Documentation
¶
Overview ¶
Package screen implements a buffer for managing a screen of content and handles only sending redraw commands for data that changes. It also allows registration of callbacks for when the screen size changes.
Index ¶
- Constants
- Variables
- func Clear()
- func Colour(r, g, b uint8) uint32
- func DrawRune(r rune, fg, bg uint32, x, y int)
- func DrawString(s string, fg, bg uint32, x, y, max int)
- func Flush()
- func GetSize() (w, h int)
- func Init()
- func RegisterSizeNotifier(n ScreenSizeNotifier)
- func Stop()
- func StopSizeNotifier(n ScreenSizeNotifier)
- type ScreenSizeNotifier
- type Window
- func (w *Window) Attach(parent *Window, px, py int, pz uint)
- func (w *Window) Clear()
- func (w *Window) Detach()
- func (w *Window) DrawRune(r rune, fg, bg uint32, x, y int)
- func (w *Window) DrawRunes(r []rune, fg, bg uint32, x, y int)
- func (w *Window) DrawString(s string, fg, bg uint32, x, y, max int)
- func (w *Window) Size() (width, height int)
Constants ¶
const ( White = 0xFFFFFF Black = 0x000000 )
Variables ¶
var ( // Background is the default background colour for newly-cleared // screens/windows. Background uint32 = Black //TODO: change to white )
Functions ¶
func Clear ¶
func Clear()
Clear clears the root window. The next flush will draw the root window using the default Background colour.
func DrawString ¶
DrawString draws a string on the root window.
func Init ¶
func Init()
Init will create and draw RootWindow. You may wish to set the default Background colour first. This function will also clear the screen contents, disable scrollback mode, and disable the cursor.
func RegisterSizeNotifier ¶
func RegisterSizeNotifier(n ScreenSizeNotifier)
RegisterSizeNotifier adds a screen size change notifier to a list which will be called if the screen size changes.
func Stop ¶
func Stop()
Stop returns the screen contents to how they were before program execution, restoring scrollback.
func StopSizeNotifier ¶
func StopSizeNotifier(n ScreenSizeNotifier)
StopSizeNotifier stops notifications from being sent to the given notifier object.
Types ¶
type ScreenSizeNotifier ¶
type ScreenSizeNotifier interface {
ScreenSizeNotify(w, h int)
}
ScreenSizeNotifier objects are notified whenever the screen size changes.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window represents a buffer that may be attached and detached from other windows. When drawing the screen, we first start at the RootWindow and then iterate down over its children.
var RootWindow *Window
RootWindow represents the background of the application. It ignores calls such as Attach and Resize.
func NewWindow ¶
NewWindow returns a new window object with the given size. The window is not attached.
func (*Window) Attach ¶
Attach will attach the given window to another. It implicitly detaches the given window first if it is already attached. This function may be used to move the position of a window and to alter its z-order by re-attaching to the same parent. This call is ignored on the root window.
func (*Window) Clear ¶
func (w *Window) Clear()
Clear clears the contents of a window to the default screen background colour. All contents are lost.
func (*Window) Detach ¶
func (w *Window) Detach()
Detach will detach the given window. This call is ignored on the root window.
func (*Window) DrawRune ¶
DrawRune modifies the window by placing the given Unicode rune with fg/bg text/background colours at the given x,y coordinates.
func (*Window) DrawRunes ¶
DrawRunes is an optimised version of DrawRune that writes multiple runes to the screen.
func (*Window) DrawString ¶
DrawString modifies the window by writing the given UTF-8 string with fg/bg text/background colours at the given x, y coordinates. The string is length limited to the given max runes; pass 0 or negative to limit at the edge of the screen.