From b72725742ab5554f8c25d22005fe8fdf77e8f205 Mon Sep 17 00:00:00 2001 From: Achilleas Anagnostopoulos Date: Tue, 4 Jul 2017 07:07:59 +0100 Subject: [PATCH] Revise console interface --- src/gopheros/device/video/console/device.go | 45 +++++++++++++++++ .../kernel/driver/video/console/console.go | 48 ------------------- 2 files changed, 45 insertions(+), 48 deletions(-) create mode 100644 src/gopheros/device/video/console/device.go delete mode 100644 src/gopheros/kernel/driver/video/console/console.go diff --git a/src/gopheros/device/video/console/device.go b/src/gopheros/device/video/console/device.go new file mode 100644 index 0000000..8129216 --- /dev/null +++ b/src/gopheros/device/video/console/device.go @@ -0,0 +1,45 @@ +package console + +import "image/color" + +// 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 Device interface is implemented by objects that can function as system +// consoles. +type Device interface { + // Dimensions returns the width and height of the console in characters. + Dimensions() (uint16, uint16) + + // DefaultColors returns the default foreground and background colors + // used by this console. + DefaultColors() (fg, bg uint8) + + // Fill sets the contents of the specified rectangular region to the + // requested color. Both x and y coordinates are 1-based (top-left + // corner has coordinates 1,1). + Fill(x, y, width, height uint16, fg, bg uint8) + + // Scroll the console contents to the specified direction. The caller + // is responsible for updating (e.g. clear or replace) the contents of + // the region that was scrolled. + Scroll(dir ScrollDir, lines uint16) + + // Write a char to the specified location. Both x and y coordinates are + // 1-based (top-left corner has coordinates 1,1). + Write(ch byte, fg, bg uint8, x, y uint16) + + // Palette returns the active color palette for this console. + Palette() color.Palette + + // SetPaletteColor updates the color definition for the specified + // palette index. Passing a color index greated than the number of + // supported colors should be a no-op. + SetPaletteColor(uint8, color.RGBA) +} diff --git a/src/gopheros/kernel/driver/video/console/console.go b/src/gopheros/kernel/driver/video/console/console.go deleted file mode 100644 index 0b2cf1f..0000000 --- a/src/gopheros/kernel/driver/video/console/console.go +++ /dev/null @@ -1,48 +0,0 @@ -package console - -// 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 Console interface { - // 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) -}