Documentation ¶
Index ¶
- Variables
- func EnableMouseEvents()
- func HideCursor()
- func Init() error
- func SetCursor(x, y int)
- func ShowCursor()
- func Size() (int, int, error)
- func StartKeyReadLoop(keyChan chan<- ScanCode, errChan chan<- error)
- func Stop()
- type Attribute
- type CellState
- type Color
- type Framebuffer
- func (f *Framebuffer) ASCIIRect(x0, y0, w, h int, doubleWidth bool, clearInside bool)
- func (f *Framebuffer) AttribRect(x0, y0, w, h int, s CellState)
- func (f *Framebuffer) AttribText(x0, y0 int, s CellState, t string)
- func (f *Framebuffer) CenterText(x, y0 int, t string)
- func (f *Framebuffer) Clear()
- func (f *Framebuffer) Flush()
- func (f *Framebuffer) Get(x, y int) (rune, CellState)
- func (f *Framebuffer) GetAttrNone() Attribute
- func (f *Framebuffer) GetBoldWhiteOnBlack() CellState
- func (f *Framebuffer) GetColorBlue() Color
- func (f *Framebuffer) GetColorGray() Color
- func (f *Framebuffer) GetHeight() int
- func (f *Framebuffer) GetWidth() int
- func (f *Framebuffer) NewCellState() CellState
- func (f *Framebuffer) Set(x, y int, s CellState, r rune)
- func (f *Framebuffer) SetRect(x0, y0, w, h int, s CellState, r rune)
- func (f *Framebuffer) SetRune(x, y int, r rune)
- func (f *Framebuffer) SetText(x0, y0 int, t string)
- type ScanCode
Constants ¶
This section is empty.
Variables ¶
var ( StateDefault = CellState{Attrib: AttrNone, FGColor: ColorDefault, BGColor: ColorDefault} BoldWhiteOnBlack = CellState{Attrib: AttrBold, FGColor: ColorGray.Light(), BGColor: ColorBlack} BoldBlackOnWhite = CellState{Attrib: AttrBold, FGColor: ColorBlack, BGColor: ColorGray.Light()} )
Predefined attributes
var ErrNotATerminal = errors.New("not running in a terminal")
ErrNotATerminal is the error returned when running termo in an unsupported environment
Functions ¶
func EnableMouseEvents ¶
func EnableMouseEvents()
EnableMouseEvents makes mouse events start arriving through the input read loop
func SetCursor ¶
func SetCursor(x, y int)
SetCursor positions the cursor at the specified coordinates. Cursor visibility is not affected.
func StartKeyReadLoop ¶
StartKeyReadLoop runs a goroutine that keeps reading terminal input forever. It returns events through the keyChan param, and errors through the errChan parameter
Types ¶
type Color ¶
type Color int
Color holds character color information
type Framebuffer ¶
type Framebuffer struct {
// contains filtered or unexported fields
}
Framebuffer contains the runes and attributes that will be drawn in the terminal
func NewFramebuffer ¶
func NewFramebuffer(w, h int) *Framebuffer
NewFramebuffer creates a Framebuffer with the specified size and initializes it filling it with blank spaces and default attributes
func (*Framebuffer) ASCIIRect ¶
func (f *Framebuffer) ASCIIRect(x0, y0, w, h int, doubleWidth bool, clearInside bool)
ASCIIRect draws an ASCII rectangle. It can either be single-width (─) or double-width (═). It can also clear the inner part of the rectangle, if desired.
func (*Framebuffer) AttribRect ¶
func (f *Framebuffer) AttribRect(x0, y0, w, h int, s CellState)
AttribRect sets the attributes for a rectangular region without changing the runes
func (*Framebuffer) AttribText ¶
func (f *Framebuffer) AttribText(x0, y0 int, s CellState, t string)
AttribText draws a string from left to right, starting at x0,y0 There is no wrapping mechanism, and parts of the text outside the framebuffer will be ignored. This call will also change the written cells' attributes to the specified ones.
func (*Framebuffer) CenterText ¶
func (f *Framebuffer) CenterText(x, y0 int, t string)
CenterText draws a string from left to right and top-to-bottom, starting at x-len(t)/2,y0. There is no wrapping mechanism, and parts of the text outside the framebuffer will be ignored. Attributes for written cells will remain unchanged.
func (*Framebuffer) Clear ¶
func (f *Framebuffer) Clear()
Clear fills the framebuffer with blank spaces and default attributes
func (*Framebuffer) Flush ¶
func (f *Framebuffer) Flush()
Flush pushes the current state of the framebuffer to the terminal
func (*Framebuffer) Get ¶
func (f *Framebuffer) Get(x, y int) (rune, CellState)
Get returns the rune stored in the [x,y] position. If coords are outside the framebuffer size, it returns ' '
func (*Framebuffer) GetAttrNone ¶
func (f *Framebuffer) GetAttrNone() Attribute
func (*Framebuffer) GetBoldWhiteOnBlack ¶
func (f *Framebuffer) GetBoldWhiteOnBlack() CellState
func (*Framebuffer) GetColorBlue ¶
func (f *Framebuffer) GetColorBlue() Color
func (*Framebuffer) GetColorGray ¶
func (f *Framebuffer) GetColorGray() Color
func (*Framebuffer) GetHeight ¶
func (f *Framebuffer) GetHeight() int
func (*Framebuffer) GetWidth ¶
func (f *Framebuffer) GetWidth() int
func (*Framebuffer) NewCellState ¶
func (f *Framebuffer) NewCellState() CellState
func (*Framebuffer) Set ¶
func (f *Framebuffer) Set(x, y int, s CellState, r rune)
Set sets a rune in the specified position with the specified attributes
func (*Framebuffer) SetRect ¶
func (f *Framebuffer) SetRect(x0, y0, w, h int, s CellState, r rune)
SetRect fills a rectangular region with a rune and state
func (*Framebuffer) SetRune ¶
func (f *Framebuffer) SetRune(x, y int, r rune)
SetRune sets a rune in the specified position without modifying its attributes
func (*Framebuffer) SetText ¶
func (f *Framebuffer) SetText(x0, y0 int, t string)
SetText draws a string from left to right, and top-to bottom, starting at x0,y0. There is no wrapping mechanism, and parts of the text outside the framebuffer will be ignored. Attributes for written cells will remain unchanged.
type ScanCode ¶
type ScanCode []byte
ScanCode contains data for a terminal keypress
func ReadScanCode ¶
ReadScanCode reads a keypress from stdin. It will block until it can read something
func (ScanCode) EscapeCode ¶
EscapeCode returns the escape code for a keypress
func (ScanCode) IsEscapeCode ¶
IsEscapeCode returns true if the terminal considers it an escape code
func (ScanCode) IsMouseDownEvent ¶
IsMouseDownEvent returns wether it is a mouse button down event
func (ScanCode) IsMouseMoveEvent ¶
IsMouseMoveEvent returns wether it is a mouse move event
func (ScanCode) IsMouseUpEvent ¶
IsMouseUpEvent returns wether it is a mouse button up event
func (ScanCode) MouseCoords ¶
MouseCoords returns data for the mouse position. Returned coords start at [0,0] for upper-left corner