Documentation ¶
Index ¶
- Constants
- Variables
- func Clear()
- func Close()
- func Error(issue, diagnostics string)
- func Init() error
- func MaxString(s string, l int) string
- func PollEvents() <-chan Event
- func Render(bs ...Bufferer)
- func Round(f float64) float64
- type Block
- 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) 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 Event
- type EventType
- type Gauge
- type Grid
- type GridBufferer
- type LineGraph
- type Mouse
- type Resize
- type Sparkline
- type Sparklines
- type Table
- func (self *Table) Bottom()
- func (self *Table) Buffer() *Buffer
- 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) PageDown()
- func (self *Table) PageUp()
- func (self *Table) Top()
- func (self *Table) Up()
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 = '»' )
const ColorDefault = -1
ColorDefault = clear
const DOTS = '…'
Variables ¶
var SPARKS = [8]rune{'▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'}
var Theme = Colorscheme{
Fg: 7,
Bg: -1,
LabelFg: 7,
LabelBg: -1,
BorderFg: 6,
BorderBg: -1,
Sparkline: 4,
LineGraph: 0,
TableCursor: 4,
GaugeColor: 7,
}
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 PollEvents ¶
func PollEvents() <-chan Event
PollEvents gets events from termbox, converts them, then sends them to each of its channels.
Types ¶
type Block ¶
type Block struct { Grid image.Rectangle X int // largest X value in the inner square Y int // largest Y value in the inner square XOffset int // the X position of the widget on the terminal YOffset int // the Y position of the widget on the terminal Label string BorderFg Color BorderBg Color LabelFg Color LabelBg Color Fg Color Bg Color }
Block is a base struct for all other upper level widgets.
func NewBlock ¶
func NewBlock() *Block
NewBlock returns a *Block which inherits styles from the current theme.
func (*Block) Buffer ¶
Buffer implements Bufferer interface and draws background, border, and borderlabel.
func (*Block) GetXOffset ¶
GetXOffset implements Bufferer interface.
func (*Block) GetYOffset ¶
GetYOffset implements Bufferer interface.
type Buffer ¶
Buffer is a renderable rectangle cell data container.
func NewFilledBuffer ¶
NewFilledBuffer returns a new Buffer filled with the given Cell.
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 Grid ¶
type Grid struct { Widgets []GridBufferer Width int Height int Cols int Rows int }
Grid holds widgets and information about terminal dimensions. Widgets are adjusted and rendered through the grid.
var Body *Grid
func (*Grid) Buffer ¶
Buffer implements the Bufferer interface by merging each widget in Grid into one buffer.
func (*Grid) GetXOffset ¶
GetXOffset implements Bufferer interface.
func (*Grid) GetYOffset ¶
GetYOffset implements Bufferer interface.
func (*Grid) Set ¶
func (self *Grid) Set(x0, y0, x1, y1 int, widget GridBufferer)
Set assigns a widget and its grid dimensions to Grid.
type GridBufferer ¶
GridBufferer introduces a Bufferer that can be manipulated by Grid.
type LineGraph ¶
type LineGraph struct { *Block Data map[string][]float64 LineColor map[string]Color Zoom int Labels map[string]string DefaultLineColor Color }
LineGraph implements a line graph of data points.
func NewLineGraph ¶
func NewLineGraph() *LineGraph
NewLineGraph returns a new LineGraph with current theme.
type Sparkline ¶
Sparkline is like: ▅▆▂▂▅▇▂▂▃▆▆▆▅▃. The data points should be non-negative integers.
func NewSparkline ¶
func NewSparkline() *Sparkline
NewSparkline returns an unrenderable single sparkline that intended to be added into a Sparklines.
type Sparklines ¶
Sparklines is a renderable widget which groups together the given sparklines.
func NewSparklines ¶
func NewSparklines(ss ...*Sparkline) *Sparklines
NewSparklines return a new *Sparklines with given Sparklines, you can always add a new Sparkline later.
func (*Sparklines) Add ¶
func (self *Sparklines) Add(sl Sparkline)
Add appends a given Sparkline to the *Sparklines.
func (*Sparklines) Buffer ¶
func (self *Sparklines) Buffer() *Buffer
Buffer implements Bufferer interface.
type Table ¶
type Table struct { *Block 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()