Documentation ¶
Index ¶
- Variables
- type Grid
- func (g *Grid) ClearHeader()
- func (g *Grid) Close() error
- func (g *Grid) HandleKeyboard() error
- func (g *Grid) RedrawAll() error
- func (g *Grid) RegisterKeyHandler(key termbox.Key, fct func(*Grid)) *KeyHandler
- func (g *Grid) SetCursor(x, y int)
- func (g *Grid) SetCursorOrigin()
- func (g *Grid) UnregisterKeyHandler(hdlr *KeyHandler)
- type KeyHandler
Constants ¶
This section is empty.
Variables ¶
var ( ErrTerminalTooSmall = errors.New("terminal too small") ErrKeyInUse = errors.New("key already registered") )
Common errors.
Functions ¶
This section is empty.
Types ¶
type Grid ¶
type Grid struct { // Dimensions. Height int Width int // Offset at the top of the screen. HeaderHeight int HeaderFct func(*Grid) // Internal controls. StopChan <-chan struct{} // contains filtered or unexported fields }
Grid holds the data for the terminal grid.
Sample output for a 2 rows 3 columns grid:
┌─┬─┬─┐ │ │ │ │ ├─┼─┼─┤ │ │ │ │ └─┴─┴─┘
func (*Grid) ClearHeader ¶
func (g *Grid) ClearHeader()
ClearHeader zero out the header and reset the cursor to 0,0.
func (*Grid) HandleKeyboard ¶
HandleKeyboard is the runtime loop monitoring keyboard activity.
func (*Grid) RegisterKeyHandler ¶
func (g *Grid) RegisterKeyHandler(key termbox.Key, fct func(*Grid)) *KeyHandler
RegisterKeyHandler adds a handler for the given key. Returns a pointer to the handler, needed to unregister.
func (*Grid) SetCursor ¶
SetCursor sets the cursor at the proper place and flushes the terminal. x and y are Cells, not absolute.
func (*Grid) SetCursorOrigin ¶
func (g *Grid) SetCursorOrigin()
SetCursorOrigin sets the cursor back to 0,0 to display the header.
func (*Grid) UnregisterKeyHandler ¶
func (g *Grid) UnregisterKeyHandler(hdlr *KeyHandler)
UnregisterKeyHandler removes the given handler from the list. hdlr is returned by (*gogrid.Grid).RegisterKeyHandler.
type KeyHandler ¶
KeyHandler associates a key with a callback.