Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyAttrs(ss *vaxis.StyledString, style vaxis.Style)
- func ApplyStyle(style vaxis.Style, str string) string
- func Close()
- func Const(i int) func() int
- func Exit()
- func HandleEvent(event vaxis.Event)
- func Initialize(content DrawableInteractive) error
- func Invalidate()
- func PadLeft(ss *vaxis.StyledString, width int)
- func PadRight(ss *vaxis.StyledString, width int)
- func QueueFunc(fn func())
- func QueueRefresh()
- func QueueSuspend()
- func Render()
- func ResumeScreen()
- func StyledString(s string) *vaxis.StyledString
- func Suspend() error
- func SuspendScreen()
- func Truncate(ss *vaxis.StyledString, width int)
- func TruncateHead(ss *vaxis.StyledString, width int)
- type Beeper
- type Bordered
- type Box
- type Closeable
- type Column
- type Container
- type Context
- func (ctx *Context) Fill(x, y, width, height int, rune rune, style vaxis.Style)
- func (ctx *Context) Height() int
- func (ctx *Context) HideCursor()
- func (ctx *Context) Popover(x, y, width, height int, d Drawable)
- func (ctx *Context) Printf(x, y int, style vaxis.Style, format string, a ...interface{}) int
- func (ctx *Context) SetCell(x, y int, ch rune, style vaxis.Style)
- func (ctx *Context) SetCursor(x, y int, style vaxis.CursorStyle)
- func (ctx *Context) Size() (int, int)
- func (ctx *Context) Subcontext(x, y, width, height int) *Context
- func (ctx *Context) Width() int
- func (ctx *Context) Window() vaxis.Window
- type Drawable
- type DrawableInteractive
- type DrawableInteractiveBeeper
- type Fill
- type Grid
- func (grid *Grid) AddChild(content Drawable) *GridCell
- func (grid *Grid) Columns(spec []GridSpec) *Grid
- func (grid *Grid) Draw(ctx *Context)
- func (grid *Grid) Invalidate()
- func (grid *Grid) MouseEvent(localX int, localY int, event vaxis.Event)
- func (grid *Grid) RemoveChild(content Drawable)
- func (grid *Grid) ReplaceChild(old Drawable, new Drawable)
- func (grid *Grid) Rows(spec []GridSpec) *Grid
- type GridCell
- type GridSpec
- type Interactive
- type MouseHandler
- type Mouseable
- type MouseableDrawableInteractive
- type Popover
- type Row
- type Stack
- type Tab
- type TabContent
- type TabStrip
- type Table
- type Tabs
- func (tabs *Tabs) Add(content Drawable, name string, background bool) *Tab
- func (tabs *Tabs) Get(index int) *Tab
- func (tabs *Tabs) MoveTab(to int, relative bool)
- func (tabs *Tabs) Names() []string
- func (tabs *Tabs) NextTab()
- func (tabs *Tabs) PinTab()
- func (tabs *Tabs) PrevTab()
- func (tabs *Tabs) Remove(content Drawable)
- func (tabs *Tabs) Replace(contentSrc Drawable, contentTarget Drawable, name string)
- func (tabs *Tabs) Select(index int) bool
- func (tabs *Tabs) SelectName(name string) bool
- func (tabs *Tabs) SelectOffset(offset int)
- func (tabs *Tabs) SelectPrevious() bool
- func (tabs *Tabs) Selected() *Tab
- func (tabs *Tabs) UnpinTab()
- type Text
- type TextInput
- func (ti *TextInput) Draw(ctx *Context)
- func (ti *TextInput) Event(event vaxis.Event) bool
- func (ti *TextInput) Focus(focus bool)
- func (ti *TextInput) Invalidate()
- func (ti *TextInput) MouseEvent(localX int, localY int, event vaxis.Event)
- func (ti *TextInput) OnChange(onChange func(ti *TextInput))
- func (ti *TextInput) OnFocusLost(onFocusLost func(ti *TextInput))
- func (ti *TextInput) Password(password bool) *TextInput
- func (ti *TextInput) Prompt(prompt string) *TextInput
- func (ti *TextInput) Set(value string) *TextInput
- func (ti *TextInput) String() string
- func (ti *TextInput) StringLeft() string
- func (ti *TextInput) StringRight() string
- func (ti *TextInput) TabComplete(tabcomplete func(ctx context.Context, s string) ([]opt.Completion, string), ...) *TextInput
- type Visible
Constants ¶
const ( BORDER_LEFT = 1 << iota BORDER_TOP = 1 << iota BORDER_RIGHT = 1 << iota BORDER_BOTTOM = 1 << iota )
const ( SIZE_EXACT = iota SIZE_WEIGHT = iota )
const ( TEXT_LEFT = iota TEXT_CENTER = iota TEXT_RIGHT = iota )
Variables ¶
var Callbacks = make(chan func(), 50)
var Events = make(chan vaxis.Event)
Use unbuffered channels (always blocking unless somebody can read immediately) We are merely using this as a proxy to the internal vaxis event channel.
var Quit = make(chan struct{})
var Redraw = make(chan bool, 1)
Use a buffered channel of size 1 to avoid blocking callers of Invalidate()
var SuspendQueue = make(chan bool, 1)
Functions ¶
func ApplyAttrs ¶
func ApplyAttrs(ss *vaxis.StyledString, style vaxis.Style)
ApplyAttrs applies the style, and if another style is present ORs the attributes
func ApplyStyle ¶
Applies a style to a string. Any currently applied styles will not be overwritten
func HandleEvent ¶
func Initialize ¶
func Initialize(content DrawableInteractive) error
func Invalidate ¶
func Invalidate()
Invalidate marks the entire UI as invalid and request a redraw as soon as possible. Invalidate can be called from any goroutine and will never block.
func PadLeft ¶
func PadLeft(ss *vaxis.StyledString, width int)
PadLeft inserts blank spaces at the beginning of the StyledString to produce a string of the provided width
func PadRight ¶
func PadRight(ss *vaxis.StyledString, width int)
PadLeft inserts blank spaces at the end of the StyledString to produce a string of the provided width
func QueueFunc ¶
func QueueFunc(fn func())
QueueFunc queues a function to be called in the main goroutine. This can be used to prevent race conditions from delayed functions
func QueueRefresh ¶
func QueueRefresh()
func QueueSuspend ¶
func QueueSuspend()
func ResumeScreen ¶
func ResumeScreen()
func StyledString ¶
func StyledString(s string) *vaxis.StyledString
func Truncate ¶
func Truncate(ss *vaxis.StyledString, width int)
Truncates the styled string on the right and inserts a '…' as the last character
func TruncateHead ¶
func TruncateHead(ss *vaxis.StyledString, width int)
TruncateHead truncates the left side of the string and inserts '…' as the first character
Types ¶
type Bordered ¶
type Bordered struct {
// contains filtered or unexported fields
}
func NewBordered ¶
func (*Bordered) Invalidate ¶
func (bordered *Bordered) Invalidate()
type Box ¶
type Box struct {
// contains filtered or unexported fields
}
func (*Box) Invalidate ¶
func (b *Box) Invalidate()
type Container ¶
type Container interface { Drawable // Return all of the drawables which are children of this one (do not // recurse into your grandchildren). Children() []Drawable }
A drawable which contains other drawables
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
A context allows you to draw in a sub-region of the terminal
func (*Context) HideCursor ¶
func (ctx *Context) HideCursor()
func (*Context) Subcontext ¶
type Drawable ¶
type Drawable interface { // Called when this renderable should draw itself. Draw(ctx *Context) // Invalidates the UI. This can be called from any goroutine. Invalidate() }
Drawable is a UI component that can draw. Unless specified, all methods must only be called from a single goroutine, the UI goroutine.
type DrawableInteractive ¶
type DrawableInteractive interface { Drawable Interactive }
type DrawableInteractiveBeeper ¶
type DrawableInteractiveBeeper interface { DrawableInteractive Beeper }
type Fill ¶
func (Fill) Invalidate ¶
func (f Fill) Invalidate()
type Grid ¶
type Grid struct {
// contains filtered or unexported fields
}
func MakeGrid ¶
MakeGrid creates a grid with the specified number of columns and rows. Each cell has a size of 1.
func (*Grid) Invalidate ¶
func (grid *Grid) Invalidate()
func (*Grid) RemoveChild ¶
func (*Grid) ReplaceChild ¶
type GridSpec ¶
type GridSpec struct { // One of SIZE_EXACT or SIZE_WEIGHT Strategy int // If Strategy = SIZE_EXACT, this function returns the number of cells // this row/col shall occupy. If SIZE_WEIGHT, the space left after all // exact rows/cols are measured is distributed amonst the remainder // weighted by the value returned by this function. Size func() int }
Specifies the layout of a single row or column
type Interactive ¶
type MouseHandler ¶
type Mouseable ¶
type Mouseable interface { Drawable MouseHandler }
A drawable that can be interacted with by the mouse
type MouseableDrawableInteractive ¶
type MouseableDrawableInteractive interface { DrawableInteractive MouseHandler }
type Popover ¶
type Popover struct {
// contains filtered or unexported fields
}
func (*Popover) Invalidate ¶
func (p *Popover) Invalidate()
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
func (*Stack) Invalidate ¶
func (stack *Stack) Invalidate()
func (*Stack) MouseEvent ¶
type TabContent ¶
type TabContent Tabs
func (*TabContent) Children ¶
func (content *TabContent) Children() []Drawable
func (*TabContent) Draw ¶
func (content *TabContent) Draw(ctx *Context)
func (*TabContent) Invalidate ¶
func (content *TabContent) Invalidate()
func (*TabContent) MouseEvent ¶
func (content *TabContent) MouseEvent(localX int, localY int, event vaxis.Event)
type TabStrip ¶
type TabStrip Tabs
func (*TabStrip) Invalidate ¶
func (strip *TabStrip) Invalidate()
type Table ¶
type Table struct { Columns []Column Rows []Row Height int // Optional callback that allows customizing the default drawing routine // of table rows. If true is returned, the default routine is skipped. CustomDraw func(t *Table, row int, c *Context) bool // Optional callback that allows returning a custom style for the row. GetRowStyle func(t *Table, row int) vaxis.Style // contains filtered or unexported fields }
type Tabs ¶
type Tabs struct { TabStrip *TabStrip TabContent *TabContent CloseTab func(index int) // contains filtered or unexported fields }
func (*Tabs) SelectName ¶
func (*Tabs) SelectOffset ¶
func (*Tabs) SelectPrevious ¶
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
func (*Text) Invalidate ¶
func (t *Text) Invalidate()
type TextInput ¶
func NewTextInput ¶
Creates a new TextInput. TextInputs will render a "textbox" in the entire context they're given, and process keypresses to build a string from user input.
func (*TextInput) Invalidate ¶
func (ti *TextInput) Invalidate()