From b513f2f332a74e3c56f10256da6b930bda9f16ad Mon Sep 17 00:00:00 2001 From: Achilleas Anagnostopoulos Date: Thu, 23 Mar 2017 08:01:47 +0000 Subject: [PATCH] Define console interface --- kernel/driver/video/console/console.go | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 kernel/driver/video/console/console.go diff --git a/kernel/driver/video/console/console.go b/kernel/driver/video/console/console.go new file mode 100644 index 0000000..b041fcc --- /dev/null +++ b/kernel/driver/video/console/console.go @@ -0,0 +1,52 @@ +package console + +import "sync" + +// Attr defines a color attribute. +type Attr uint16 + +// The set of attributes that can be passed to Write(). +const ( + Black Attr = iota + Blue + Green + Cyan + Red + Magenta + Brown + LightGrey + Grey + LightBlue + LightGreen + LightCyan + LightRed + LightMagenta + LightBrown + White +) + +// ScrollDir defines a scroll direction. +type ScrollDir uint8 + +// The supported list of scroll directions for the console Scroll() calls. +const ( + Up ScrollDir = iota + Down +) + +// The console.Interface is implemented by objects that can function as physical consoles. +type Interface interface { + sync.Locker + + // Dimensions returns the width and height of the console in characters. + Dimensions() (uint16, uint16) + + // Clear clears the specified rectangular region + Clear(x, y, width, height uint16) + + // Scroll a particular number of lines to the specified direction. + Scroll(dir ScrollDir, lines uint16) + + // Write a char to the specified location. + Write(ch byte, attr Attr, x, y uint16) +}