Documentation ¶
Index ¶
- Constants
- Variables
- func Clear()
- func Close()
- func Decorate(this *Pencere, buf *Buffer)
- func Error(issue, diagnostics string)
- func Init() error
- func Loop()
- func MaxString(s string, l int) string
- func NextTo(p *Pencere, n *Pencere) func() error
- func Render() error
- func RenderOLD(bs ...Bufferer)
- func Round(f float64) float64
- func SetFocus(p *Pencere)
- func StopLoop()
- type Buffer
- func (self *Buffer) At(x, y int) Cell
- func (self *Buffer) Fill(c Cell)
- func (self *Buffer) Merge(bs ...*Buffer)
- func (self *Buffer) MergeChildArea(buf *Buffer, left, top, width, height int)
- func (self *Buffer) MergeWithOffset(buf *Buffer, xOffset, yOffset int)
- func (self *Buffer) SetArea(r image.Rectangle)
- func (self *Buffer) SetAreaXY(x, y int)
- func (self *Buffer) SetCell(x, y int, c Cell)
- func (self *Buffer) SetString(x, y int, s string, fg, bg Color)
- type Bufferer
- type Cell
- type Color
- type Colorscheme
- type Control
- type Decoration
- type DragBeginEvent
- type DragContext
- type DragEndEvent
- type DragEnterEvent
- type DragLeaveEvent
- type DragOverEvent
- type DraggingEvent
- type DropEvent
- type EventBus
- type EventCallback
- type EventData
- type EventStream
- type Key
- type KeyEvent
- type Menu
- type MenuItem
- type MenuList
- type Modifier
- type MouseEvent
- type MultiLineTextBox
- type Option
- type Pencere
- func NewBox(options ...Option) (*Pencere, error)
- func NewButton(label string, options ...Option) (*Pencere, error)
- func NewMenuBar(options ...Option) (*Pencere, error)
- func NewOutput(options ...Option) (*Pencere, error)
- func NewPencere(options ...Option) (*Pencere, error)
- func NewStatusBar(options ...Option) (*Pencere, error)
- func Root() *Pencere
- func (this *Pencere) AddWindow(c Control)
- func (this *Pencere) Apply(options ...Option) error
- func (this *Pencere) Childs() []*Pencere
- func (this *Pencere) FireEvent(eventType string, data interface{}) error
- func (this *Pencere) GetLayoutOrder() int
- func (this *Pencere) GetZIndex() int
- func (this *Pencere) GlobalPosition() (int, int)
- func (this *Pencere) Parent() *Pencere
- func (this *Pencere) SetButtomBar(p *Pencere)
- func (this *Pencere) SetLayoutOrder(layoutOrder int)
- func (this *Pencere) SetLeftBar(p *Pencere)
- func (this *Pencere) SetRightBar(p *Pencere)
- func (this *Pencere) SetTopBar(p *Pencere)
- func (this *Pencere) SetZIndex(zindex int)
- func (this *Pencere) TranslateToXY(globalX int, globalY int) (int, int)
- func (this *Pencere) Window() *Pencere
- type PencereOrder
- type Properties
- func (this Properties) GetColor(key string, def Color) Color
- func (this Properties) GetInt(key string, def int) int
- func (this Properties) GetString(key string, def string) string
- func (this Properties) GetValue(name string) interface{}
- func (this Properties) SetColor(name string, value Color)
- func (this Properties) SetInt(name string, value int)
- func (this Properties) SetString(name string, value string)
- func (this Properties) SetValue(name string, value interface{})
- type RuneBuffer
- func (r *RuneBuffer) Backspace()
- func (r *RuneBuffer) CursorPos() image.Point
- func (r *RuneBuffer) Delete()
- func (r *RuneBuffer) Kill()
- func (r *RuneBuffer) Len() int
- func (r *RuneBuffer) MoveBackward()
- func (r *RuneBuffer) MoveForward()
- func (r *RuneBuffer) MoveToLineEnd()
- func (r *RuneBuffer) MoveToLineStart()
- func (r *RuneBuffer) Pos() int
- func (r *RuneBuffer) Runes() []rune
- func (r *RuneBuffer) Set(buf []rune)
- func (r *RuneBuffer) SetMaxWidth(w int)
- func (r *RuneBuffer) SetWithIdx(idx int, buf []rune)
- func (r *RuneBuffer) SplitByLine() []string
- func (r *RuneBuffer) String() string
- func (r *RuneBuffer) Width() int
- func (r *RuneBuffer) WriteRune(s rune)
- func (r *RuneBuffer) WriteRunes(s []rune)
- type Style
- type Table
- func (self *Table) Bottom()
- func (self *Table) Click(x, y int)
- func (self *Table) ColResize()
- func (self *Table) Down()
- func (self *Table) HalfPageDown()
- func (self *Table) HalfPageUp()
- func (self *Table) OnKeyEvent(event KeyEvent) error
- func (self *Table) PageDown()
- func (self *Table) PageUp()
- func (self *Table) Render(buf *Buffer) error
- func (self *Table) Top()
- func (self *Table) Up()
- type Theme
- type VerticalSplitter
- type Widget
Constants ¶
const ( TOP_RIGHT = '┐' VERTICAL_LINE = '│' HORIZONTAL_LINE = '─' TOP_LEFT = '┌' BOTTOM_RIGHT = '┘' BOTTOM_LEFT = '└' VERTICAL_LEFT = '┤' VERTICAL_RIGHT = '├' HORIZONTAL_DOWN = '┬' HORIZONTAL_UP = '┴' QUOTA_LEFT = '«' QUOTA_RIGHT = '»' FOCUSED_TOP_LEFT = '╒' FOCUSED_TOP_RIGT = '╕' FOCUSED_TOP = '═' //SCROLL_BASE = '░' //SCROLL_BASE = '█' SCROLL_BASE = ' ' SCROLL_BUTTON = '█' )
const ( KeyBackspace = KeyBS KeyTab = KeyTAB KeyEsc = KeyESC KeyEscape = KeyESC KeyEnter = KeyCR KeyBackspace2 = KeyDEL )
These are aliases for other keys.
const ( BORDER = 1 << iota SCROLLABLE ENABLED VISIBLE CANFOCUS )
const ColorDefault = -1
ColorDefault = clear
const DOTS = '…'
Variables ¶
var Bus = NewEventBus()
var DefaultTheme = &Theme{ styles: map[string]Style{ "default": {Fg: 100, Bg: 230}, "border": {Fg: 230, Bg: 0}, "label": {Fg: 230, Bg: 0}, "menubar": {Fg: 12, Bg: 123}, "scrollbar": {Fg: 12, Bg: 123, Texture: '░'}, "textbox": {Fg: 12, Bg: 50, Texture: '░'}, "list.item.selected": {Reverse: DecorationOn}, "table.cell.selected": {Reverse: DecorationOn}, "button.focused": {Reverse: DecorationOn}, }, }
DefaultTheme is a theme with reasonable defaults.
Functions ¶
func Close ¶
func Close()
Close finalizes termui library. It should be called after successful initialization when termui's functionality isn't required anymore.
func Init ¶
func Init() error
Init initializes termui library. This function should be called before any others. After initialization, the library must be finalized by 'Close' function.
func Loop ¶
func Loop()
Loop gets events from termbox and passes them off to handleEvent. Stops when StopLoop is called.
Types ¶
type Buffer ¶
Buffer is a renderable rectangle cell data container.
func NewFilledBuffer ¶
NewFilledBuffer returns a new Buffer filled with the given Cell.
func (*Buffer) MergeChildArea ¶
func (*Buffer) MergeWithOffset ¶
MergeWithOffset merges a Buffer onto another with an offset.
type Color ¶
type Color int
Color is an integer in the range -1 to 255. -1 is clear, while 0-255 are xterm 256 colors.
type Colorscheme ¶
type Colorscheme struct { Fg Color Bg Color LabelFg Color LabelBg Color BorderFg Color BorderBg Color Sparkline Color LineGraph Color TableCursor Color GaugeColor Color }
A Colorscheme represents the current look-and-feel of the dashboard.
type Decoration ¶
type Decoration int
Decoration represents a bold/underline/etc. state
const ( DecorationInherit Decoration = iota DecorationOn DecorationOff )
Decoration modes: Inherit from parent widget, explicitly on, or explicitly off.
type DragBeginEvent ¶
type DragContext ¶
type DragContext struct { Properties Properties DraggingIcon *Pencere IconOffsetX int IconOffsetY int }
func NewDragContext ¶
func NewDragContext(source *Pencere) *DragContext
type DragEndEvent ¶
type DragEnterEvent ¶
type DragEnterEvent struct { DragContext *DragContext Target *Pencere GlobalX, GlobalY int X, Y int Type int }
type DragLeaveEvent ¶
type DragLeaveEvent struct { DragContext *DragContext Target *Pencere GlobalX, GlobalY int X, Y int Type int }
type DragOverEvent ¶
type DragOverEvent struct { DragContext *DragContext Target *Pencere GlobalX, GlobalY int X, Y int Type int }
type DraggingEvent ¶
type DraggingEvent struct { DragContext *DragContext Target *Pencere GlobalX, GlobalY int X, Y int Type int }
type DropEvent ¶
type DropEvent struct { DragContext *DragContext Target *Pencere GlobalX, GlobalY int X, Y int Type int }
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
func NewEventBus ¶
func NewEventBus() *EventBus
type EventCallback ¶
type EventStream ¶
type EventStream struct {
// contains filtered or unexported fields
}
func (EventStream) HandleEvent ¶
func (this EventStream) HandleEvent(e tb.Event)
type Key ¶
type Key uint16
const ( KeyRune Key = iota + 256 KeyUp KeyDown KeyRight KeyLeft KeyUpLeft KeyUpRight KeyDownLeft KeyDownRight KeyCenter KeyPgUp KeyPgDn KeyHome KeyEnd KeyInsert KeyDelete KeyHelp KeyExit KeyClear KeyCancel KeyPrint KeyPause KeyBacktab KeyF1 KeyF2 KeyF3 KeyF4 KeyF5 KeyF6 KeyF7 KeyF8 KeyF9 KeyF10 KeyF11 KeyF12 KeyF13 KeyF14 KeyF15 KeyF16 KeyF17 KeyF18 KeyF19 KeyF20 KeyF21 KeyF22 KeyF23 KeyF24 KeyF25 KeyF26 KeyF27 KeyF28 KeyF29 KeyF30 KeyF31 KeyF32 KeyF33 KeyF34 KeyF35 KeyF36 KeyF37 KeyF38 KeyF39 KeyF40 KeyF41 KeyF42 KeyF43 KeyF44 KeyF45 KeyF46 KeyF47 KeyF48 KeyF49 KeyF50 KeyF51 KeyF52 KeyF53 KeyF54 KeyF55 KeyF56 KeyF57 KeyF58 KeyF59 KeyF60 KeyF61 KeyF62 KeyF63 KeyF64 )
These are named keys that can be handled.
const ( KeyCtrlSpace Key = iota KeyCtrlA KeyCtrlB KeyCtrlC KeyCtrlD KeyCtrlE KeyCtrlF KeyCtrlG KeyCtrlH KeyCtrlI KeyCtrlJ KeyCtrlK KeyCtrlL KeyCtrlM KeyCtrlN KeyCtrlO KeyCtrlP KeyCtrlQ KeyCtrlR KeyCtrlS KeyCtrlT KeyCtrlU KeyCtrlV KeyCtrlW KeyCtrlX KeyCtrlY KeyCtrlZ KeyCtrlLeftSq // Escape KeyCtrlBackslash KeyCtrlRightSq KeyCtrlCarat KeyCtrlUnderscore )
These are the supported control keys.
const ( KeyNUL Key = iota KeySOH KeySTX KeyETX KeyEOT KeyENQ KeyACK KeyBEL KeyBS KeyTAB KeyLF KeyVT KeyFF KeyCR KeySO KeySI KeyDLE KeyDC1 KeyDC2 KeyDC3 KeyDC4 KeyNAK KeySYN KeyETB KeyCAN KeyEM KeySUB KeyESC KeyFS KeyGS KeyRS KeyUS KeyDEL Key = 0x7F )
These are the defined ASCII values for key codes.
type MultiLineTextBox ¶
type MultiLineTextBox struct { *Pencere // contains filtered or unexported fields }
func NewMultiLineTextBox ¶
func NewMultiLineTextBox(options ...Option) (*MultiLineTextBox, error)
func (*MultiLineTextBox) OnKeyEvent ¶
func (this *MultiLineTextBox) OnKeyEvent(ev KeyEvent) error
func (*MultiLineTextBox) Render ¶
func (this *MultiLineTextBox) Render(buf *Buffer) error
type Pencere ¶
type Pencere struct { Label string LabelFg Color LabelBg Color Text string Inner image.Rectangle Fg Color Bg Color Texture rune Left, Top int Width, Height int CanFocus bool HasFocus bool HasBorder bool Scrollable bool ContentX int ContentY int BorderFg Color BorderBg Color Render func(buffer *Buffer) error Enabled bool Visible bool Layout func() error Id string Kind string Tag string OnMouseLeftClick func(event MouseEvent) error OnFocus func() error OnLostFocus func() error OnKeyEvent func(event KeyEvent) error Data interface{} Controller interface{} Draggable bool Droppable bool OnDragBegin func(event DragBeginEvent) (bool, *DragContext, error) OnDragging func(event DraggingEvent) error OnDragEnd func(event DragEndEvent) error OnDragEnter func(event DragEnterEvent) error OnDragLeave func(event DragLeaveEvent) error OnDragOver func(event DragOverEvent) error OnDrop func(event DropEvent) error CanDrop func(event DropEvent) (bool, error) Properties Properties Theme *Theme // contains filtered or unexported fields }
func NewMenuBar ¶
func NewPencere ¶
func NewStatusBar ¶
func (*Pencere) GetLayoutOrder ¶
func (*Pencere) GlobalPosition ¶
func (*Pencere) SetButtomBar ¶
func (*Pencere) SetLayoutOrder ¶
func (*Pencere) SetLeftBar ¶
func (*Pencere) SetRightBar ¶
func (*Pencere) TranslateToXY ¶
type PencereOrder ¶
type Properties ¶
type Properties map[string]interface{}
func NewProperties ¶
func NewProperties() Properties
func (Properties) GetValue ¶
func (this Properties) GetValue(name string) interface{}
func (Properties) SetColor ¶
func (this Properties) SetColor(name string, value Color)
func (Properties) SetInt ¶
func (this Properties) SetInt(name string, value int)
func (Properties) SetString ¶
func (this Properties) SetString(name string, value string)
func (Properties) SetValue ¶
func (this Properties) SetValue(name string, value interface{})
type RuneBuffer ¶
type RuneBuffer struct {
// contains filtered or unexported fields
}
RuneBuffer provides readline functionality for text widgets.
func (*RuneBuffer) Backspace ¶
func (r *RuneBuffer) Backspace()
Backspace deletes the rune left of the cursor.
func (*RuneBuffer) CursorPos ¶
func (r *RuneBuffer) CursorPos() image.Point
CursorPos returns the coordinate for the cursor for a given width.
func (*RuneBuffer) Delete ¶
func (r *RuneBuffer) Delete()
Delete deletes the rune at the current cursor position.
func (*RuneBuffer) Kill ¶
func (r *RuneBuffer) Kill()
Kill deletes all runes from the cursor until the end of the line.
func (*RuneBuffer) Len ¶
func (r *RuneBuffer) Len() int
Len returns the number of runes in the buffer.
func (*RuneBuffer) MoveBackward ¶
func (r *RuneBuffer) MoveBackward()
MoveBackward moves the cursor back by one rune.
func (*RuneBuffer) MoveForward ¶
func (r *RuneBuffer) MoveForward()
MoveForward moves the cursor forward by one rune.
func (*RuneBuffer) MoveToLineEnd ¶
func (r *RuneBuffer) MoveToLineEnd()
MoveToLineEnd moves the cursor to the end of the current line.
func (*RuneBuffer) MoveToLineStart ¶
func (r *RuneBuffer) MoveToLineStart()
MoveToLineStart moves the cursor to the start of the current line.
func (*RuneBuffer) Pos ¶
func (r *RuneBuffer) Pos() int
Pos returns the current index in the buffer.
func (*RuneBuffer) Set ¶
func (r *RuneBuffer) Set(buf []rune)
Set the buffer and the index at the end of the buffer.
func (*RuneBuffer) SetMaxWidth ¶
func (r *RuneBuffer) SetMaxWidth(w int)
SetMaxWidth sets the maximum text width.
func (*RuneBuffer) SetWithIdx ¶
func (r *RuneBuffer) SetWithIdx(idx int, buf []rune)
SetWithIdx set the the buffer with a given index.
func (*RuneBuffer) SplitByLine ¶
func (r *RuneBuffer) SplitByLine() []string
SplitByLine returns the lines for a given width.
func (*RuneBuffer) String ¶
func (r *RuneBuffer) String() string
func (*RuneBuffer) Width ¶
func (r *RuneBuffer) Width() int
Width returns the width of the rune buffer, taking into account for CJK.
func (*RuneBuffer) WriteRune ¶
func (r *RuneBuffer) WriteRune(s rune)
WriteRune appends a rune to the buffer.
func (*RuneBuffer) WriteRunes ¶
func (r *RuneBuffer) WriteRunes(s []rune)
WriteRunes appends runes to the buffer.
type Style ¶
type Style struct { Fg Color Bg Color Texture rune Brush rune Reverse Decoration Bold Decoration Underline Decoration }
type Table ¶
type Table struct { *Pencere Header []string Rows [][]string ColWidths []int CellXPos []int // column position ColResizer func() // for widgets that inherit a Table and want to overload the ColResize method Gap int // gap between columns PadLeft int Cursor bool CursorColor Color UniqueCol int // the column used to identify the selected item SelectedItem string // used to keep the cursor on the correct item if the data changes SelectedRow int TopRow int // used to indicate where in the table we are scrolled at }
Table tracks all the attributes of a Table instance
func (*Table) ColResize ¶
func (self *Table) ColResize()
ColResize is the default column resizer, but can be overriden. ColResize calculates the width of each column.
func (*Table) HalfPageDown ¶
func (self *Table) HalfPageDown()
func (*Table) HalfPageUp ¶
func (self *Table) HalfPageUp()
func (*Table) OnKeyEvent ¶
type Theme ¶
type Theme struct {
// contains filtered or unexported fields
}
type VerticalSplitter ¶
func NewVerticalSplitter ¶
func NewVerticalSplitter(options ...Option) (*VerticalSplitter, error)
func (*VerticalSplitter) Layout ¶
func (this *VerticalSplitter) Layout() error
func (*VerticalSplitter) OnDragBegin ¶
func (this *VerticalSplitter) OnDragBegin(event DragBeginEvent) (bool, *DragContext, error)
func (*VerticalSplitter) Render ¶
func (this *VerticalSplitter) Render(buf *Buffer) error
Source Files ¶
- block_common.go
- buffer.go
- color.go
- decorators.go
- drag.go
- events.go
- evetbus.go
- global.go
- init.go
- keyconstans.go
- layout_childs.go
- loop.go
- menu.go
- option.go
- pencere.go
- properties.go
- render.go
- renderer_column.go
- runebuffer.go
- table.go
- theme.go
- util.go
- w_VerticalSplitter.go
- w_box.go
- w_button.go
- w_menubar.go
- w_output.go
- w_root.go
- w_statusbar.go
- w_textbox.go
- widget.go