ui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2019 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BORDER_LEFT   = 1 << iota
	BORDER_TOP    = 1 << iota
	BORDER_RIGHT  = 1 << iota
	BORDER_BOTTOM = 1 << iota
)
View Source
const (
	SIZE_EXACT  = iota
	SIZE_WEIGHT = iota
)
View Source
const (
	TEXT_LEFT   = iota
	TEXT_CENTER = iota
	TEXT_RIGHT  = iota
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bordered

type Bordered struct {
	Invalidatable
	// contains filtered or unexported fields
}

func NewBordered

func NewBordered(content Drawable, borders uint) *Bordered

func (*Bordered) Children

func (bordered *Bordered) Children() []Drawable

func (*Bordered) Draw

func (bordered *Bordered) Draw(ctx *Context)

func (*Bordered) Invalidate

func (bordered *Bordered) 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 NewContext

func NewContext(width, height int, screen tcell.Screen) *Context

func (*Context) Fill

func (ctx *Context) Fill(x, y, width, height int, rune rune, style tcell.Style)

func (*Context) Height

func (ctx *Context) Height() int

func (*Context) HideCursor

func (ctx *Context) HideCursor()

func (*Context) Printf

func (ctx *Context) Printf(x, y int, style tcell.Style,
	format string, a ...interface{}) int

func (*Context) SetCell

func (ctx *Context) SetCell(x, y int, ch rune, style tcell.Style)

func (*Context) SetCursor

func (ctx *Context) SetCursor(x, y int)

func (*Context) Subcontext

func (ctx *Context) Subcontext(x, y, width, height int) *Context

func (*Context) Width

func (ctx *Context) Width() int

func (*Context) X

func (ctx *Context) X() int

func (*Context) Y

func (ctx *Context) Y() int

type Drawable

type Drawable interface {
	// Called when this renderable should draw itself.
	Draw(ctx *Context)
	// Specifies a function to call when this cell needs to be redrawn. The
	// callback may be called in any goroutine.
	OnInvalidate(callback func(d Drawable))
	// Invalidates the drawable. 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 Fill

type Fill rune

func NewFill

func NewFill(f rune) Fill

func (Fill) Draw

func (f Fill) Draw(ctx *Context)

func (Fill) Invalidate

func (f Fill) Invalidate()

func (Fill) OnInvalidate

func (f Fill) OnInvalidate(callback func(d Drawable))

type Grid

type Grid struct {
	Invalidatable
	// contains filtered or unexported fields
}

func NewGrid

func NewGrid() *Grid

func (*Grid) AddChild

func (grid *Grid) AddChild(content Drawable) *GridCell

func (*Grid) Children

func (grid *Grid) Children() []Drawable

func (*Grid) Columns

func (grid *Grid) Columns(spec []GridSpec) *Grid

func (*Grid) Draw

func (grid *Grid) Draw(ctx *Context)

func (*Grid) Invalidate

func (grid *Grid) Invalidate()

func (*Grid) RemoveChild

func (grid *Grid) RemoveChild(content Drawable)

func (*Grid) Rows

func (grid *Grid) Rows(spec []GridSpec) *Grid

type GridCell

type GridCell struct {
	Row     int
	Column  int
	RowSpan int
	ColSpan int
	Content Drawable
	// contains filtered or unexported fields
}

func (*GridCell) At

func (cell *GridCell) At(row, col int) *GridCell

func (*GridCell) Span

func (cell *GridCell) Span(rows, cols int) *GridCell

type GridSpec

type GridSpec struct {
	// One of SIZE_EXACT or SIZE_WEIGHT
	Strategy int
	// If Strategy = SIZE_EXACT, this is 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 this value.
	Size int
}

Specifies the layout of a single row or column

type Interactive

type Interactive interface {
	// Returns true if the event was handled by this component
	Event(event tcell.Event) bool
	// Indicates whether or not this control will receive input events
	Focus(focus bool)
}

type Invalidatable

type Invalidatable struct {
	// contains filtered or unexported fields
}

func (*Invalidatable) DoInvalidate

func (i *Invalidatable) DoInvalidate(d Drawable)

func (*Invalidatable) OnInvalidate

func (i *Invalidatable) OnInvalidate(f func(d Drawable))

type Simulator

type Simulator interface {
	// Queues up the given input events for simulation
	Simulate(events []tcell.Event)
}

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

func NewStack

func NewStack() *Stack

func (*Stack) Children

func (stack *Stack) Children() []Drawable

func (*Stack) Draw

func (stack *Stack) Draw(ctx *Context)

func (*Stack) Invalidate

func (stack *Stack) Invalidate()

func (*Stack) OnInvalidate

func (stack *Stack) OnInvalidate(onInvalidate func(d Drawable))

func (*Stack) Peek

func (stack *Stack) Peek() Drawable

func (*Stack) Pop

func (stack *Stack) Pop() Drawable

func (*Stack) Push

func (stack *Stack) Push(d Drawable)

type Tab

type Tab struct {
	Content Drawable
	Name    string
	// contains filtered or unexported fields
}

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) OnInvalidate

func (content *TabContent) OnInvalidate(onInvalidate func(d Drawable))

type TabStrip

type TabStrip Tabs

func (*TabStrip) Draw

func (strip *TabStrip) Draw(ctx *Context)

TODO: Color repository

func (*TabStrip) Invalidate

func (strip *TabStrip) Invalidate()

func (*TabStrip) OnInvalidate

func (strip *TabStrip) OnInvalidate(onInvalidate func(d Drawable))

type Tabs

type Tabs struct {
	Tabs       []*Tab
	TabStrip   *TabStrip
	TabContent *TabContent
	Selected   int
	// contains filtered or unexported fields
}

func NewTabs

func NewTabs() *Tabs

func (*Tabs) Add

func (tabs *Tabs) Add(content Drawable, name string) *Tab

func (*Tabs) Remove

func (tabs *Tabs) Remove(content Drawable)

func (*Tabs) Select

func (tabs *Tabs) Select(index int)

type Text

type Text struct {
	Invalidatable
	// contains filtered or unexported fields
}

func NewText

func NewText(text string) *Text

func (*Text) Bold

func (t *Text) Bold(bold bool) *Text

func (*Text) Color

func (t *Text) Color(fg tcell.Color, bg tcell.Color) *Text

func (*Text) Draw

func (t *Text) Draw(ctx *Context)

func (*Text) Invalidate

func (t *Text) Invalidate()

func (*Text) Reverse

func (t *Text) Reverse(reverse bool) *Text

func (*Text) Strategy

func (t *Text) Strategy(strategy uint) *Text

func (*Text) Text

func (t *Text) Text(text string) *Text

type TextInput

type TextInput struct {
	Invalidatable
	// contains filtered or unexported fields
}

func NewTextInput

func NewTextInput(text string) *TextInput

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) Draw

func (ti *TextInput) Draw(ctx *Context)

func (*TextInput) Event

func (ti *TextInput) Event(event tcell.Event) bool

func (*TextInput) Focus

func (ti *TextInput) Focus(focus bool)

func (*TextInput) Invalidate

func (ti *TextInput) Invalidate()

func (*TextInput) OnChange

func (ti *TextInput) OnChange(onChange func(ti *TextInput))

func (*TextInput) Password

func (ti *TextInput) Password(password bool) *TextInput

func (*TextInput) Prompt

func (ti *TextInput) Prompt(prompt string) *TextInput

func (*TextInput) Set

func (ti *TextInput) Set(value string)

func (*TextInput) String

func (ti *TextInput) String() string

type UI

type UI struct {
	Content DrawableInteractive
	// contains filtered or unexported fields
}

func Initialize

func Initialize(conf *config.AercConfig,
	content DrawableInteractive) (*UI, error)

func (*UI) Close

func (state *UI) Close()

func (*UI) Exit

func (state *UI) Exit()

func (*UI) ShouldExit

func (state *UI) ShouldExit() bool

func (*UI) Tick

func (state *UI) Tick() bool

Jump to

Keyboard shortcuts

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