screen

package
v0.0.0-...-0ee40a1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2017 License: GPL-3.0 Imports: 8 Imported by: 0

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

View Source
const (
	White = 0xFFFFFF
	Black = 0x000000
)

Variables

View Source
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 Colour

func Colour(r, g, b uint8) uint32

Colour returns a colour code suitable for use with the given RGB values.

func DrawRune

func DrawRune(r rune, fg, bg uint32, x, y int)

DrawRune draws a rune on the root window.

func DrawString

func DrawString(s string, fg, bg uint32, x, y, max int)

DrawString draws a string on the root window.

func Flush

func Flush()

Flush will cause all window output to be updated.

func GetSize

func GetSize() (w, h int)

GetSize queries the current screen size.

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

func NewWindow(w, h int) *Window

NewWindow returns a new window object with the given size. The window is not attached.

func (*Window) Attach

func (w *Window) Attach(parent *Window, px, py int, pz uint)

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

func (w *Window) DrawRune(r rune, fg, bg uint32, x, y int)

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

func (w *Window) DrawRunes(r []rune, fg, bg uint32, x, y int)

DrawRunes is an optimised version of DrawRune that writes multiple runes to the screen.

func (*Window) DrawString

func (w *Window) DrawString(s string, fg, bg uint32, x, y, max int)

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.

func (*Window) Size

func (w *Window) Size() (width, height int)

Size reports the current size of the window.

Directories

Path Synopsis
Package raw implements raw output codes for the terminal.
Package raw implements raw output codes for the terminal.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL