Documentation ¶
Overview ¶
Package components implements re-usable sections of UI which can be used by multiple sections of the program in multiple different ways.
They are designed to be as self-contained and as simple to use as possible, with immediate-mode UI used as a reference model.
As a general rule, it is safe to assume that none of this package is thread-safe, as it is only really designed for use by the UI thread. That being said, there is nothing stopping you from connecting some methods up to channel listeners or just locking the UI using a mutex either.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶ added in v1.1.1
A Column is a vertical section of a table, defined by a pair of both a "width" and a "label".
The width is the fraction of the table width the column should take up (defined between zero and one). Table's render method will panic if any column has a "width" of less than zero or greater than one, or if an impossible combination of widths was requested.
The width is the label which will be displayed at the top of the table The color is the ncurses color to activate when selected
type Menu ¶
type Menu struct {
W, H int
X, Y int
Items []string
Win goncurses.Window
Selected bool
// contains filtered or unexported fields
}
Menu represents a vertical panel menu of cellular entries taking up an entire row from X to W
Menu handles focus, scrolling and the managing of elements at each render.
This component is not thread safe and should only be modified directly one a single thread
func (*Menu) ChangeSelection ¶
ChangeSelection changes the selection to the index specified. If index is out of range, no action is taken.
func (*Menu) GetSelection ¶
GetSelection returns the text of the currently selected menu element. If there are no items selected, GetSelection returns an empty string.
func (*Menu) MoveSelection ¶
MoveSelection changes the selected item relative to the current position. If the new selection would be out of range, no action is taken.
type Table ¶ added in v1.1.1
type Table struct {
X, Y int
W, H int
Win *goncurses.Window
// See column struct for docs
Columns []Column
// Each sub-slice represents each column entry (eg, 0 = first column)
Items [][]string
// contains filtered or unexported fields
}
Table represents a vertical, headed table structure, useful for displaying a slice of structs
func (*Table) ChangeSelection ¶ added in v1.1.1
ChangeSelection changes the selection to the index specified. If index is out of range, no action is taken.
func (*Table) GetSelection ¶ added in v1.1.1
GetSelection returns the text of the currently selected menu element. If there are no items selected, GetSelection returns an empty slice.
func (*Table) MoveSelection ¶ added in v1.1.1
MoveSelection changes the selected item relative to the current position. If the new selection would be out of range, no action is taken.