Documentation ¶
Index ¶
- Variables
- func JustKeepRunning(factory func(v *View) (Client, error)) error
- type Align
- type Client
- type Grid
- func (g Grid) Copy(og Grid)
- func (g Grid) Get(x, y int) termbox.Cell
- func (g Grid) Lines(fillZero rune) []string
- func (g Grid) Merge(x, y int, ch rune, fg, bg termbox.Attribute)
- func (g *Grid) Resize(sz point.Point)
- func (g Grid) Set(x, y int, ch rune, fg, bg termbox.Attribute)
- func (g Grid) WriteString(x, y int, mess string, args ...interface{}) int
- func (g Grid) WriteStringRTL(x, y int, mess string, args ...interface{}) int
- type KeyEvent
- type Layout
- type LayoutPlacement
- type Renderable
- type View
Constants ¶
This section is empty.
Variables ¶
var ErrStop = errors.New("client stop")
ErrStop may be returned by a client method to mean "we're done, break run loop".
Functions ¶
Types ¶
type Align ¶
type Align uint8
Align specifies alignment to Layout placements.
const ( // AlignLeft causes left horizontal alignment in a Layout. AlignLeft Align = 1 << iota // AlignRight causes right horizontal alignment in a Layout. AlignRight // AlignTop causes top vertical alignment in a Layout. AlignTop // AlignBottom causes bottom vertical alignment in a Layout. AlignBottom // AlignHFlush causes horizontal alignment to accept no offset; so it will // always get the "next empty row" in the relevant vertical direction. AlignHFlush // AlignCenter causes center horizontal alignment in a layout. AlignCenter = AlignLeft | AlignRight // AlignMiddle causes middle vertical alignment in a layout. AlignMiddle = AlignTop | AlignBottom )
type Client ¶
Client is the interface exposed to the user of View; its various methods are called in a loop that provides terminal orchestration.
type Grid ¶
Grid represents a sized buffer of terminal cells.
func (Grid) Lines ¶
Lines returns a slice of row strings from the grid, filling in any zero runes with the given one.
func (*Grid) Resize ¶
Resize update the grid size, growing Data capacity or truncating its length as needed.
func (Grid) WriteString ¶
WriteString writes a string into the grid at the given position, returning how many cells were affected.
type Layout ¶
type Layout struct { Grid // contains filtered or unexported fields }
Layout places Renderables in a Grid, keeping track of used left/right/center space to inform future placements.
func (*Layout) Place ¶
func (lay *Layout) Place(ren Renderable, align Align) LayoutPlacement
Place a Renderable into layout, returning false if the placement can't be done.
func (*Layout) Render ¶
func (lay *Layout) Render(ren Renderable, align Align) LayoutPlacement
Render places and renders a Renderable if the placement succeeded.
type LayoutPlacement ¶
type LayoutPlacement struct {
// contains filtered or unexported fields
}
LayoutPlacement represents a placement made by a Layout for a Renderable.
func MakeLayoutPlacement ¶
func MakeLayoutPlacement(lay *Layout, ren Renderable) LayoutPlacement
MakeLayoutPlacement makes a new placement for the given layout and renderable; it records the wanted/needed render sizes, ready to attempt placement.
func (*LayoutPlacement) Render ¶
func (plc *LayoutPlacement) Render()
Render renders the placement, if it has been resolved successfully.
func (*LayoutPlacement) Try ¶
func (plc *LayoutPlacement) Try(align Align) bool
Try attempts to (re)resolve the placement with an other alignment.
type Renderable ¶
Renderable is an element for Layout to place and maybe render; if its Render method is called, it will get a grid of at least the needed RenderSize.
func RenderString ¶
func RenderString(mess string, args ...interface{}) Renderable
RenderString constructs a static string Renderable; either the entire string is rendered, or not; no truncation is supported.