Documentation
¶
Overview ¶
Package cui implements rich widgets for terminal based user interfaces.
See the demos folder and the example application provided with the NewApp documentation for usage examples.
Types ¶
This package is built on top of tcell, which provides the types necessary to create a terminal-based application (e.g. EventKey). For information on inherited types see the tcell documentation.
tcell: https://github.com/gdamore/tcell
Base Widget ¶
Widgets must implement the Widget interface. All widgets embed the base widget, Box, and thus inherit its functions. This isn't necessarily required, but it makes more sense than reimplementing Box's functionality in each widget.
Widgets ¶
The following widgets are available:
Button - Button which is activated when the user selects it. CheckBox - Selectable checkbox for boolean values. DropDown - Drop-down selection field. Flex - A Flexbox based layout manager. Form - Form composed of input fields, drop down selections, checkboxes, and buttons. Grid - A grid based layout manager. InputField - Single-line text entry field. List - A navigable text list with optional keyboard shortcuts. Modal - A centered window with a text message and one or more buttons. Panels - A panel based layout manager. ProgressBar - Indicates the progress of an operation. TabbedPanels - Panels widget with tabbed navigation. Table - A scrollable display of tabular data. Table cells, rows, or columns may also be highlighted. TextView - A scrollable window that displays multi-colored text. Text may also be highlighted. TreeView - A scrollable display for hierarchical data. Tree nodes can be highlighted, collapsed, expanded, and more. Window - A draggable and resizable container.
Widgets may be used without an application created via NewApp, allowing them to be integrated into any tcell-based application.
Concurrency ¶
All functions may be called concurrently (they are thread-safe). When called from multiple threads, functions will block until the application or widget becomes available. Function calls may be queued with App.QueueUpdate to avoid blocking.
Unicode Support ¶
This package supports unicode characters including wide characters.
Keyboard Shortcuts ¶
Widgets use keyboard shortcuts (a.k.a. keybindings) such as arrow keys and H/J/K/L by default. You may replace these defaults by modifying the shortcuts listed in Keys. You may also override keyboard shortcuts globally by setting a handler with Application.SetInputCapture.
cbind is a library which simplifies the process of adding support for custom keyboard shortcuts to your application. It allows setting handlers for EventKeys. It also translates between EventKeys and human-readable strings such as "Alt+Enter". This makes it possible to store keybindings in a configuration file.
cbind: https://github.com/malivvan/rumo/std/cui/bind
Bracketed Paste Mode ¶
Bracketed paste mode is enabled by default. It may be disabled by calling Application.EnableBracketedPaste before Application.Run. The following demo shows how to handle paste events and process pasted text.
tcell bracketed paste demo: https://github.com/gdamore/tcell/blob/master/_demos/mouse.go
Mouse Support ¶
Mouse support may be enabled by calling Application.EnableMouse before Application.Run. See the example application provided with the App.EnableMouse documentation.
Double clicks are treated single clicks by default. Specify a maximum duration between clicks with App.SetDoubleClickInterval to enable double clicks. A standard duration is provided as StandardDoubleClick.
Mouse events are passed to:
- The handler set with SetMouseCapture, which is reserved for use by application developers to permanently intercept mouse events. Return nil to stop propagation.
- The MouseHandler method of the topmost widget under the mouse.
Colors ¶
Throughout this package, colors are specified using the tcell.Color type. Functions such as tcell.GetColor(), tcell.NewHexColor(), and tcell.NewRGBColor() can be used to create colors from W3C color names or RGB values.
Almost all strings which are displayed can contain color tags. Color tags are W3C color names or six hexadecimal digits following a hash tag, wrapped in square brackets. Examples:
This is a [red]warning[white]! The sky is [#8080ff]blue[#ffffff].
A color tag changes the color of the characters following that color tag. This applies to almost everything from box titles, list text, form item labels, to table cells. In a TextView, this functionality must be explicitly enabled. See the TextView documentation for more information.
Color tags may contain not just the foreground (text) color but also the background color and additional flags. In fact, the full definition of a color tag is as follows:
[<foreground>:<background>:<flags>]
Each of the three fields can be left blank and trailing fields can be omitted. (Empty square brackets "[]", however, are not considered color tags.) Colors that are not specified will be left unchanged. A field with just a dash ("-") means "reset to default".
You can specify the following flags (some flags may not be supported by your terminal):
l: blink b: bold d: dim i: italic r: reverse (switch foreground and background color) u: underline s: strikethrough
Examples:
[yellow]Yellow text [yellow:red]Yellow text on red background [:red]Red background, text color unchanged [yellow::u]Yellow text underlined [::bl]Bold, blinking text [::-]Colors unchanged, flags reset [-]Reset foreground color [-:-:-]Reset everything [:]No effect []Not a valid color tag, will print square brackets as they are
In the rare event that you want to display a string such as "[red]" or "[#00ff1a]" without applying its effect, you need to put an opening square bracket before the closing square bracket. Note that the text inside the brackets will be matched less strictly than region or colors tags. I.e. any character that may be used in color or region tags will be recognized. Examples:
[red[] will be output as [red] ["123"[] will be output as ["123"] [#6aff00[[] will be output as [#6aff00[] [a#"[[[] will be output as [a#"[[] [] will be output as [] (see color tags above) [[] will be output as [[] (not an escaped tag)
You can use the Escape() function to insert brackets automatically where needed.
Setting the background color of a widget to tcell.ColorDefault will use the default terminal background color. To enable transparency (allowing one or more widgets to display behind a widget) call SetBackgroundTransparent. The screen is not cleared before drawing the application. Overlaying transparent widgets directly onto the screen may result in artifacts. To resolve this, add a blank, non-transparent Box to the bottom layer of the interface via Panels, or set a handler via SetBeforeDrawFunc which clears the screen.
Styles ¶
When widgets are instantiated, they are initialized with colors taken from the global Styles variable. You may change this variable to adapt the look and feel of the widgets to your preferred style.
Scroll Bars ¶
Scroll bars are supported by the following widgets: List, Table, TextView and TreeView. Each widget will display scroll bars automatically when there are additional items offscreen. See SetScrollBarColor and SetScrollBarVisibility.
Hello World ¶
The following is an example application which shows a box titled "Greetings" containing the text "Hello, world!":
package main
import (
"github.com/malivvan/rumo/std/cui"
)
func main() {
tv := cui.NewTextView()
tv.SetText("Hello, world!").
SetBorder(true).
SetTitle("Greetings")
if err := cui.NewApp().SetRoot(tv, true).Run(); err != nil {
panic(err)
}
}
First, we create a TextView with a border and a title. Then we create an application, set the TextView as its root widget, and run the event loop. The application exits when the application's Stop() function is called or when Ctrl-C is pressed.
If we have a widget which consumes key presses, we call the application's SetFocus() function to redirect all key presses to that widget. Most widgets then offer ways to install handlers that allow you to react to any actions performed on them.
Demos ¶
The "demos" subdirectory contains a demo for each widget, as well as a presentation which gives an overview of the widgets and how they may be used.
Index ¶
- Constants
- Variables
- func ANSIWriter(writer io.Writer) io.Writer
- func Animate(app *App)
- func ColorHex(c tcell.Color) string
- func DecodeBind(s string) (mod tcell.ModMask, key tcell.Key, str string, err error)
- func DefaultColorizer(c byte) tcell.Color
- func EncodeBind(mod tcell.ModMask, key tcell.Key, str string) (string, error)
- func Escape(text string) string
- func EscapeBytes(text []byte) []byte
- func HitShortcut(event *tcell.EventKey, keybindings ...[]string) bool
- func Print(screen tcell.Screen, text []byte, x, y, maxWidth, align int, color tcell.Color) (int, int)
- func PrintJoinedSemigraphics(screen tcell.Screen, x, y int, ch rune, color tcell.Color)
- func PrintSimple(screen tcell.Screen, text []byte, x, y int)
- func PrintStyle(screen tcell.Screen, text []byte, x, y, maxWidth, align int, style tcell.Style) (int, int)
- func RenderScrollBar(screen tcell.Screen, visibility ScrollBarVisibility, x int, y int, height int, ...)
- func SetAttributes(style tcell.Style, attrs tcell.AttrMask) tcell.Style
- func StripTags(text []byte, colors bool, regions bool) []byte
- func TaggedStringWidth(text string) int
- func TaggedTextWidth(text []byte) int
- func TranslateANSI(text string) string
- func WordWrap(text string, width int) (lines []string)
- type App
- func (a *App) Draw(p ...Widget)
- func (a *App) EnableBracketedPaste(enable bool)
- func (a *App) EnableMouse(enable bool)
- func (a *App) GetAfterDrawFunc() func(screen tcell.Screen)
- func (a *App) GetAfterResizeFunc() func(width int, height int)
- func (a *App) GetBeforeDrawFunc() func(screen tcell.Screen) bool
- func (a *App) GetFocus() Widget
- func (a *App) GetInputCapture() func(event *tcell.EventKey) *tcell.EventKey
- func (a *App) GetMouseCapture() ...
- func (a *App) GetScreen() tcell.Screen
- func (a *App) GetScreenSize() (width, height int)
- func (a *App) HandlePanic()
- func (a *App) Init() error
- func (a *App) QueueEvent(event tcell.Event)
- func (a *App) QueueUpdate(f func())
- func (a *App) QueueUpdateDraw(f func(), p ...Widget)
- func (a *App) ResizeToFullScreen(w Widget)
- func (a *App) RingBell()
- func (a *App) Run() error
- func (a *App) SetAfterDrawFunc(handler func(screen tcell.Screen))
- func (a *App) SetAfterFocusFunc(handler func(w Widget))
- func (a *App) SetAfterResizeFunc(handler func(width int, height int))
- func (a *App) SetBeforeDrawFunc(handler func(screen tcell.Screen) bool)
- func (a *App) SetBeforeFocusFunc(handler func(w Widget) bool)
- func (a *App) SetDoubleClickInterval(interval time.Duration) *App
- func (a *App) SetFocus(w Widget)
- func (a *App) SetInputCapture(capture func(event *tcell.EventKey) *tcell.EventKey) *App
- func (a *App) SetMouseCapture(...) *App
- func (a *App) SetRoot(root Widget, fullscreen bool)
- func (a *App) SetScreen(screen tcell.Screen)
- func (a *App) Stop()
- func (a *App) Suspend(f func()) bool
- type BarChart
- func (c *BarChart) AddBar(label string, value int, color tcell.Color)
- func (c *BarChart) Draw(screen tcell.Screen)
- func (c *BarChart) Focus(delegate func(w Widget))
- func (c *BarChart) GetRect() (int, int, int, int)
- func (c *BarChart) HasFocus() bool
- func (c *BarChart) RemoveBar(label string)
- func (c *BarChart) SetAxesColor(color tcell.Color) *BarChart
- func (c *BarChart) SetAxesLabelColor(color tcell.Color) *BarChart
- func (c *BarChart) SetBarValue(name string, value int) *BarChart
- func (c *BarChart) SetBorder(status bool) *BarChart
- func (c *BarChart) SetMaxValue(maxValue int) *BarChart
- func (c *BarChart) SetRect(x, y, width, height int) Widget
- type BarChartItem
- type BindConfig
- func (c *BindConfig) Capture(ev *tcell.EventKey) *tcell.EventKey
- func (c *BindConfig) Clear()
- func (c *BindConfig) Set(s string, handler func(ev *tcell.EventKey) *tcell.EventKey) error
- func (c *BindConfig) SetKey(mod tcell.ModMask, key tcell.Key, ...)
- func (c *BindConfig) SetRune(mod tcell.ModMask, ch rune, handler func(ev *tcell.EventKey) *tcell.EventKey)
- type Box
- func (b *Box) Blur()
- func (b *Box) Draw(screen tcell.Screen)
- func (b *Box) Focus(delegate func(w Widget))
- func (b *Box) GetBackgroundColor() tcell.Color
- func (b *Box) GetBorder() bool
- func (b *Box) GetBorderPadding() (top, bottom, left, right int)deprecated
- func (b *Box) GetDrawFunc() func(screen tcell.Screen, x, y, width, height int) (int, int, int, int)
- func (b *Box) GetFocusable() Focusable
- func (b *Box) GetInnerRect() (int, int, int, int)
- func (b *Box) GetInputCapture() func(event *tcell.EventKey) *tcell.EventKey
- func (b *Box) GetMouseCapture() ...
- func (b *Box) GetPadding() (top, bottom, left, right int)
- func (b *Box) GetRect() (int, int, int, int)
- func (b *Box) GetTitle() string
- func (b *Box) GetVisible() bool
- func (b *Box) HasFocus() bool
- func (b *Box) InRect(x, y int) bool
- func (b *Box) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (b *Box) MouseHandler() ...
- func (b *Box) SetBackgroundColor(color tcell.Color) *Box
- func (b *Box) SetBackgroundTransparent(transparent bool) *Box
- func (b *Box) SetBorder(show bool) *Box
- func (b *Box) SetBorderAttributes(attr tcell.AttrMask) *Box
- func (b *Box) SetBorderColor(color tcell.Color) *Box
- func (b *Box) SetBorderColorFocused(color tcell.Color) *Box
- func (b *Box) SetBorderPadding(top, bottom, left, right int) *Boxdeprecated
- func (b *Box) SetDrawFunc(...) *Box
- func (b *Box) SetInputCapture(capture func(event *tcell.EventKey) *tcell.EventKey) *Box
- func (b *Box) SetMouseCapture(...) *Box
- func (b *Box) SetPadding(top, bottom, left, right int) *Box
- func (b *Box) SetRect(x, y, width, height int) Widget
- func (b *Box) SetTitle(title string) *Box
- func (b *Box) SetTitleAlign(align int) *Box
- func (b *Box) SetTitleColor(color tcell.Color) *Box
- func (b *Box) SetVisible(v bool) Widget
- func (b *Box) ShowFocus(showFocus bool) *Box
- func (b *Box) WrapInputHandler(inputHandler func(*tcell.EventKey, func(w Widget))) func(*tcell.EventKey, func(w Widget))
- func (b *Box) WrapMouseHandler(...) ...
- type Button
- func (b *Button) Draw(screen tcell.Screen)
- func (b *Button) GetLabel() string
- func (b *Button) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (b *Button) MouseHandler() ...
- func (b *Button) SetBackgroundColorFocused(color tcell.Color) *Button
- func (b *Button) SetBlurFunc(handler func(key tcell.Key)) *Button
- func (b *Button) SetCursorRune(rune rune) *Button
- func (b *Button) SetLabel(label string) *Button
- func (b *Button) SetLabelColor(color tcell.Color) *Button
- func (b *Button) SetLabelColorFocused(color tcell.Color) *Button
- func (b *Button) SetSelectedFunc(handler func()) *Button
- type CheckBox
- func (c *CheckBox) Draw(screen tcell.Screen)
- func (c *CheckBox) GetFieldHeight() int
- func (c *CheckBox) GetFieldWidth() int
- func (c *CheckBox) GetLabel() string
- func (c *CheckBox) GetMessage() string
- func (c *CheckBox) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (c *CheckBox) IsChecked() bool
- func (c *CheckBox) MouseHandler() ...
- func (c *CheckBox) SetBackgroundColor(color tcell.Color) FormItem
- func (c *CheckBox) SetChangedFunc(handler func(checked bool)) *CheckBox
- func (c *CheckBox) SetChecked(checked bool) *CheckBox
- func (c *CheckBox) SetCheckedRune(rune rune) *CheckBox
- func (c *CheckBox) SetCursorRune(rune rune) *CheckBox
- func (c *CheckBox) SetDoneFunc(handler func(key tcell.Key)) *CheckBox
- func (c *CheckBox) SetFieldBackgroundColor(color tcell.Color) FormItem
- func (c *CheckBox) SetFieldBackgroundColorFocused(color tcell.Color) FormItem
- func (c *CheckBox) SetFieldTextColor(color tcell.Color) FormItem
- func (c *CheckBox) SetFieldTextColorFocused(color tcell.Color) FormItem
- func (c *CheckBox) SetFinishedFunc(handler func(key tcell.Key)) FormItem
- func (c *CheckBox) SetLabel(label string) *CheckBox
- func (c *CheckBox) SetLabelColor(color tcell.Color) FormItem
- func (c *CheckBox) SetLabelColorFocused(color tcell.Color) FormItem
- func (c *CheckBox) SetLabelWidth(width int) FormItem
- func (c *CheckBox) SetMessage(message string) *CheckBox
- type ContextMenu
- func (c *ContextMenu) AddContextItem(text string, shortcut rune, selected func(index int))
- func (c *ContextMenu) ClearContextMenu()
- func (c *ContextMenu) ContextMenuList() *List
- func (c *ContextMenu) ContextMenuVisible() bool
- func (c *ContextMenu) HideContextMenu(setFocus func(Widget))
- func (c *ContextMenu) SetContextSelectedFunc(handler func(index int, text string, shortcut rune)) *ContextMenu
- func (c *ContextMenu) ShowContextMenu(item int, x int, y int, setFocus func(Widget))
- type DropDown
- func (d *DropDown) AddOptions(options ...*DropDownOption)
- func (d *DropDown) AddOptionsSimple(options ...string)
- func (d *DropDown) Draw(screen tcell.Screen)
- func (d *DropDown) Focus(delegate func(w Widget))
- func (d *DropDown) GetCurrentOption() (int, *DropDownOption)
- func (d *DropDown) GetFieldHeight() int
- func (d *DropDown) GetFieldWidth() int
- func (d *DropDown) GetLabel() string
- func (d *DropDown) HasFocus() bool
- func (d *DropDown) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (d *DropDown) MouseHandler() ...
- func (d *DropDown) SetAlwaysDrawDropDownSymbol(alwaysDraw bool) *DropDown
- func (d *DropDown) SetBackgroundColor(color tcell.Color) FormItem
- func (d *DropDown) SetChangedFunc(handler func(index int, option *DropDownOption)) *DropDown
- func (d *DropDown) SetCurrentOption(index int) *DropDown
- func (d *DropDown) SetDoneFunc(handler func(key tcell.Key)) *DropDown
- func (d *DropDown) SetDropDownBackgroundColor(color tcell.Color) *DropDown
- func (d *DropDown) SetDropDownOpenSymbolRune(symbol rune) *DropDown
- func (d *DropDown) SetDropDownSelectedBackgroundColor(color tcell.Color) *DropDown
- func (d *DropDown) SetDropDownSelectedSymbolRune(symbol rune) *DropDown
- func (d *DropDown) SetDropDownSelectedTextColor(color tcell.Color) *DropDown
- func (d *DropDown) SetDropDownSymbolRune(symbol rune) *DropDown
- func (d *DropDown) SetDropDownTextColor(color tcell.Color) *DropDown
- func (d *DropDown) SetFieldBackgroundColor(color tcell.Color) FormItem
- func (d *DropDown) SetFieldBackgroundColorFocused(color tcell.Color) FormItem
- func (d *DropDown) SetFieldTextColor(color tcell.Color) FormItem
- func (d *DropDown) SetFieldTextColorFocused(color tcell.Color) FormItem
- func (d *DropDown) SetFieldWidth(width int) *DropDown
- func (d *DropDown) SetFinishedFunc(handler func(key tcell.Key)) FormItem
- func (d *DropDown) SetLabel(label string) *DropDown
- func (d *DropDown) SetLabelColor(color tcell.Color) FormItem
- func (d *DropDown) SetLabelColorFocused(color tcell.Color) FormItem
- func (d *DropDown) SetLabelWidth(width int) FormItem
- func (d *DropDown) SetOptions(selected func(index int, option *DropDownOption), options ...*DropDownOption) *DropDown
- func (d *DropDown) SetOptionsSimple(selected func(index int, option *DropDownOption), options ...string) *DropDown
- func (d *DropDown) SetPrefixTextColor(color tcell.Color) *DropDown
- func (d *DropDown) SetSelectedFunc(handler func(index int, option *DropDownOption)) *DropDown
- func (d *DropDown) SetTextOptions(prefix, suffix, currentPrefix, currentSuffix, noSelection string) *DropDown
- type DropDownOption
- func (d *DropDownOption) GetReference() interface{}
- func (d *DropDownOption) GetText() string
- func (d *DropDownOption) SetReference(reference interface{}) *DropDownOption
- func (d *DropDownOption) SetSelectedFunc(handler func(index int, option *DropDownOption)) *DropDownOption
- func (d *DropDownOption) SetText(text string) *DropDownOption
- type Flex
- func (f *Flex) AddItem(item Widget, fixedSize, proportion int, focus bool)
- func (f *Flex) AddItemAtIndex(index int, item Widget, fixedSize, proportion int, focus bool)
- func (f *Flex) Clear()
- func (f *Flex) Draw(screen tcell.Screen)
- func (f *Flex) Focus(delegate func(w Widget))
- func (f *Flex) GetDirection() int
- func (f *Flex) HasFocus() bool
- func (f *Flex) MouseHandler() ...
- func (f *Flex) RemoveItem(w Widget)
- func (f *Flex) ResizeItem(w Widget, fixedSize, proportion int)
- func (f *Flex) SetDirection(direction int) *Flex
- func (f *Flex) SetFullScreen(fullScreen bool) *Flex
- type FocusManager
- func (f *FocusManager) Add(w ...Widget)
- func (f *FocusManager) AddAt(index int, w Widget)
- func (f *FocusManager) Focus(w Widget)
- func (f *FocusManager) FocusAt(index int)
- func (f *FocusManager) FocusNext()
- func (f *FocusManager) FocusPrevious()
- func (f *FocusManager) GetFocusIndex() int
- func (f *FocusManager) GetFocusedWidget() Widget
- func (f *FocusManager) SetWrapAround(wrapAround bool)
- func (f *FocusManager) Transform(tr Transformation)
- type Focusable
- type Form
- func (f *Form) AddButton(label string, selected func())
- func (f *Form) AddCheckBox(label string, message string, checked bool, changed func(checked bool))
- func (f *Form) AddDropDown(label string, initialOption int, ...)
- func (f *Form) AddDropDownSimple(label string, initialOption int, ...)
- func (f *Form) AddFormItem(item FormItem)
- func (f *Form) AddInputField(label, value string, fieldWidth int, ...)
- func (f *Form) AddPasswordField(label, value string, fieldWidth int, mask rune, changed func(text string))
- func (f *Form) AddSlider(label string, current, max, increment int, changed func(value int))
- func (f *Form) Clear(includeButtons bool)
- func (f *Form) ClearButtons()
- func (f *Form) Draw(screen tcell.Screen)
- func (f *Form) Focus(delegate func(w Widget))
- func (f *Form) GetAttributes() *FormItemAttributes
- func (f *Form) GetButton(index int) *Button
- func (f *Form) GetButtonCount() int
- func (f *Form) GetButtonIndex(label string) int
- func (f *Form) GetFocusedItemIndex() (formItem, button int)
- func (f *Form) GetFormItem(index int) FormItem
- func (f *Form) GetFormItemByLabel(label string) FormItem
- func (f *Form) GetFormItemCount() int
- func (f *Form) GetFormItemIndex(label string) int
- func (f *Form) HasFocus() bool
- func (f *Form) IndexOfFormItem(item FormItem) int
- func (f *Form) MouseHandler() ...
- func (f *Form) RemoveButton(index int)
- func (f *Form) RemoveFormItem(index int)
- func (f *Form) SetButtonBackgroundColor(color tcell.Color) *Form
- func (f *Form) SetButtonBackgroundColorFocused(color tcell.Color) *Form
- func (f *Form) SetButtonTextColor(color tcell.Color) *Form
- func (f *Form) SetButtonTextColorFocused(color tcell.Color) *Form
- func (f *Form) SetButtonsAlign(align int) *Form
- func (f *Form) SetCancelFunc(callback func()) *Form
- func (f *Form) SetFieldBackgroundColor(color tcell.Color) *Form
- func (f *Form) SetFieldBackgroundColorFocused(color tcell.Color) *Form
- func (f *Form) SetFieldTextColor(color tcell.Color) *Form
- func (f *Form) SetFieldTextColorFocused(color tcell.Color) *Form
- func (f *Form) SetFocus(index int) *Form
- func (f *Form) SetHorizontal(horizontal bool) *Form
- func (f *Form) SetItemPadding(padding int) *Form
- func (f *Form) SetLabelColor(color tcell.Color) *Form
- func (f *Form) SetLabelColorFocused(color tcell.Color) *Form
- func (f *Form) SetWrapAround(wrapAround bool) *Form
- type FormItem
- type FormItemAttributes
- type Frame
- func (f *Frame) AddText(text string, header bool, align int, color tcell.Color)
- func (f *Frame) Clear()
- func (f *Frame) Draw(screen tcell.Screen)
- func (f *Frame) Focus(delegate func(w Widget))
- func (f *Frame) HasFocus() bool
- func (f *Frame) MouseHandler() ...
- func (f *Frame) SetBorders(top, bottom, header, footer, left, right int) *Frame
- type Grid
- func (g *Grid) AddItem(w Widget, row, column, rowSpan, colSpan, minGridHeight, minGridWidth int, ...)
- func (g *Grid) Blur()
- func (g *Grid) Clear()
- func (g *Grid) Draw(screen tcell.Screen)
- func (g *Grid) Focus(delegate func(w Widget))
- func (g *Grid) GetOffset() (rows, columns int)
- func (g *Grid) HasFocus() bool
- func (g *Grid) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (g *Grid) MouseHandler() ...
- func (g *Grid) RemoveItem(w Widget)
- func (g *Grid) SetBorders(borders bool) *Grid
- func (g *Grid) SetBordersColor(color tcell.Color) *Grid
- func (g *Grid) SetColumns(columns ...int) *Grid
- func (g *Grid) SetGap(row, column int) *Grid
- func (g *Grid) SetMinSize(row, column int) *Grid
- func (g *Grid) SetOffset(rows, columns int) *Grid
- func (g *Grid) SetRows(rows ...int) *Grid
- func (g *Grid) SetSize(numRows, numColumns, rowSize, columnSize int) *Grid
- type HexView
- type Image
- type InputField
- func (i *InputField) Autocomplete()
- func (i *InputField) Draw(screen tcell.Screen)
- func (i *InputField) GetCursorPosition() int
- func (i *InputField) GetFieldHeight() int
- func (i *InputField) GetFieldWidth() int
- func (i *InputField) GetLabel() string
- func (i *InputField) GetText() string
- func (i *InputField) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (i *InputField) MouseHandler() ...
- func (i *InputField) ResetFieldNote() *InputField
- func (i *InputField) SetAcceptanceFunc(handler func(textToCheck string, lastChar rune) bool) *InputField
- func (i *InputField) SetAutocompleteFunc(callback func(currentText string) (entries []*ListItem)) *InputField
- func (i *InputField) SetAutocompleteListBackgroundColor(color tcell.Color) *InputField
- func (i *InputField) SetAutocompleteListSelectedBackgroundColor(color tcell.Color) *InputField
- func (i *InputField) SetAutocompleteListSelectedTextColor(color tcell.Color) *InputField
- func (i *InputField) SetAutocompleteListTextColor(color tcell.Color) *InputField
- func (i *InputField) SetAutocompleteSuggestionTextColor(color tcell.Color) *InputField
- func (i *InputField) SetBackgroundColor(color tcell.Color) FormItem
- func (i *InputField) SetChangedFunc(handler func(text string)) *InputField
- func (i *InputField) SetCursorPosition(cursorPos int) *InputField
- func (i *InputField) SetDoneFunc(handler func(key tcell.Key)) *InputField
- func (i *InputField) SetFieldBackgroundColor(color tcell.Color) FormItem
- func (i *InputField) SetFieldBackgroundColorFocused(color tcell.Color) FormItem
- func (i *InputField) SetFieldNote(note string) *InputField
- func (i *InputField) SetFieldNoteTextColor(color tcell.Color) *InputField
- func (i *InputField) SetFieldTextColor(color tcell.Color) FormItem
- func (i *InputField) SetFieldTextColorFocused(color tcell.Color) FormItem
- func (i *InputField) SetFieldWidth(width int) *InputField
- func (i *InputField) SetFinishedFunc(handler func(key tcell.Key)) FormItem
- func (i *InputField) SetLabel(label string) *InputField
- func (i *InputField) SetLabelColor(color tcell.Color) FormItem
- func (i *InputField) SetLabelColorFocused(color tcell.Color) FormItem
- func (i *InputField) SetLabelWidth(width int) FormItem
- func (i *InputField) SetMaskCharacter(mask rune) *InputField
- func (i *InputField) SetPlaceholder(text string) *InputField
- func (i *InputField) SetPlaceholderTextColor(color tcell.Color) *InputField
- func (i *InputField) SetPlaceholderTextColorFocused(color tcell.Color) *InputField
- func (i *InputField) SetText(text string) *InputField
- type Key
- type List
- func (l *List) AddItem(item *ListItem)
- func (l *List) Clear()
- func (l *List) Draw(screen tcell.Screen)
- func (l *List) FindItems(mainSearch, secondarySearch string, mustContainBoth, ignoreCase bool) (indices []int)
- func (l *List) Focus(delegate func(w Widget))
- func (l *List) GetCurrentItem() *ListItem
- func (l *List) GetCurrentItemIndex() int
- func (l *List) GetItem(index int) *ListItem
- func (l *List) GetItemCount() int
- func (l *List) GetItemText(index int) (main, secondary string)
- func (l *List) GetItems() []*ListItem
- func (l *List) GetOffset() (int, int)
- func (l *List) HasFocus() bool
- func (l *List) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (l *List) InsertItem(index int, item *ListItem)
- func (l *List) MouseHandler() ...
- func (l *List) RemoveItem(index int)
- func (l *List) SetChangedFunc(handler func(index int, item *ListItem)) *List
- func (l *List) SetCurrentItem(index int) *List
- func (l *List) SetDoneFunc(handler func()) *List
- func (l *List) SetHighlightFullLine(highlight bool) *List
- func (l *List) SetHover(hover bool) *List
- func (l *List) SetIndicators(selectedPrefix, selectedSuffix, unselectedPrefix, unselectedSuffix string) *List
- func (l *List) SetItemEnabled(index int, enabled bool) *List
- func (l *List) SetItemText(index int, main, secondary string) *List
- func (l *List) SetMainTextColor(color tcell.Color) *List
- func (l *List) SetOffset(items, columns int) *List
- func (l *List) SetScrollBarColor(color tcell.Color) *List
- func (l *List) SetScrollBarVisibility(visibility ScrollBarVisibility) *List
- func (l *List) SetSecondaryTextColor(color tcell.Color) *List
- func (l *List) SetSelectedAlwaysCentered(alwaysCentered bool) *List
- func (l *List) SetSelectedAlwaysVisible(alwaysVisible bool) *List
- func (l *List) SetSelectedBackgroundColor(color tcell.Color) *List
- func (l *List) SetSelectedFocusOnly(focusOnly bool) *List
- func (l *List) SetSelectedFunc(handler func(int, *ListItem)) *List
- func (l *List) SetSelectedTextAttributes(attr tcell.AttrMask) *List
- func (l *List) SetSelectedTextColor(color tcell.Color) *List
- func (l *List) SetShortcutColor(color tcell.Color) *List
- func (l *List) SetWrapAround(wrapAround bool) *List
- func (l *List) ShowSecondaryText(show bool) *List
- func (l *List) Transform(tr Transformation)
- type ListItem
- func (l *ListItem) GetMainBytes() []byte
- func (l *ListItem) GetMainText() string
- func (l *ListItem) GetReference() interface{}
- func (l *ListItem) GetSecondaryBytes() []byte
- func (l *ListItem) GetSecondaryText() string
- func (l *ListItem) GetShortcut() rune
- func (l *ListItem) SetMainBytes(val []byte) *ListItem
- func (l *ListItem) SetMainText(val string) *ListItem
- func (l *ListItem) SetReference(val interface{}) *ListItem
- func (l *ListItem) SetSecondaryBytes(val []byte) *ListItem
- func (l *ListItem) SetSecondaryText(val string) *ListItem
- func (l *ListItem) SetSelectedFunc(handler func()) *ListItem
- func (l *ListItem) SetShortcut(val rune) *ListItem
- type Marker
- type MenuBar
- func (menuBar *MenuBar) AddItem(item *MenuItem) *MenuBar
- func (menuBar *MenuBar) AfterDraw() func(tcell.Screen)
- func (menuBar *MenuBar) Draw(screen tcell.Screen)
- func (menuBar *MenuBar) Focus(delegate func(w Widget))
- func (menuBar *MenuBar) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (menuBar *MenuBar) MouseHandler() ...
- type MenuItem
- type MessageDialog
- func (d *MessageDialog) Draw(screen tcell.Screen)
- func (d *MessageDialog) Focus(delegate func(w Widget))
- func (d *MessageDialog) GetBackgroundColor() tcell.Color
- func (d *MessageDialog) HasFocus() bool
- func (d *MessageDialog) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (d *MessageDialog) MouseHandler() ...
- func (d *MessageDialog) SetBackgroundColor(color tcell.Color) *MessageDialog
- func (d *MessageDialog) SetDoneFunc(handler func()) *MessageDialog
- func (d *MessageDialog) SetMessage(message string) *MessageDialog
- func (d *MessageDialog) SetRect(x, y, width, height int) Widget
- func (d *MessageDialog) SetTextColor(color tcell.Color) *MessageDialog
- func (d *MessageDialog) SetTitle(title string) *MessageDialog
- func (d *MessageDialog) SetType(dtype int) *MessageDialog
- type Modal
- func (m *Modal) AddButtons(labels []string)
- func (m *Modal) ClearButtons()
- func (m *Modal) Draw(screen tcell.Screen)
- func (m *Modal) Focus(delegate func(w Widget))
- func (m *Modal) GetForm() *Form
- func (m *Modal) GetFrame() *Frame
- func (m *Modal) HasFocus() bool
- func (m *Modal) MouseHandler() ...
- func (m *Modal) SetBackgroundColor(color tcell.Color) *Modal
- func (m *Modal) SetButtonBackgroundColor(color tcell.Color) *Modal
- func (m *Modal) SetButtonTextColor(color tcell.Color) *Modal
- func (m *Modal) SetButtonsAlign(align int) *Modal
- func (m *Modal) SetDoneFunc(handler func(buttonIndex int, buttonLabel string)) *Modal
- func (m *Modal) SetFocus(index int) *Modal
- func (m *Modal) SetText(text string) *Modal
- func (m *Modal) SetTextAlign(align int) *Modal
- func (m *Modal) SetTextColor(color tcell.Color) *Modal
- type MouseAction
- type Pagesdeprecated
- func NewPages() *Pagesdeprecated
- func (p *Pages) AddAndSwitchToPage(name string, item Widget, resize bool)
- func (p *Pages) AddPage(name string, item Widget, resize, visible bool)
- func (p *Pages) GetFrontPage() (name string, item Widget)
- func (p *Pages) GetPageCount() int
- func (p *Pages) HasPage(name string) bool
- func (p *Pages) HidePage(name string)
- func (p *Pages) RemovePage(name string)
- func (p *Pages) ShowPage(name string)
- func (p *Pages) SwitchToPage(name string)
- type Panels
- func (p *Panels) AddPanel(name string, item Widget, resize, visible bool)
- func (p *Panels) Draw(screen tcell.Screen)
- func (p *Panels) Focus(delegate func(w Widget))
- func (p *Panels) GetFrontPanel() (name string, item Widget)
- func (p *Panels) GetPanelCount() int
- func (p *Panels) HasFocus() bool
- func (p *Panels) HasPanel(name string) bool
- func (p *Panels) HidePanel(name string)
- func (p *Panels) MouseHandler() ...
- func (p *Panels) RemovePanel(name string)
- func (p *Panels) SendToBack(name string)
- func (p *Panels) SendToFront(name string)
- func (p *Panels) SetChangedFunc(handler func()) *Panels
- func (p *Panels) SetCurrentPanel(name string) *Panels
- func (p *Panels) ShowPanel(name string)
- type PercentageModeGauge
- func (g *PercentageModeGauge) Draw(screen tcell.Screen)
- func (g *PercentageModeGauge) Focus(delegate func(w Widget))
- func (g *PercentageModeGauge) GetMaxValue() int
- func (g *PercentageModeGauge) GetRect() (int, int, int, int)
- func (g *PercentageModeGauge) GetValue() int
- func (g *PercentageModeGauge) HasFocus() bool
- func (g *PercentageModeGauge) Reset()
- func (g *PercentageModeGauge) SetMaxValue(value int) *PercentageModeGauge
- func (g *PercentageModeGauge) SetPgBgColor(color tcell.Color) *PercentageModeGauge
- func (g *PercentageModeGauge) SetRect(x, y, width, height int) Widget
- func (g *PercentageModeGauge) SetValue(value int) *PercentageModeGauge
- type Plot
- func (plot *Plot) Draw(screen tcell.Screen)
- func (plot *Plot) GetPlotRect() (int, int, int, int)
- func (plot *Plot) SetAxesColor(color tcell.Color) *Plot
- func (plot *Plot) SetAxesLabelColor(color tcell.Color) *Plot
- func (plot *Plot) SetData(data [][]float64) *Plot
- func (plot *Plot) SetDotMarkerRune(r rune) *Plot
- func (plot *Plot) SetDrawAxes(draw bool) *Plot
- func (plot *Plot) SetDrawXAxisLabel(draw bool) *Plot
- func (plot *Plot) SetDrawYAxisLabel(draw bool) *Plot
- func (plot *Plot) SetLineColor(color []tcell.Color) *Plot
- func (plot *Plot) SetMarker(marker Marker) *Plot
- func (plot *Plot) SetMaxVal(maxVal float64) *Plot
- func (plot *Plot) SetMinVal(minVal float64) *Plot
- func (plot *Plot) SetPlotType(ptype PlotType) *Plot
- func (plot *Plot) SetRect(x, y, width, height int) Widget
- func (plot *Plot) SetXAxisLabelFunc(f func(int) string) *Plot
- func (plot *Plot) SetYAxisAutoScaleMax(autoScale bool) *Plot
- func (plot *Plot) SetYAxisAutoScaleMin(autoScale bool) *Plot
- func (plot *Plot) SetYAxisLabelDataType(dataType PlotYAxisLabelDataType) *Plot
- func (plot *Plot) SetYRange(minVal float64, maxVal float64) *Plot
- type PlotType
- type PlotYAxisLabelDataType
- type ProgressBar
- func (p *ProgressBar) AddProgress(progress int)
- func (p *ProgressBar) Complete() bool
- func (p *ProgressBar) Draw(screen tcell.Screen)
- func (p *ProgressBar) GetMax() int
- func (p *ProgressBar) GetProgress() int
- func (p *ProgressBar) SetEmptyColor(empty tcell.Color) *ProgressBar
- func (p *ProgressBar) SetEmptyRune(empty rune) *ProgressBar
- func (p *ProgressBar) SetFilledColor(filled tcell.Color) *ProgressBar
- func (p *ProgressBar) SetFilledRune(filled rune) *ProgressBar
- func (p *ProgressBar) SetMax(max int) *ProgressBar
- func (p *ProgressBar) SetProgress(progress int) *ProgressBar
- func (p *ProgressBar) SetVertical(vertical bool) *ProgressBar
- type ScrollBarVisibility
- type Slider
- func (s *Slider) Draw(screen tcell.Screen)
- func (s *Slider) GetFieldHeight() int
- func (s *Slider) GetFieldWidth() int
- func (s *Slider) GetLabel() string
- func (s *Slider) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (s *Slider) MouseHandler() ...
- func (s *Slider) SetBackgroundColor(color tcell.Color) FormItem
- func (s *Slider) SetChangedFunc(handler func(value int)) *Slider
- func (s *Slider) SetDoneFunc(handler func(key tcell.Key)) *Slider
- func (s *Slider) SetFieldBackgroundColor(color tcell.Color) FormItem
- func (s *Slider) SetFieldBackgroundColorFocused(color tcell.Color) FormItem
- func (s *Slider) SetFieldTextColor(color tcell.Color) FormItem
- func (s *Slider) SetFieldTextColorFocused(color tcell.Color) FormItem
- func (s *Slider) SetFinishedFunc(handler func(key tcell.Key)) FormItem
- func (s *Slider) SetIncrement(increment int) *Slider
- func (s *Slider) SetLabel(label string) *Slider
- func (s *Slider) SetLabelColor(color tcell.Color) FormItem
- func (s *Slider) SetLabelColorFocused(color tcell.Color) FormItem
- func (s *Slider) SetLabelWidth(width int) FormItem
- type Sparkline
- func (sl *Sparkline) Draw(screen tcell.Screen)
- func (sl *Sparkline) GetRect() (int, int, int, int)
- func (sl *Sparkline) HasFocus() bool
- func (sl *Sparkline) SetData(data []float64) *Sparkline
- func (sl *Sparkline) SetDataTitle(title string) *Sparkline
- func (sl *Sparkline) SetDataTitleColor(color tcell.Color) *Sparkline
- func (sl *Sparkline) SetLineColor(color tcell.Color) *Sparkline
- func (sl *Sparkline) SetRect(x, y, width, height int) Widget
- type Spinner
- type SpinnerStyle
- type SubMenu
- type TabbedPanels
- func (t *TabbedPanels) AddTab(name, label string, item Widget)
- func (t *TabbedPanels) Draw(screen tcell.Screen)
- func (t *TabbedPanels) GetCurrentTab() string
- func (t *TabbedPanels) HasTab(name string) bool
- func (t *TabbedPanels) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (t *TabbedPanels) MouseHandler() ...
- func (t *TabbedPanels) RemoveTab(name string)
- func (t *TabbedPanels) SetChangedFunc(handler func()) *TabbedPanels
- func (t *TabbedPanels) SetCurrentTab(name string) *TabbedPanels
- func (t *TabbedPanels) SetTabBackgroundColor(color tcell.Color) *TabbedPanels
- func (t *TabbedPanels) SetTabBackgroundColorFocused(color tcell.Color) *TabbedPanels
- func (t *TabbedPanels) SetTabLabel(name, label string) *TabbedPanels
- func (t *TabbedPanels) SetTabSwitcherAfterContent(after bool) *TabbedPanels
- func (t *TabbedPanels) SetTabSwitcherDivider(start, mid, end string) *TabbedPanels
- func (t *TabbedPanels) SetTabSwitcherHeight(height int) *TabbedPanels
- func (t *TabbedPanels) SetTabSwitcherVertical(vertical bool) *TabbedPanels
- func (t *TabbedPanels) SetTabTextColor(color tcell.Color) *TabbedPanels
- func (t *TabbedPanels) SetTabTextColorFocused(color tcell.Color) *TabbedPanels
- type Table
- func (t *Table) Clear()
- func (t *Table) Draw(screen tcell.Screen)
- func (t *Table) GetCell(row, column int) *TableCell
- func (t *Table) GetColumnCount() int
- func (t *Table) GetOffset() (row, column int)
- func (t *Table) GetRowCount() int
- func (t *Table) GetSelectable() (rows, columns bool)
- func (t *Table) GetSelection() (row, column int)
- func (t *Table) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (t *Table) InsertColumn(column int)
- func (t *Table) InsertRow(row int)
- func (t *Table) MouseHandler() ...
- func (t *Table) RemoveColumn(column int)
- func (t *Table) RemoveRow(row int)
- func (t *Table) ScrollToBeginning()
- func (t *Table) ScrollToEnd()
- func (t *Table) Select(row, column int)
- func (t *Table) SetBorders(show bool) *Table
- func (t *Table) SetBordersColor(color tcell.Color) *Table
- func (t *Table) SetCell(row, column int, cell *TableCell) *Table
- func (t *Table) SetCellSimple(row, column int, text string) *Table
- func (t *Table) SetDoneFunc(handler func(key tcell.Key)) *Table
- func (t *Table) SetEvaluateAllRows(all bool) *Table
- func (t *Table) SetFixed(rows, columns int) *Table
- func (t *Table) SetOffset(row, column int) *Table
- func (t *Table) SetScrollBarColor(color tcell.Color) *Table
- func (t *Table) SetScrollBarVisibility(visibility ScrollBarVisibility) *Table
- func (t *Table) SetSelectable(rows, columns bool) *Table
- func (t *Table) SetSelectedFunc(handler func(row, column int)) *Table
- func (t *Table) SetSelectedStyle(foregroundColor, backgroundColor tcell.Color, attributes tcell.AttrMask) *Table
- func (t *Table) SetSelectionChangedFunc(handler func(row, column int)) *Table
- func (t *Table) SetSeparator(separator rune) *Table
- func (t *Table) SetSortClicked(sortClicked bool) *Table
- func (t *Table) SetSortFunc(sortFunc func(column, i, j int) bool) *Table
- func (t *Table) Sort(column int, descending bool)
- type TableCell
- func (c *TableCell) GetBytes() []byte
- func (c *TableCell) GetLastPosition() (x, y, width int)
- func (c *TableCell) GetReference() interface{}
- func (c *TableCell) GetText() string
- func (c *TableCell) SetAlign(align int) *TableCell
- func (c *TableCell) SetAttributes(attr tcell.AttrMask) *TableCell
- func (c *TableCell) SetBackgroundColor(color tcell.Color) *TableCell
- func (c *TableCell) SetBytes(text []byte) *TableCell
- func (c *TableCell) SetExpansion(expansion int) *TableCell
- func (c *TableCell) SetMaxWidth(maxWidth int) *TableCell
- func (c *TableCell) SetReference(reference interface{}) *TableCell
- func (c *TableCell) SetSelectable(selectable bool) *TableCell
- func (c *TableCell) SetStyle(style tcell.Style) *TableCell
- func (c *TableCell) SetText(text string) *TableCell
- func (c *TableCell) SetTextColor(color tcell.Color) *TableCell
- type TextView
- func (t *TextView) Clear()
- func (t *TextView) Draw(screen tcell.Screen)
- func (t *TextView) Focus(delegate func(w Widget))
- func (t *TextView) GetBufferSize() (rows int, maxLen int)
- func (t *TextView) GetBytes(stripTags bool) []byte
- func (t *TextView) GetHighlights() (regionIDs []string)
- func (t *TextView) GetRegionText(regionID string) string
- func (t *TextView) GetScrollOffset() (row, column int)
- func (t *TextView) GetText(stripTags bool) string
- func (t *TextView) HasFocus() bool
- func (t *TextView) Highlight(regionIDs ...string)
- func (t *TextView) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (t *TextView) MouseHandler() ...
- func (t *TextView) ScrollTo(row, column int)
- func (t *TextView) ScrollToBeginning()
- func (t *TextView) ScrollToEnd()
- func (t *TextView) ScrollToHighlight()
- func (t *TextView) SetBytes(text []byte) *TextView
- func (t *TextView) SetChangedFunc(handler func()) *TextView
- func (t *TextView) SetDoneFunc(handler func(key tcell.Key)) *TextView
- func (t *TextView) SetDynamicColors(dynamic bool) *TextView
- func (t *TextView) SetHighlightBackgroundColor(color tcell.Color) *TextView
- func (t *TextView) SetHighlightForegroundColor(color tcell.Color) *TextView
- func (t *TextView) SetHighlightedFunc(handler func(added, removed, remaining []string)) *TextView
- func (t *TextView) SetMaxLines(maxLines int) *TextView
- func (t *TextView) SetRegions(regions bool) *TextView
- func (t *TextView) SetReindexBuffer(reindex bool) *TextView
- func (t *TextView) SetScrollBarColor(color tcell.Color) *TextView
- func (t *TextView) SetScrollBarVisibility(visibility ScrollBarVisibility) *TextView
- func (t *TextView) SetScrollable(scrollable bool) *TextView
- func (t *TextView) SetText(text string) *TextView
- func (t *TextView) SetTextAlign(align int) *TextView
- func (t *TextView) SetTextColor(color tcell.Color) *TextView
- func (t *TextView) SetToggleHighlights(toggle bool) *TextView
- func (t *TextView) SetVerticalAlign(valign VerticalAlignment) *TextView
- func (t *TextView) SetWordWrap(wrapOnWords bool) *TextView
- func (t *TextView) SetWrap(wrap bool) *TextView
- func (t *TextView) SetWrapWidth(width int) *TextView
- func (t *TextView) Write(p []byte) (n int, err error)
- type Theme
- type Transformation
- type TreeNode
- func (n *TreeNode) AddChild(node *TreeNode)
- func (n *TreeNode) ClearChildren()
- func (n *TreeNode) Collapse()
- func (n *TreeNode) CollapseAll()
- func (n *TreeNode) Expand()
- func (n *TreeNode) ExpandAll()
- func (n *TreeNode) GetChildren() []*TreeNode
- func (n *TreeNode) GetColor() tcell.Color
- func (n *TreeNode) GetReference() interface{}
- func (n *TreeNode) GetText() string
- func (n *TreeNode) IsExpanded() bool
- func (n *TreeNode) SetChildren(childNodes []*TreeNode) *TreeNode
- func (n *TreeNode) SetColor(color tcell.Color) *TreeNode
- func (n *TreeNode) SetExpanded(expanded bool) *TreeNode
- func (n *TreeNode) SetFocusedFunc(handler func()) *TreeNode
- func (n *TreeNode) SetIndent(indent int) *TreeNode
- func (n *TreeNode) SetReference(reference interface{}) *TreeNode
- func (n *TreeNode) SetSelectable(selectable bool) *TreeNode
- func (n *TreeNode) SetSelectedFunc(handler func()) *TreeNode
- func (n *TreeNode) SetText(text string) *TreeNode
- func (n *TreeNode) Walk(callback func(node, parent *TreeNode) bool)
- type TreeView
- func (t *TreeView) Draw(screen tcell.Screen)
- func (t *TreeView) GetCurrentNode() *TreeNode
- func (t *TreeView) GetRoot() *TreeNode
- func (t *TreeView) GetRowCount() int
- func (t *TreeView) GetScrollOffset() int
- func (t *TreeView) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (t *TreeView) MouseHandler() ...
- func (t *TreeView) SetAlign(align bool) *TreeView
- func (t *TreeView) SetChangedFunc(handler func(node *TreeNode)) *TreeView
- func (t *TreeView) SetCurrentNode(node *TreeNode) *TreeView
- func (t *TreeView) SetDoneFunc(handler func(key tcell.Key)) *TreeView
- func (t *TreeView) SetGraphics(showGraphics bool) *TreeView
- func (t *TreeView) SetGraphicsColor(color tcell.Color) *TreeView
- func (t *TreeView) SetPrefixes(prefixes []string) *TreeView
- func (t *TreeView) SetRoot(root *TreeNode) *TreeView
- func (t *TreeView) SetScrollBarColor(color tcell.Color) *TreeView
- func (t *TreeView) SetScrollBarVisibility(visibility ScrollBarVisibility) *TreeView
- func (t *TreeView) SetSelectedBackgroundColor(color tcell.Color) *TreeView
- func (t *TreeView) SetSelectedFunc(handler func(node *TreeNode)) *TreeView
- func (t *TreeView) SetSelectedTextColor(color tcell.Color) *TreeView
- func (t *TreeView) SetTopLevel(topLevel int) *TreeView
- func (t *TreeView) Transform(tr Transformation)
- type UtilisationGauge
- func (g *UtilisationGauge) Draw(screen tcell.Screen)
- func (g *UtilisationGauge) Focus(delegate func(w Widget))
- func (g *UtilisationGauge) GetRect() (int, int, int, int)
- func (g *UtilisationGauge) GetValue() float64
- func (g *UtilisationGauge) HasFocus() bool
- func (g *UtilisationGauge) SetCritPercentage(percentage float64) *UtilisationGauge
- func (g *UtilisationGauge) SetEmptyColor(color tcell.Color) *UtilisationGauge
- func (g *UtilisationGauge) SetLabel(label string) *UtilisationGauge
- func (g *UtilisationGauge) SetLabelColor(color tcell.Color) *UtilisationGauge
- func (g *UtilisationGauge) SetRect(x, y, width, height int) Widget
- func (g *UtilisationGauge) SetValue(value float64) *UtilisationGauge
- func (g *UtilisationGauge) SetWarnPercentage(percentage float64) *UtilisationGauge
- type VerticalAlignment
- type View
- type ViewPort
- func (v *ViewPort) Center(x, y int)
- func (v *ViewPort) Clear()
- func (v *ViewPort) Fill(ch rune, style tcell.Style)
- func (v *ViewPort) GetContentSize() (int, int)
- func (v *ViewPort) GetPhysical() (int, int, int, int)
- func (v *ViewPort) GetVisible() (int, int, int, int)
- func (v *ViewPort) MakeVisible(x, y int)
- func (v *ViewPort) Put(x, y int, str string, style tcell.Style) (string, int)
- func (v *ViewPort) Reset()
- func (v *ViewPort) Resize(x, y, width, height int)
- func (v *ViewPort) ScrollDown(rows int)
- func (v *ViewPort) ScrollLeft(cols int)
- func (v *ViewPort) ScrollRight(cols int)
- func (v *ViewPort) ScrollUp(rows int)
- func (v *ViewPort) SetContent(x, y int, ch rune, comb []rune, s tcell.Style)deprecated
- func (v *ViewPort) SetContentSize(width, height int, locked bool)
- func (v *ViewPort) SetSize(width, height int)
- func (v *ViewPort) SetView(view View)
- func (v *ViewPort) Size() (int, int)
- func (v *ViewPort) ValidateView()
- func (v *ViewPort) ValidateViewX()
- func (v *ViewPort) ValidateViewY()
- type Widget
- type Window
- func (w *Window) Blur()
- func (w *Window) Draw(screen tcell.Screen)
- func (w *Window) Focus(delegate func(w Widget))
- func (w *Window) HasFocus() bool
- func (w *Window) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
- func (w *Window) MouseHandler() ...
- func (w *Window) SetFullscreen(fullscreen bool) *Window
- type WindowManager
- Bugs
Examples ¶
Constants ¶
const ( LabelCtrl = "ctrl" LabelAlt = "alt" LabelMeta = "meta" LabelShift = "shift" )
Modifier labels
const ( InfoDialog = 0 + iota ErrorDailog )
represents dialog type.
const ( FlexRow = iota FlexColumn )
Configuration values.
const ( // Block: General Punctation U+2000-U+206F (http://unicode.org/charts/PDF/U2000.pdf) SemigraphicsHorizontalEllipsis rune = '\u2026' // … // Block: Box Drawing U+2500-U+257F (http://unicode.org/charts/PDF/U2500.pdf) BoxDrawingsLightHorizontal rune = '\u2500' // ─ BoxDrawingsHeavyHorizontal rune = '\u2501' // ━ BoxDrawingsLightVertical rune = '\u2502' // │ BoxDrawingsHeavyVertical rune = '\u2503' // ┃ BoxDrawingsLightTripleDashHorizontal rune = '\u2504' // ┄ BoxDrawingsHeavyTripleDashHorizontal rune = '\u2505' // ┅ BoxDrawingsLightTripleDashVertical rune = '\u2506' // ┆ BoxDrawingsHeavyTripleDashVertical rune = '\u2507' // ┇ BoxDrawingsLightQuadrupleDashHorizontal rune = '\u2508' // ┈ BoxDrawingsHeavyQuadrupleDashHorizontal rune = '\u2509' // ┉ BoxDrawingsLightQuadrupleDashVertical rune = '\u250a' // ┊ BoxDrawingsHeavyQuadrupleDashVertical rune = '\u250b' // ┋ BoxDrawingsLightDownAndRight rune = '\u250c' // ┌ BoxDrawingsDownLighAndRightHeavy rune = '\u250d' // ┍ BoxDrawingsDownHeavyAndRightLight rune = '\u250e' // ┎ BoxDrawingsHeavyDownAndRight rune = '\u250f' // ┏ BoxDrawingsLightDownAndLeft rune = '\u2510' // ┐ BoxDrawingsDownLighAndLeftHeavy rune = '\u2511' // ┑ BoxDrawingsDownHeavyAndLeftLight rune = '\u2512' // ┒ BoxDrawingsHeavyDownAndLeft rune = '\u2513' // ┓ BoxDrawingsLightUpAndRight rune = '\u2514' // └ BoxDrawingsUpLightAndRightHeavy rune = '\u2515' // ┕ BoxDrawingsUpHeavyAndRightLight rune = '\u2516' // ┖ BoxDrawingsHeavyUpAndRight rune = '\u2517' // ┗ BoxDrawingsLightUpAndLeft rune = '\u2518' // ┘ BoxDrawingsUpLightAndLeftHeavy rune = '\u2519' // ┙ BoxDrawingsUpHeavyAndLeftLight rune = '\u251a' // ┚ BoxDrawingsHeavyUpAndLeft rune = '\u251b' // ┛ BoxDrawingsLightVerticalAndRight rune = '\u251c' // ├ BoxDrawingsVerticalLightAndRightHeavy rune = '\u251d' // ┝ BoxDrawingsUpHeavyAndRightDownLight rune = '\u251e' // ┞ BoxDrawingsDownHeacyAndRightUpLight rune = '\u251f' // ┟ BoxDrawingsVerticalHeavyAndRightLight rune = '\u2520' // ┠ BoxDrawingsDownLightAnbdRightUpHeavy rune = '\u2521' // ┡ BoxDrawingsUpLightAndRightDownHeavy rune = '\u2522' // ┢ BoxDrawingsHeavyVerticalAndRight rune = '\u2523' // ┣ BoxDrawingsLightVerticalAndLeft rune = '\u2524' // ┤ BoxDrawingsVerticalLightAndLeftHeavy rune = '\u2525' // ┥ BoxDrawingsUpHeavyAndLeftDownLight rune = '\u2526' // ┦ BoxDrawingsDownHeavyAndLeftUpLight rune = '\u2527' // ┧ BoxDrawingsVerticalheavyAndLeftLight rune = '\u2528' // ┨ BoxDrawingsDownLightAndLeftUpHeavy rune = '\u2529' // ┨ BoxDrawingsUpLightAndLeftDownHeavy rune = '\u252a' // ┪ BoxDrawingsHeavyVerticalAndLeft rune = '\u252b' // ┫ BoxDrawingsLightDownAndHorizontal rune = '\u252c' // ┬ BoxDrawingsLeftHeavyAndRightDownLight rune = '\u252d' // ┭ BoxDrawingsRightHeavyAndLeftDownLight rune = '\u252e' // ┮ BoxDrawingsDownLightAndHorizontalHeavy rune = '\u252f' // ┯ BoxDrawingsDownHeavyAndHorizontalLight rune = '\u2530' // ┰ BoxDrawingsRightLightAndLeftDownHeavy rune = '\u2531' // ┱ BoxDrawingsLeftLightAndRightDownHeavy rune = '\u2532' // ┲ BoxDrawingsHeavyDownAndHorizontal rune = '\u2533' // ┳ BoxDrawingsLightUpAndHorizontal rune = '\u2534' // ┴ BoxDrawingsLeftHeavyAndRightUpLight rune = '\u2535' // ┵ BoxDrawingsRightHeavyAndLeftUpLight rune = '\u2536' // ┶ BoxDrawingsUpLightAndHorizontalHeavy rune = '\u2537' // ┷ BoxDrawingsUpHeavyAndHorizontalLight rune = '\u2538' // ┸ BoxDrawingsRightLightAndLeftUpHeavy rune = '\u2539' // ┹ BoxDrawingsLeftLightAndRightUpHeavy rune = '\u253a' // ┺ BoxDrawingsHeavyUpAndHorizontal rune = '\u253b' // ┻ BoxDrawingsLightVerticalAndHorizontal rune = '\u253c' // ┼ BoxDrawingsLeftHeavyAndRightVerticalLight rune = '\u253d' // ┽ BoxDrawingsRightHeavyAndLeftVerticalLight rune = '\u253e' // ┾ BoxDrawingsVerticalLightAndHorizontalHeavy rune = '\u253f' // ┿ BoxDrawingsUpHeavyAndDownHorizontalLight rune = '\u2540' // ╀ BoxDrawingsDownHeavyAndUpHorizontalLight rune = '\u2541' // ╁ BoxDrawingsVerticalHeavyAndHorizontalLight rune = '\u2542' // ╂ BoxDrawingsLeftUpHeavyAndRightDownLight rune = '\u2543' // ╃ BoxDrawingsRightUpHeavyAndLeftDownLight rune = '\u2544' // ╄ BoxDrawingsLeftDownHeavyAndRightUpLight rune = '\u2545' // ╅ BoxDrawingsRightDownHeavyAndLeftUpLight rune = '\u2546' // ╆ BoxDrawingsDownLightAndUpHorizontalHeavy rune = '\u2547' // ╇ BoxDrawingsUpLightAndDownHorizontalHeavy rune = '\u2548' // ╈ BoxDrawingsRightLightAndLeftVerticalHeavy rune = '\u2549' // ╉ BoxDrawingsLeftLightAndRightVerticalHeavy rune = '\u254a' // ╊ BoxDrawingsHeavyVerticalAndHorizontal rune = '\u254b' // ╋ BoxDrawingsLightDoubleDashHorizontal rune = '\u254c' // ╌ BoxDrawingsHeavyDoubleDashHorizontal rune = '\u254d' // ╍ BoxDrawingsLightDoubleDashVertical rune = '\u254e' // ╎ BoxDrawingsHeavyDoubleDashVertical rune = '\u254f' // ╏ BoxDrawingsDoubleHorizontal rune = '\u2550' // ═ BoxDrawingsDoubleVertical rune = '\u2551' // ║ BoxDrawingsDownSingleAndRightDouble rune = '\u2552' // ╒ BoxDrawingsDownDoubleAndRightSingle rune = '\u2553' // ╓ BoxDrawingsDoubleDownAndRight rune = '\u2554' // ╔ BoxDrawingsDownSingleAndLeftDouble rune = '\u2555' // ╕ BoxDrawingsDownDoubleAndLeftSingle rune = '\u2556' // ╖ BoxDrawingsDoubleDownAndLeft rune = '\u2557' // ╗ BoxDrawingsUpSingleAndRightDouble rune = '\u2558' // ╘ BoxDrawingsUpDoubleAndRightSingle rune = '\u2559' // ╙ BoxDrawingsDoubleUpAndRight rune = '\u255a' // ╚ BoxDrawingsUpSingleAndLeftDouble rune = '\u255b' // ╛ BoxDrawingsUpDobuleAndLeftSingle rune = '\u255c' // ╜ BoxDrawingsDoubleUpAndLeft rune = '\u255d' // ╝ BoxDrawingsVerticalSingleAndRightDouble rune = '\u255e' // ╞ BoxDrawingsVerticalDoubleAndRightSingle rune = '\u255f' // ╟ BoxDrawingsDoubleVerticalAndRight rune = '\u2560' // ╠ BoxDrawingsVerticalSingleAndLeftDouble rune = '\u2561' // ╡ BoxDrawingsVerticalDoubleAndLeftSingle rune = '\u2562' // ╢ BoxDrawingsDoubleVerticalAndLeft rune = '\u2563' // ╣ BoxDrawingsDownSingleAndHorizontalDouble rune = '\u2564' // ╤ BoxDrawingsDownDoubleAndHorizontalSingle rune = '\u2565' // ╥ BoxDrawingsDoubleDownAndHorizontal rune = '\u2566' // ╦ BoxDrawingsUpSingleAndHorizontalDouble rune = '\u2567' // ╧ BoxDrawingsUpDoubleAndHorizontalSingle rune = '\u2568' // ╨ BoxDrawingsDoubleUpAndHorizontal rune = '\u2569' // ╩ BoxDrawingsVerticalSingleAndHorizontalDouble rune = '\u256a' // ╪ BoxDrawingsVerticalDoubleAndHorizontalSingle rune = '\u256b' // ╫ BoxDrawingsDoubleVerticalAndHorizontal rune = '\u256c' // ╬ BoxDrawingsLightArcDownAndRight rune = '\u256d' // ╭ BoxDrawingsLightArcDownAndLeft rune = '\u256e' // ╮ BoxDrawingsLightArcUpAndLeft rune = '\u256f' // ╯ BoxDrawingsLightArcUpAndRight rune = '\u2570' // ╰ BoxDrawingsLightDiagonalUpperRightToLowerLeft rune = '\u2571' // ╱ BoxDrawingsLightDiagonalUpperLeftToLowerRight rune = '\u2572' // ╲ BoxDrawingsLightDiagonalCross rune = '\u2573' // ╳ BoxDrawingsLightLeft rune = '\u2574' // ╴ BoxDrawingsLightUp rune = '\u2575' // ╵ BoxDrawingsLightRight rune = '\u2576' // ╶ BoxDrawingsLightDown rune = '\u2577' // ╷ BoxDrawingsHeavyLeft rune = '\u2578' // ╸ BoxDrawingsHeavyUp rune = '\u2579' // ╹ BoxDrawingsHeavyRight rune = '\u257a' // ╺ BoxDrawingsHeavyDown rune = '\u257b' // ╻ BoxDrawingsLightLeftAndHeavyRight rune = '\u257c' // ╼ BoxDrawingsLightUpAndHeavyDown rune = '\u257d' // ╽ BoxDrawingsHeavyLeftAndLightRight rune = '\u257e' // ╾ BoxDrawingsHeavyUpAndLightDown rune = '\u257f' // ╿ )
Semigraphics provides an easy way to access unicode characters for drawing.
Named like the unicode characters, 'Semigraphics'-prefix used if unicode block isn't prefixed itself.
const ( AlignLeft = iota AlignCenter AlignRight )
Horizontal alignment within a box.
const StandardDoubleClick = 500 * time.Millisecond
StandardDoubleClick is a commonly used double click interval.
Variables ¶
var ( // InputFieldInteger accepts integers. InputFieldInteger func(text string, ch rune) bool // InputFieldFloat accepts floating-point numbers. InputFieldFloat func(text string, ch rune) bool // InputFieldMaxLength returns an input field accept handler which accepts // input strings up to a given length. Use it like this: // // inputField.SetAcceptanceFunc(InputFieldMaxLength(10)) // Accept up to 10 characters. InputFieldMaxLength func(maxLength int) func(text string, ch rune) bool )
Predefined InputField acceptance functions.
var ( ScrollBarArea = []byte("[-:-:-]░") ScrollBarAreaFocused = []byte("[-:-:-]▒") ScrollBarHandle = []byte("[-:-:-]▓") ScrollBarHandleFocused = []byte("[::r] [-:-:-]") )
Scroll bar render text (must be one cell wide)
var Borders = struct { Horizontal rune Vertical rune TopLeft rune TopRight rune BottomLeft rune BottomRight rune LeftT rune RightT rune TopT rune BottomT rune Cross rune HorizontalFocus rune VerticalFocus rune TopLeftFocus rune TopRightFocus rune BottomLeftFocus rune BottomRightFocus rune }{ Horizontal: BoxDrawingsLightHorizontal, Vertical: BoxDrawingsLightVertical, TopLeft: BoxDrawingsLightDownAndRight, TopRight: BoxDrawingsLightDownAndLeft, BottomLeft: BoxDrawingsLightUpAndRight, BottomRight: BoxDrawingsLightUpAndLeft, LeftT: BoxDrawingsLightVerticalAndRight, RightT: BoxDrawingsLightVerticalAndLeft, TopT: BoxDrawingsLightDownAndHorizontal, BottomT: BoxDrawingsLightUpAndHorizontal, Cross: BoxDrawingsLightVerticalAndHorizontal, HorizontalFocus: BoxDrawingsDoubleHorizontal, VerticalFocus: BoxDrawingsDoubleVertical, TopLeftFocus: BoxDrawingsDoubleDownAndRight, TopRightFocus: BoxDrawingsDoubleDownAndLeft, BottomLeftFocus: BoxDrawingsDoubleUpAndRight, BottomRightFocus: BoxDrawingsDoubleUpAndLeft, }
Borders defines various borders used when widgets are drawn. These may be changed to accommodate a different look and feel.
var CallbackErrorHandler func(error) = func(err error) { fmt.Fprintf(os.Stderr, "cui: callback error: %v\n", err) }
CallbackErrorHandler is called when a rumo callback invoked from a tview event handler returns an error. If nil, errors are silently discarded (pre-fix behaviour). Set a handler to observe/log callback failures.
var ColorUnset = color.IsSpecial | 108
ColorUnset represents an unset color. This is necessary because the zero value of color, ColorDefault, results in default terminal colors.
var DefaultFormFieldWidth = 10
DefaultFormFieldWidth is the default field screen width of form elements whose field width is flexible (0). This is used in the Form class for horizontal layouts.
var ErrInvalidKeyEvent = errors.New("invalid key event")
ErrInvalidKeyEvent is the error returned when encoding or decoding a key event fails.
var Keys = Key{ Cancel: []string{"Escape"}, Select: []string{"Enter", "Ctrl+J"}, Select2: []string{"Space"}, MoveUp: []string{"Up"}, MoveUp2: []string{"k"}, MoveDown: []string{"Down"}, MoveDown2: []string{"j"}, MoveLeft: []string{"Left"}, MoveLeft2: []string{"h"}, MoveRight: []string{"Right"}, MoveRight2: []string{"l"}, MoveFirst: []string{"Home", "Ctrl+A"}, MoveFirst2: []string{"g"}, MoveLast: []string{"End", "Ctrl+E"}, MoveLast2: []string{"G"}, MovePreviousField: []string{"Backtab"}, MoveNextField: []string{"Tab"}, MovePreviousPage: []string{"PageUp", "Ctrl+B"}, MoveNextPage: []string{"PageDown", "Ctrl+F"}, ShowContextMenu: []string{"Alt+Enter"}, }
Keys defines the keyboard shortcuts of an application. Secondary shortcuts apply when not focusing a text input.
var Module = module.NewBuiltin(). Func("new_app() (app *App)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapApp(NewApp()), nil }). Func("new_box() (box *Box)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapBox(), nil }). Func("new_text_view() (tv *TextView)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapTextView(NewTextView()), nil }). Func("new_button(label string) (btn *Button)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 1 { return nil, vm.ErrWrongNumArguments } label, ok := strictStr(args[0]) if !ok { return nil, vm.ErrInvalidArgumentType{Name: "first", Expected: "string", Found: args[0].TypeName()} } return wrapButton(NewButton(label)), nil }). Func("new_check_box() (cb *CheckBox)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapCheckBox(NewCheckBox()), nil }). Func("new_input_field() (i *InputField)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapInputField(NewInputField()), nil }). Func("new_list() (l *List)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapList(NewList()), nil }). Func("new_table() (t *Table)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapTable(NewTable()), nil }). Func("new_flex() (f *Flex)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapFlex(NewFlex()), nil }). Func("new_grid() (g *Grid)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapGrid(NewGrid()), nil }). Func("new_form() (f *Form)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapForm(NewForm()), nil }). Func("new_modal() (m *Modal)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapModal(NewModal()), nil }). Func("new_panels() (p *Panels)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapPanels(NewPanels()), nil }). Func("new_tabbed_panels() (tp *TabbedPanels)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapTabbedPanels(NewTabbedPanels()), nil }). Func("new_tree_view() (tv *TreeView)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapTreeView(NewTreeView()), nil }). Func("new_tree_node(text string) (node *TreeNode)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 1 { return nil, vm.ErrWrongNumArguments } text, ok := strictStr(args[0]) if !ok { return nil, vm.ErrInvalidArgumentType{Name: "first", Expected: "string", Found: args[0].TypeName()} } return wrapTreeNode(NewTreeNode(text)), nil }). Func("new_progress_bar() (pb *ProgressBar)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapProgressBar(NewProgressBar()), nil }). Func("new_drop_down() (dd *DropDown)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 0 { return nil, vm.ErrWrongNumArguments } return wrapDropDown(NewDropDown()), nil }). Func("new_frame(widget *Widget) (fr *Frame)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 1 { return nil, vm.ErrWrongNumArguments } w := toWidget(args[0]) if w == nil { return nil, vm.ErrInvalidArgumentType{Name: "first", Expected: "widget", Found: args[0].TypeName()} } return wrapFrame(NewFrame(w)), nil }). Const("flex_row int", FlexRow). Const("flex_column int", FlexColumn). Const("align_left int", AlignLeft). Const("align_center int", AlignCenter). Const("align_right int", AlignRight)
Module provides a terminal-based UI toolkit built on top of tview.
var SemigraphicJoints = map[string]rune{ string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightVertical}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightDownAndRight}): BoxDrawingsLightDownAndHorizontal, string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightDownAndLeft}): BoxDrawingsLightDownAndHorizontal, string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightUpAndRight}): BoxDrawingsLightUpAndHorizontal, string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightUpAndLeft}): BoxDrawingsLightUpAndHorizontal, string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightVerticalAndRight}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightDownAndHorizontal, string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightUpAndHorizontal, string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightDownAndRight}): BoxDrawingsLightVerticalAndRight, string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightDownAndLeft}): BoxDrawingsLightVerticalAndLeft, string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightUpAndRight}): BoxDrawingsLightVerticalAndRight, string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightUpAndLeft}): BoxDrawingsLightVerticalAndLeft, string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightVerticalAndRight}): BoxDrawingsLightVerticalAndRight, string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndLeft, string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightDownAndLeft}): BoxDrawingsLightDownAndHorizontal, string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightUpAndRight}): BoxDrawingsLightVerticalAndRight, string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightUpAndLeft}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightVerticalAndRight}): BoxDrawingsLightVerticalAndRight, string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightDownAndHorizontal, string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightUpAndRight}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightUpAndLeft}): BoxDrawingsLightVerticalAndLeft, string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightVerticalAndRight}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndLeft, string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightDownAndHorizontal, string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightUpAndRight, BoxDrawingsLightUpAndLeft}): BoxDrawingsLightUpAndHorizontal, string([]rune{BoxDrawingsLightUpAndRight, BoxDrawingsLightVerticalAndRight}): BoxDrawingsLightVerticalAndRight, string([]rune{BoxDrawingsLightUpAndRight, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightUpAndRight, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightUpAndRight, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightUpAndHorizontal, string([]rune{BoxDrawingsLightUpAndRight, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightUpAndLeft, BoxDrawingsLightVerticalAndRight}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightUpAndLeft, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndLeft, string([]rune{BoxDrawingsLightUpAndLeft, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightUpAndLeft, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightUpAndHorizontal, string([]rune{BoxDrawingsLightUpAndLeft, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightVerticalAndRight, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightVerticalAndRight, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightVerticalAndRight, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightVerticalAndRight, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightVerticalAndLeft, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightVerticalAndLeft, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightVerticalAndLeft, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightDownAndHorizontal, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightDownAndHorizontal, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, string([]rune{BoxDrawingsLightUpAndHorizontal, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal, }
SemigraphicJoints is a map for joining semigraphic (or otherwise) runes. So far only light lines are supported but if you want to change the border styling you need to provide the joints, too. The matching will be sorted ascending by rune value, so you don't need to provide all rune combinations, e.g. (─) + (│) = (┼) will also match (│) + (─) = (┼)
var Styles = Theme{ TitleColor: color.White, BorderColor: color.White, GraphicsColor: color.White, PrimaryTextColor: color.White, SecondaryTextColor: color.Yellow, TertiaryTextColor: color.LimeGreen, InverseTextColor: color.Black, ContrastPrimaryTextColor: color.Black, ContrastSecondaryTextColor: color.LightSlateGray, WidgetBackgroundColor: color.Black, ContrastBackgroundColor: color.Green, MoreContrastBackgroundColor: color.DarkGreen, ButtonCursorRune: '◀', CheckBoxCheckedRune: 'X', CheckBoxCursorRune: '◀', ContextMenuPaddingTop: 0, ContextMenuPaddingBottom: 0, ContextMenuPaddingLeft: 1, ContextMenuPaddingRight: 1, DropDownAbbreviationChars: "...", DropDownSymbol: '◀', DropDownOpenSymbol: '▼', DropDownSelectedSymbol: '▶', ScrollBarColor: color.White, WindowMinWidth: 4, WindowMinHeight: 3, }
Styles defines the appearance of an application. The default is for a black background and some basic colors: black, white, yellow, green, cyan, and blue.
var (
// TabSize is the number of spaces with which a tab character will be replaced.
TabSize = 4
)
var TrueColorTags = false
TrueColorTags is a flag which controls whether color tags should render as the specific colors defined by tcell, or as the colors defined by the user's terminal configuration (the default).
var UnifyEnterKeys = true
UnifyEnterKeys is a flag that determines whether or not KPEnter (keypad enter) key events are interpreted as Enter key events. When enabled, Ctrl+J key events are also interpreted as Enter key events.
Functions ¶
func ANSIWriter ¶
ANSIWriter returns an io.Writer which translates any ANSI escape codes written to it into cui color tags. Other escape codes don't have an effect and are simply removed. The translated text is written to the provided writer.
func ColorHex ¶
ColorHex returns the hexadecimal value of a color as a string, prefixed with #. If the color is invalid, a blank string is returned.
func DecodeBind ¶
DecodeBind decodes a string as a key or combination of keys.
func DefaultColorizer ¶
DefaultColorize returns colors for a byte as follows:
- Gray if NULL
- DarkCyan if an ASCII printable
- Green if an ASCII space
- Purple if other ASCII characters
- Yellow if non-ASCII
func EncodeBind ¶
EncodeBind encodes a key or combination of keys a string.
func Escape ¶
Escape escapes the given text such that color and/or region tags are not recognized and substituted by the print functions of this package. For example, to include a tag-like string in a box title or in a TextView:
box.SetTitle(cui.Escape("[squarebrackets]"))
fmt.Fprint(textView, cui.Escape(`["quoted"]`))
func EscapeBytes ¶
EscapeBytes escapes the given text such that color and/or region tags are not recognized and substituted by the print functions of this package. For example, to include a tag-like string in a box title or in a TextView:
box.SetTitle(cui.Escape("[squarebrackets]"))
fmt.Fprint(textView, cui.EscapeBytes(`["quoted"]`))
func HitShortcut ¶
HitShortcut returns whether the EventKey provided is present in one or more sets of keybindings.
func Print ¶
func Print(screen tcell.Screen, text []byte, x, y, maxWidth, align int, color tcell.Color) (int, int)
Print prints text onto the screen into the given box at (x,y,maxWidth,1), not exceeding that box. "align" is one of AlignLeft, AlignCenter, or AlignRight. The screen's background color will not be changed.
You can change the colors and text styles mid-text by inserting a color tag. See the package description for details.
Returns the number of actual bytes of the text printed (including color tags) and the actual width used for the printed runes.
func PrintJoinedSemigraphics ¶
PrintJoinedSemigraphics prints a semigraphics rune into the screen at the given position with the given color, joining it with any existing semigraphics rune. Background colors are preserved. At this point, only regular single line borders are supported.
func PrintSimple ¶
PrintSimple prints white text to the screen at the given position.
func PrintStyle ¶
func PrintStyle(screen tcell.Screen, text []byte, x, y, maxWidth, align int, style tcell.Style) (int, int)
PrintStyle works like Print() but it takes a style instead of just a foreground color.
func RenderScrollBar ¶
func RenderScrollBar(screen tcell.Screen, visibility ScrollBarVisibility, x int, y int, height int, items int, cursor int, printed int, focused bool, color tcell.Color)
RenderScrollBar renders a scroll bar at the specified position.
func SetAttributes ¶
SetAttributes sets attributes on a style.
func TaggedStringWidth ¶
TaggedStringWidth returns the width of the given string needed to print it on screen. The text may contain color tags which are not counted.
func TaggedTextWidth ¶
TaggedTextWidth returns the width of the given string needed to print it on screen. The text may contain color tags which are not counted.
func TranslateANSI ¶
TranslateANSI replaces ANSI escape sequences found in the provided string with cui's color tags and returns the resulting string.
func WordWrap ¶
WordWrap splits a text such that each resulting line does not exceed the given screen width. Possible split points are after any punctuation or whitespace. Whitespace after split points will be dropped.
This function considers color tags to have no width.
Text is always split at newline characters ('\n').
BUG(tslocum) Text containing square brackets is not escaped properly. Use TextView.SetWrapWidth where possible.
Types ¶
type App ¶
App represents the top node of an application.
It is not strictly required to use this class as none of the other classes depend on it. However, it provides useful tools to set up an application and plays nicely with all widgets.
The following command displays a widget p on the screen until Ctrl-C is pressed:
if err := cui.NewApp().SetRoot(p, true).Run(); err != nil {
panic(err)
}
func NewApp ¶
func NewApp() *App
NewApp creates and returns a new application.
Example ¶
Example of an application with multiple layouts.
// Initialize application.
app := NewApp()
// Handle panics gracefully.
defer app.HandlePanic()
// Create shared TextView.
sharedTextView := NewTextView()
sharedTextView.SetTextAlign(AlignCenter)
sharedTextView.SetText("Widgets may be re-used between multiple layouts.")
// Create main layout using Grid.
mainTextView := NewTextView()
mainTextView.SetTextAlign(AlignCenter)
mainTextView.SetText("This is mainLayout.\n\nPress <Tab> to view aboutLayout.")
mainLayout := NewGrid()
mainLayout.AddItem(mainTextView, 0, 0, 1, 1, 0, 0, false)
mainLayout.AddItem(sharedTextView, 1, 0, 1, 1, 0, 0, false)
// Create about layout using Grid.
aboutTextView := NewTextView()
aboutTextView.SetTextAlign(AlignCenter)
aboutTextView.SetText("cui muti-layout application example\n\nhttps://github.com/malivvan/rumo/std/cui")
aboutLayout := NewGrid()
aboutLayout.AddItem(aboutTextView, 0, 0, 1, 1, 0, 0, false)
aboutLayout.AddItem(sharedTextView, 1, 0, 1, 1, 0, 0, false)
// Track the current layout.
currentLayout := 0
// Set an input capture function that switches between layouts when the tab
// key is pressed.
app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Key() == tcell.KeyTab {
if currentLayout == 0 {
currentLayout = 1
app.SetRoot(aboutLayout, true)
} else {
currentLayout = 0
app.SetRoot(mainLayout, true)
}
// Return nil to stop propagating the event to any remaining
// handlers.
return nil
}
// Return the event to continue propagating it.
return event
})
// Run the application.
app.SetRoot(mainLayout, true)
if err := app.Run(); err != nil {
panic(err)
}
func (*App) Draw ¶
Draw draws the provided widgets on the screen, or when no widgets are provided, draws the application's root widget (i.e. the entire screen).
When one or more widgets are supplied, the Draw functions of the widgets are called. Handlers set via BeforeDrawFunc and AfterDrawFunc are not called.
When no widgets are provided, the Draw function of the application's root widget is called. This results in drawing the entire screen. Handlers set via BeforeDrawFunc and AfterDrawFunc are also called.
func (*App) EnableBracketedPaste ¶
EnableBracketedPaste enables bracketed paste mode, which is enabled by default.
func (*App) EnableMouse ¶
EnableMouse enables mouse events.
Example ¶
Example of an application with mouse support.
// Initialize application.
app := NewApp()
// Handle panics gracefully.
defer app.HandlePanic()
// Enable mouse support.
app.EnableMouse(true)
// Enable double clicks.
app.SetDoubleClickInterval(StandardDoubleClick)
// Create a textview.
tv := NewTextView()
tv.SetText("Click somewhere!")
// Set a mouse capture function which prints where the mouse was clicked.
app.SetMouseCapture(func(event *tcell.EventMouse, action MouseAction) (*tcell.EventMouse, MouseAction) {
if action == MouseLeftClick || action == MouseLeftDoubleClick {
actionLabel := "click"
if action == MouseLeftDoubleClick {
actionLabel = "double-click"
}
x, y := event.Position()
fmt.Fprintf(tv, "\nYou %sed at %d,%d! Amazing!", actionLabel, x, y)
// Return nil to stop propagating the event to any remaining handlers.
return nil, 0
}
// Return the event to continue propagating it.
return event, action
})
// Run the application.
app.SetRoot(tv, true)
if err := app.Run(); err != nil {
panic(err)
}
func (*App) GetAfterDrawFunc ¶
GetAfterDrawFunc returns the callback function installed with SetAfterDrawFunc() or nil if none has been installed.
func (*App) GetAfterResizeFunc ¶
GetAfterResizeFunc returns the callback function installed with SetAfterResizeFunc() or nil if none has been installed.
func (*App) GetBeforeDrawFunc ¶
GetBeforeDrawFunc returns the callback function installed with SetBeforeDrawFunc() or nil if none has been installed.
func (*App) GetFocus ¶
GetFocus returns the widget which has the current focus. If none has it, nil is returned.
func (*App) GetInputCapture ¶
GetInputCapture returns the function installed with SetInputCapture() or nil if no such function has been installed.
func (*App) GetMouseCapture ¶
func (a *App) GetMouseCapture() func(event *tcell.EventMouse, action MouseAction) (*tcell.EventMouse, MouseAction)
GetMouseCapture returns the function installed with SetMouseCapture() or nil if no such function has been installed.
func (*App) GetScreen ¶
GetScreen returns the current tcell.Screen of the application. Lock the application when manipulating the screen to prevent race conditions. This value is only available after calling Init or Run.
func (*App) GetScreenSize ¶
GetScreenSize returns the size of the application's screen. These values are only available after calling Init or Run.
func (*App) HandlePanic ¶
func (a *App) HandlePanic()
HandlePanic (when deferred at the start of a goroutine) handles panics gracefully. The terminal is returned to its original state before the panic message is printed.
Panics may only be handled by the panicking goroutine. Because of this, HandlePanic must be deferred at the start of each goroutine (including main).
func (*App) Init ¶
Init initializes the application screen. Calling Init before running is not required. Its primary use is to populate screen dimensions before running an application.
func (*App) QueueEvent ¶
QueueEvent sends an event to the App event loop.
It is not recommended for event to be nil.
func (*App) QueueUpdate ¶
func (a *App) QueueUpdate(f func())
QueueUpdate queues a function to be executed as part of the event loop.
Note that Draw() is not implicitly called after the execution of f as that may not be desirable. You can call Draw() from f if the screen should be refreshed after each update. Alternatively, use QueueUpdateDraw() to follow up with an immediate refresh of the screen.
func (*App) QueueUpdateDraw ¶
QueueUpdateDraw works like QueueUpdate() except, when one or more widgets are provided, the widgets are drawn after the provided function returns. When no widgets are provided, the entire screen is drawn after the provided function returns.
func (*App) ResizeToFullScreen ¶
ResizeToFullScreen resizes the given widget such that it fills the entire screen.
func (*App) Run ¶
Run starts the application and thus the event loop. This function returns when Stop() was called.
func (*App) SetAfterDrawFunc ¶
SetAfterDrawFunc installs a callback function which is invoked after the root widget was drawn during screen updates.
Provide nil to uninstall the callback function.
func (*App) SetAfterFocusFunc ¶
SetAfterFocusFunc installs a callback function which is invoked after the application's focus changes.
Provide nil to uninstall the callback function.
func (*App) SetAfterResizeFunc ¶
SetAfterResizeFunc installs a callback function which is invoked when the application's window is initialized, and when the application's window size changes. After invoking this callback the screen is cleared and the application is drawn.
Provide nil to uninstall the callback function.
func (*App) SetBeforeDrawFunc ¶
SetBeforeDrawFunc installs a callback function which is invoked just before the root widget is drawn during screen updates. If the function returns true, drawing will not continue, i.e. the root widget will not be drawn (and an after-draw-handler will not be called).
Note that the screen is not cleared by the application. To clear the screen, you may call screen.Clear().
Provide nil to uninstall the callback function.
func (*App) SetBeforeFocusFunc ¶
SetBeforeFocusFunc installs a callback function which is invoked before the application's focus changes. Return false to maintain the current focus.
Provide nil to uninstall the callback function.
func (*App) SetDoubleClickInterval ¶
SetDoubleClickInterval sets the maximum time between clicks to register a double click rather than a single click. A standard duration is provided as StandardDoubleClick. No interval is set by default, disabling double clicks.
func (*App) SetFocus ¶
SetFocus sets the focus on a new widget. All key events will be redirected to that widget. Callers must ensure that the widget will handle key events.
Blur() will be called on the previously focused widget. Focus() will be called on the new widget.
func (*App) SetInputCapture ¶
SetInputCapture sets a function which captures all key events before they are forwarded to the key event handler of the widget which currently has focus. This function can then choose to forward that key event (or a different one) by returning it or stop the key event processing by returning nil.
Note that this also affects the default event handling of the application itself: Such a handler can intercept the Ctrl-C event which closes the application.
func (*App) SetMouseCapture ¶
func (a *App) SetMouseCapture(capture func(event *tcell.EventMouse, action MouseAction) (*tcell.EventMouse, MouseAction)) *App
SetMouseCapture sets a function which captures mouse events (consisting of the original tcell mouse event and the semantic mouse action) before they are forwarded to the appropriate mouse event handler. This function can then choose to forward that event (or a different one) by returning it or stop the event processing by returning a nil mouse event.
func (*App) SetRoot ¶
SetRoot sets the root widget for this application. If "fullscreen" is set to true, the root widget's position will be changed to fill the screen.
This function must be called at least once or nothing will be displayed when the application starts.
It also calls SetFocus() on the widget and draws the application.
func (*App) SetScreen ¶
SetScreen allows you to provide your own tcell.Screen object. For most applications, this is not needed and you should be familiar with tcell.Screen when using this function.
This function is typically called before the first call to Run(). Init() need not be called on the screen.
func (*App) Suspend ¶
Suspend temporarily suspends the application by exiting terminal UI mode and invoking the provided function "f". When "f" returns, terminal UI mode is entered again and the application resumes.
A return value of true indicates that the application was suspended and "f" was called. If false is returned, the application was already suspended, terminal UI mode was not exited, and "f" was not called.
type BarChart ¶
BarChart represents bar chart widget.
func (*BarChart) SetAxesColor ¶
SetAxesColor sets axes x and y lines color.
func (*BarChart) SetAxesLabelColor ¶
SetAxesLabelColor sets axes x and y label color.
func (*BarChart) SetBarValue ¶
SetBarValue sets bar values.
func (*BarChart) SetMaxValue ¶
SetMaxValue sets maximum value of bars.
type BarChartItem ¶
type BarChartItem struct {
// contains filtered or unexported fields
}
BarChartItem represents a single bar in bar chart.
type BindConfig ¶
type BindConfig struct {
// contains filtered or unexported fields
}
BindConfig maps keys to event handlers and processes key events.
func NewBindConfig ¶
func NewBindConfig() *BindConfig
NewBindConfig returns a new input configuration.
Example ¶
Example of creating and using an input configuration.
// Create a new input configuration to store the key bindings.
c := NewBindConfig()
handleSave := func(ev *tcell.EventKey) *tcell.EventKey {
// Save
return nil
}
handleOpen := func(ev *tcell.EventKey) *tcell.EventKey {
// Open
return nil
}
handleExit := func(ev *tcell.EventKey) *tcell.EventKey {
// Exit
return nil
}
// Bind Alt+s.
if err := c.Set("Alt+s", handleSave); err != nil {
log.Fatalf("failed to set keybind: %s", err)
}
// Bind Alt+o.
c.SetRune(tcell.ModAlt, 'o', handleOpen)
// Bind Escape.
c.SetKey(tcell.ModNone, tcell.KeyEscape, handleExit)
// Capture input. This will differ based on the framework in use (if any).
// When using tview or cui, call App.SetInputCapture before calling
// App.Run.
// app.SetInputCapture(c.Capture)
func (*BindConfig) Capture ¶
func (c *BindConfig) Capture(ev *tcell.EventKey) *tcell.EventKey
Capture handles key events.
type Box ¶
type Box struct {
// contains filtered or unexported fields
}
Box is the base Widget for all widgets. It has a background color and optional surrounding elements such as a border and a title. It does not have inner text. Widgets embed Box and draw their text over it.
func (*Box) GetBackgroundColor ¶
GetBackgroundColor returns the box's background color.
func (*Box) GetBorderPadding
deprecated
func (*Box) GetDrawFunc ¶
GetDrawFunc returns the callback function which was installed with SetDrawFunc() or nil if no such function has been installed.
func (*Box) GetFocusable ¶
GetFocusable returns the item's Focusable.
func (*Box) GetInnerRect ¶
GetInnerRect returns the position of the inner rectangle (x, y, width, height), without the border and without any padding. Width and height values will clamp to 0 and thus never be negative.
func (*Box) GetInputCapture ¶
GetInputCapture returns the function installed with SetInputCapture() or nil if no such function has been installed.
func (*Box) GetMouseCapture ¶
func (b *Box) GetMouseCapture() func(action MouseAction, event *tcell.EventMouse) (MouseAction, *tcell.EventMouse)
GetMouseCapture returns the function installed with SetMouseCapture() or nil if no such function has been installed.
func (*Box) GetPadding ¶
GetPadding returns the size of the padding around the box content.
func (*Box) GetRect ¶
GetRect returns the current position of the rectangle, x, y, width, and height.
func (*Box) GetVisible ¶
GetVisible returns a value indicating whether or not the box is visible.
func (*Box) InRect ¶
InRect returns true if the given coordinate is within the bounds of the box's rectangle.
func (*Box) InputHandler ¶
InputHandler returns nil.
func (*Box) MouseHandler ¶
func (b *Box) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns nil.
func (*Box) SetBackgroundColor ¶
SetBackgroundColor sets the box's background color.
func (*Box) SetBackgroundTransparent ¶
SetBackgroundTransparent sets the flag indicating whether or not the box's background is transparent. The screen is not cleared before drawing the application. Overlaying transparent widgets directly onto the screen may result in artifacts. To resolve this, add a blank, non-transparent Box to the bottom layer of the interface via Panels, or set a handler via SetBeforeDrawFunc which clears the screen.
func (*Box) SetBorder ¶
SetBorder sets the flag indicating whether or not the box should have a border.
func (*Box) SetBorderAttributes ¶
SetBorderAttributes sets the border's style attributes. You can combine different attributes using bitmask operations:
box.SetBorderAttributes(tcell.AttrUnderline | tcell.AttrBold)
func (*Box) SetBorderColor ¶
SetBorderColor sets the box's border color.
func (*Box) SetBorderColorFocused ¶
SetBorderColorFocused sets the box's border color when the box is focused.
func (*Box) SetBorderPadding
deprecated
func (*Box) SetDrawFunc ¶
func (b *Box) SetDrawFunc(handler func(screen tcell.Screen, x, y, width, height int) (int, int, int, int)) *Box
SetDrawFunc sets a callback function which is invoked after the box widget has been drawn. This allows you to add a more individual style to the box (and all widgets which extend it).
The function is provided with the box's dimensions (set via SetRect()). It must return the box's inner dimensions (x, y, width, height) which will be returned by GetInnerRect(), used by descendent widgets to draw their own content.
func (*Box) SetInputCapture ¶
SetInputCapture installs a function which captures key events before they are forwarded to the widget's default key event handler. This function can then choose to forward that key event (or a different one) to the default handler by returning it. If nil is returned, the default handler will not be called.
Providing a nil handler will remove a previously existing handler.
Note that this function will not have an effect on widgets composed of other widgets, such as Form, Flex, or Grid. Key events are only captured by the widgets that have focus (e.g. InputField) and only one widget can have focus at a time. Composing widgets such as Form pass the focus on to their contained widgets and thus never receive any key events themselves. Therefore, they cannot intercept key events.
func (*Box) SetMouseCapture ¶
func (b *Box) SetMouseCapture(capture func(action MouseAction, event *tcell.EventMouse) (MouseAction, *tcell.EventMouse)) *Box
SetMouseCapture sets a function which captures mouse events (consisting of the original tcell mouse event and the semantic mouse action) before they are forwarded to the widget's default mouse event handler. This function can then choose to forward that event (or a different one) by returning it or returning a nil mouse event, in which case the default handler will not be called.
Providing a nil handler will remove a previously existing handler.
func (*Box) SetPadding ¶
SetPadding sets the size of the padding around the box content.
func (*Box) SetRect ¶
SetRect sets a new position of the widget. Note that this has no effect if this widget is part of a layout (e.g. Flex, Grid) or if it was added like this:
application.SetRoot(b, true)
func (*Box) SetTitleAlign ¶
SetTitleAlign sets the alignment of the title, one of AlignLeft, AlignCenter, or AlignRight.
func (*Box) SetTitleColor ¶
SetTitleColor sets the box's title color.
func (*Box) SetVisible ¶
SetVisible sets the flag indicating whether or not the box is visible.
func (*Box) ShowFocus ¶
ShowFocus sets the flag indicating whether or not the borders of this widget should change thickness when focused.
func (*Box) WrapInputHandler ¶
func (b *Box) WrapInputHandler(inputHandler func(*tcell.EventKey, func(w Widget))) func(*tcell.EventKey, func(w Widget))
WrapInputHandler wraps an input handler (see InputHandler()) with the functionality to capture input (see SetInputCapture()) before passing it on to the provided (default) input handler.
This is only meant to be used by subclassing widgets.
func (*Box) WrapMouseHandler ¶
func (b *Box) WrapMouseHandler(mouseHandler func(MouseAction, *tcell.EventMouse, func(w Widget)) (bool, Widget)) func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
WrapMouseHandler wraps a mouse event handler (see MouseHandler()) with the functionality to capture mouse events (see SetMouseCapture()) before passing them on to the provided (default) event handler.
This is only meant to be used by subclassing widgets.
type Button ¶
Button is labeled box that triggers an action when selected.
func (*Button) InputHandler ¶
InputHandler returns the handler for this widget.
func (*Button) MouseHandler ¶
func (b *Button) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*Button) SetBackgroundColorFocused ¶
SetBackgroundColorFocused sets the background color of the button text when the button is in focus.
func (*Button) SetBlurFunc ¶
SetBlurFunc sets a handler which is called when the user leaves the button. The callback function is provided with the key that was pressed, which is one of the following:
- KeyEscape: Leaving the button with no specific direction.
- KeyTab: Move to the next field.
- KeyBacktab: Move to the previous field.
func (*Button) SetCursorRune ¶
SetCursorRune sets the rune to show within the button when it is focused.
func (*Button) SetLabelColor ¶
SetLabelColor sets the color of the button text.
func (*Button) SetLabelColorFocused ¶
SetLabelColorFocused sets the color of the button text when the button is in focus.
func (*Button) SetSelectedFunc ¶
SetSelectedFunc sets a handler which is called when the button was selected.
type CheckBox ¶
CheckBox implements a simple box for boolean values which can be checked and unchecked.
func (*CheckBox) GetFieldHeight ¶
GetFieldHeight returns the height of the field.
func (*CheckBox) GetFieldWidth ¶
GetFieldWidth returns this widget's field width.
func (*CheckBox) GetMessage ¶
GetMessage returns the text to be displayed after the checkbox
func (*CheckBox) InputHandler ¶
InputHandler returns the handler for this widget.
func (*CheckBox) MouseHandler ¶
func (c *CheckBox) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*CheckBox) SetBackgroundColor ¶
SetBackgroundColor sets the background color of the checkbox.
func (*CheckBox) SetChangedFunc ¶
SetChangedFunc sets a handler which is called when the checked state of this checkbox was changed by the user. The handler function receives the new state.
func (*CheckBox) SetChecked ¶
SetChecked sets the state of the checkbox.
func (*CheckBox) SetCheckedRune ¶
SetCheckedRune sets the rune to show when the checkbox is checked.
func (*CheckBox) SetCursorRune ¶
SetCursorRune sets the rune to show within the checkbox when it is focused.
func (*CheckBox) SetDoneFunc ¶
SetDoneFunc sets a handler which is called when the user is done using the checkbox. The callback function is provided with the key that was pressed, which is one of the following:
- KeyEscape: Abort text input.
- KeyTab: Move to the next field.
- KeyBacktab: Move to the previous field.
func (*CheckBox) SetFieldBackgroundColor ¶
SetFieldBackgroundColor sets the background color of the input area.
func (*CheckBox) SetFieldBackgroundColorFocused ¶
SetFieldBackgroundColorFocused sets the background color of the input area when focused.
func (*CheckBox) SetFieldTextColor ¶
SetFieldTextColor sets the text color of the input area.
func (*CheckBox) SetFieldTextColorFocused ¶
SetFieldTextColorFocused sets the text color of the input area when focused.
func (*CheckBox) SetFinishedFunc ¶
SetFinishedFunc sets a callback invoked when the user leaves this form item.
func (*CheckBox) SetLabelColor ¶
SetLabelColor sets the color of the label.
func (*CheckBox) SetLabelColorFocused ¶
SetLabelColorFocused sets the color of the label when focused.
func (*CheckBox) SetLabelWidth ¶
SetLabelWidth sets the screen width of the label. A value of 0 will cause the widget to use the width of the label string.
func (*CheckBox) SetMessage ¶
SetMessage sets the text to be displayed after the checkbox
type ContextMenu ¶
type ContextMenu struct {
// contains filtered or unexported fields
}
ContextMenu is a menu that appears upon user interaction, such as right clicking or pressing Alt+Enter.
func NewContextMenu ¶
func NewContextMenu(parent Widget) *ContextMenu
NewContextMenu returns a new context menu.
func (*ContextMenu) AddContextItem ¶
func (c *ContextMenu) AddContextItem(text string, shortcut rune, selected func(index int))
AddContextItem adds an item to the context menu. Adding an item with no text or shortcut will add a divider.
func (*ContextMenu) ClearContextMenu ¶
func (c *ContextMenu) ClearContextMenu()
ClearContextMenu removes all items from the context menu.
func (*ContextMenu) ContextMenuList ¶
func (c *ContextMenu) ContextMenuList() *List
ContextMenuList returns the underlying List of the context menu.
func (*ContextMenu) ContextMenuVisible ¶
func (c *ContextMenu) ContextMenuVisible() bool
ContextMenuVisible returns whether or not the context menu is visible.
func (*ContextMenu) HideContextMenu ¶
func (c *ContextMenu) HideContextMenu(setFocus func(Widget))
HideContextMenu hides the context menu.
func (*ContextMenu) SetContextSelectedFunc ¶
func (c *ContextMenu) SetContextSelectedFunc(handler func(index int, text string, shortcut rune)) *ContextMenu
SetContextSelectedFunc sets the function which is called when the user selects a context menu item. The function receives the item's index in the menu (starting with 0), its text and its shortcut rune. SetSelectedFunc must be called before the context menu is shown.
func (*ContextMenu) ShowContextMenu ¶
func (c *ContextMenu) ShowContextMenu(item int, x int, y int, setFocus func(Widget))
ShowContextMenu shows the context menu. Provide -1 for both to position on the selected item, or specify a position.
type DropDown ¶
DropDown implements a selection widget whose options become visible in a drop-down list when activated.
func (*DropDown) AddOptions ¶
func (d *DropDown) AddOptions(options ...*DropDownOption)
AddOptions adds new selectable options to this drop-down.
func (*DropDown) AddOptionsSimple ¶
AddOptionsSimple adds new selectable options to this drop-down.
func (*DropDown) GetCurrentOption ¶
func (d *DropDown) GetCurrentOption() (int, *DropDownOption)
GetCurrentOption returns the index of the currently selected option as well as the option itself. If no option was selected, -1 and nil is returned.
func (*DropDown) GetFieldHeight ¶
GetFieldHeight returns the height of the field.
func (*DropDown) GetFieldWidth ¶
GetFieldWidth returns this widget's field screen width.
func (*DropDown) InputHandler ¶
InputHandler returns the handler for this widget.
func (*DropDown) MouseHandler ¶
func (d *DropDown) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*DropDown) SetAlwaysDrawDropDownSymbol ¶
SetAlwaysDrawDropDownSymbol sets a flad that determines whether the drop down symbol is always drawn. The symbol is normally only drawn when focused.
func (*DropDown) SetBackgroundColor ¶
SetBackgroundColor sets the background color of the dropdown.
func (*DropDown) SetChangedFunc ¶
func (d *DropDown) SetChangedFunc(handler func(index int, option *DropDownOption)) *DropDown
SetChangedFunc sets a handler which is called when the user changes the focused drop-down option. The handler is provided with the selected option's index and the option itself. If "no option" was selected, these values are -1 and nil.
func (*DropDown) SetCurrentOption ¶
SetCurrentOption sets the index of the currently selected option. This may be a negative value to indicate that no option is currently selected. Calling this function will also trigger the "selected" callback (if there is one).
func (*DropDown) SetDoneFunc ¶
SetDoneFunc sets a handler which is called when the user is done selecting options. The callback function is provided with the key that was pressed, which is one of the following:
- KeyEscape: Abort selection.
- KeyTab: Move to the next field.
- KeyBacktab: Move to the previous field.
func (*DropDown) SetDropDownBackgroundColor ¶
SetDropDownBackgroundColor sets the background color of the drop-down list.
func (*DropDown) SetDropDownOpenSymbolRune ¶
SetDropDownOpenSymbolRune sets the rune to be drawn at the end of the dropdown field to indicate that the a dropdown is open.
func (*DropDown) SetDropDownSelectedBackgroundColor ¶
SetDropDownSelectedBackgroundColor sets the background color of the selected option in the drop-down list.
func (*DropDown) SetDropDownSelectedSymbolRune ¶
SetDropDownSelectedSymbolRune sets the rune to be drawn at the start of the selected list item.
func (*DropDown) SetDropDownSelectedTextColor ¶
SetDropDownSelectedTextColor sets the text color of the selected option in the drop-down list.
func (*DropDown) SetDropDownSymbolRune ¶
SetDropDownSymbolRune sets the rune to be drawn at the end of the dropdown field to indicate that this field is a dropdown.
func (*DropDown) SetDropDownTextColor ¶
SetDropDownTextColor sets text color of the drop-down list.
func (*DropDown) SetFieldBackgroundColor ¶
SetFieldBackgroundColor sets the background color of the options area.
func (*DropDown) SetFieldBackgroundColorFocused ¶
SetFieldBackgroundColorFocused sets the background color of the options area when focused.
func (*DropDown) SetFieldTextColor ¶
SetFieldTextColor sets the text color of the options area.
func (*DropDown) SetFieldTextColorFocused ¶
SetFieldTextColorFocused sets the text color of the options area when focused.
func (*DropDown) SetFieldWidth ¶
SetFieldWidth sets the screen width of the options area. A value of 0 means extend to as long as the longest option text.
func (*DropDown) SetFinishedFunc ¶
SetFinishedFunc sets a callback invoked when the user leaves this form item.
func (*DropDown) SetLabelColor ¶
SetLabelColor sets the color of the label.
func (*DropDown) SetLabelColorFocused ¶
SetLabelColorFocused sets the color of the label when focused.
func (*DropDown) SetLabelWidth ¶
SetLabelWidth sets the screen width of the label. A value of 0 will cause the widget to use the width of the label string.
func (*DropDown) SetOptions ¶
func (d *DropDown) SetOptions(selected func(index int, option *DropDownOption), options ...*DropDownOption) *DropDown
SetOptions replaces all current options with the ones provided and installs one callback function which is called when one of the options is selected. It will be called with the option's index and the option itself. The "selected" parameter may be nil.
func (*DropDown) SetOptionsSimple ¶
func (d *DropDown) SetOptionsSimple(selected func(index int, option *DropDownOption), options ...string) *DropDown
SetOptionsSimple replaces all current options with the ones provided and installs one callback function which is called when one of the options is selected. It will be called with the option's index and the option itself The "selected" parameter may be nil.
func (*DropDown) SetPrefixTextColor ¶
SetPrefixTextColor sets the color of the prefix string.
func (*DropDown) SetSelectedFunc ¶
func (d *DropDown) SetSelectedFunc(handler func(index int, option *DropDownOption)) *DropDown
SetSelectedFunc sets a handler which is called when the user selects a drop-down's option. This handler will be called in addition and prior to an option's optional individual handler. The handler is provided with the selected option's index and the option itself. If "no option" was selected, these values are -1 and nil.
func (*DropDown) SetTextOptions ¶
func (d *DropDown) SetTextOptions(prefix, suffix, currentPrefix, currentSuffix, noSelection string) *DropDown
SetTextOptions sets the text to be placed before and after each drop-down option (prefix/suffix), the text placed before and after the currently selected option (currentPrefix/currentSuffix) as well as the text to be displayed when no option is currently selected. Per default, all of these strings are empty.
type DropDownOption ¶
DropDownOption is one option that can be selected in a drop-down widget.
func NewDropDownOption ¶
func NewDropDownOption(text string) *DropDownOption
NewDropDownOption returns a new option for a dropdown.
func (*DropDownOption) GetReference ¶
func (d *DropDownOption) GetReference() interface{}
GetReference returns the reference object of this dropdown option.
func (*DropDownOption) GetText ¶
func (d *DropDownOption) GetText() string
GetText returns the text of this dropdown option.
func (*DropDownOption) SetReference ¶
func (d *DropDownOption) SetReference(reference interface{}) *DropDownOption
SetReference allows you to store a reference of any type in this option.
func (*DropDownOption) SetSelectedFunc ¶
func (d *DropDownOption) SetSelectedFunc(handler func(index int, option *DropDownOption)) *DropDownOption
SetSelectedFunc sets the handler to be called when this option is selected.
func (*DropDownOption) SetText ¶
func (d *DropDownOption) SetText(text string) *DropDownOption
SetText returns the text of this dropdown option.
type Flex ¶
Flex is a basic implementation of the Flexbox layout. The contained widgets are arranged horizontally or vertically. The way they are distributed along that dimension depends on their layout settings, which is either a fixed length or a proportional length. See AddItem() for details.
func NewFlex ¶
func NewFlex() *Flex
NewFlex returns a new flexbox layout container with no widgets and its direction set to FlexColumn. To add widgets to this layout, see AddItem(). To change the direction, see SetDirection().
Note that Flex will have a transparent background by default so that any nil flex items will show widgets behind the Flex. To disable this transparency:
flex.SetBackgroundTransparent(false)
func (*Flex) AddItem ¶
AddItem adds a new item to the container. The "fixedSize" argument is a width or height that may not be changed by the layout algorithm. A value of 0 means that its size is flexible and may be changed. The "proportion" argument defines the relative size of the item compared to other flexible-size items. For example, items with a proportion of 2 will be twice as large as items with a proportion of 1. The proportion must be at least 1 if fixedSize == 0 (ignored otherwise).
If "focus" is set to true, the item will receive focus when the Flex widget receives focus. If multiple items have the "focus" flag set to true, the first one will receive focus.
A nil value for the widget represents empty space.
func (*Flex) AddItemAtIndex ¶
AddItemAtIndex adds an item to the flex at a given index. For more information see AddItem.
func (*Flex) GetDirection ¶
GetDirection returns the direction in which the contained widgets are distributed. This can be either FlexColumn (default) or FlexRow.
func (*Flex) MouseHandler ¶
func (f *Flex) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*Flex) RemoveItem ¶
RemoveItem removes all items for the given widget from the container, keeping the order of the remaining items intact.
func (*Flex) ResizeItem ¶
ResizeItem sets a new size for the item(s) with the given widget. If there are multiple Flex items with the same widget, they will all receive the same size. For details regarding the size parameters, see AddItem().
func (*Flex) SetDirection ¶
SetDirection sets the direction in which the contained widgets are distributed. This can be either FlexColumn (default) or FlexRow.
func (*Flex) SetFullScreen ¶
SetFullScreen sets the flag which, when true, causes the flex layout to use the entire screen space instead of whatever size it is currently assigned to.
type FocusManager ¶
FocusManager manages application focus.
func NewFocusManager ¶
func NewFocusManager(setFocus func(w Widget)) *FocusManager
NewFocusManager returns a new FocusManager object.
func (*FocusManager) Add ¶
func (f *FocusManager) Add(w ...Widget)
Add adds an element to the focus handler.
func (*FocusManager) AddAt ¶
func (f *FocusManager) AddAt(index int, w Widget)
AddAt adds an element to the focus handler at the specified index.
func (*FocusManager) Focus ¶
func (f *FocusManager) Focus(w Widget)
Focus focuses the provided element.
func (*FocusManager) FocusAt ¶
func (f *FocusManager) FocusAt(index int)
FocusAt focuses the element at the provided index.
func (*FocusManager) FocusNext ¶
func (f *FocusManager) FocusNext()
FocusNext focuses the next element.
func (*FocusManager) FocusPrevious ¶
func (f *FocusManager) FocusPrevious()
FocusPrevious focuses the previous element.
func (*FocusManager) GetFocusIndex ¶
func (f *FocusManager) GetFocusIndex() int
GetFocusIndex returns the index of the currently focused element.
func (*FocusManager) GetFocusedWidget ¶
func (f *FocusManager) GetFocusedWidget() Widget
GetFocusedWidget returns the currently focused widget.
func (*FocusManager) SetWrapAround ¶
func (f *FocusManager) SetWrapAround(wrapAround bool)
SetWrapAround sets the flag that determines whether navigation will wrap around. That is, navigating forwards on the last field will move the selection to the first field (similarly in the other direction). If set to false, the focus won't change when navigating forwards on the last element or navigating backwards on the first element.
func (*FocusManager) Transform ¶
func (f *FocusManager) Transform(tr Transformation)
Transform modifies the current focus.
type Focusable ¶
type Focusable interface {
HasFocus() bool
}
Focusable provides a method which determines if a widget has focus. Composed widgets may be focused based on the focused state of their contained widgets.
type Form ¶
Form allows you to combine multiple one-line form elements into a vertical or horizontal layout. Form elements include types such as InputField or CheckBox. These elements can be optionally followed by one or more buttons for which you can define form-wide actions (e.g. Save, Clear, Cancel).
func (*Form) AddButton ¶
AddButton adds a new button to the form. The "selected" function is called when the user selects this button. It may be nil.
func (*Form) AddCheckBox ¶
AddCheckBox adds a checkbox to the form. It has a label, a message, an initial state, and an (optional) callback function which is invoked when the state of the checkbox was changed by the user.
func (*Form) AddDropDown ¶
func (f *Form) AddDropDown(label string, initialOption int, selected func(index int, option *DropDownOption), options []*DropDownOption)
AddDropDown adds a drop-down element to the form. It has a label, options, and an (optional) callback function which is invoked when an option was selected. The initial option may be a negative value to indicate that no option is currently selected.
func (*Form) AddDropDownSimple ¶
func (f *Form) AddDropDownSimple(label string, initialOption int, selected func(index int, option *DropDownOption), options ...string)
AddDropDownSimple adds a drop-down element to the form. It has a label, options, and an (optional) callback function which is invoked when an option was selected. The initial option may be a negative value to indicate that no option is currently selected.
func (*Form) AddFormItem ¶
AddFormItem adds a new item to the form. This can be used to add your own objects to the form. Note, however, that the Form class will override some of its attributes to make it work in the form context. Specifically, these are:
- The label width
- The label color
- The background color
- The field text color
- The field background color
func (*Form) AddInputField ¶
func (f *Form) AddInputField(label, value string, fieldWidth int, accept func(textToCheck string, lastChar rune) bool, changed func(text string))
AddInputField adds an input field to the form. It has a label, an optional initial value, a field width (a value of 0 extends it as far as possible), an optional accept function to validate the item's value (set to nil to accept any text), and an (optional) callback function which is invoked when the input field's text has changed.
func (*Form) AddPasswordField ¶
func (f *Form) AddPasswordField(label, value string, fieldWidth int, mask rune, changed func(text string))
AddPasswordField adds a password field to the form. This is similar to an input field except that the user's input not shown. Instead, a "mask" character is displayed. The password field has a label, an optional initial value, a field width (a value of 0 extends it as far as possible), and an (optional) callback function which is invoked when the input field's text has changed.
func (*Form) AddSlider ¶
AddSlider adds a slider to the form. It has a label, an initial value, a maximum value, an amount to increment by when modified via keyboard, and an (optional) callback function which is invoked when the state of the slider was changed by the user.
func (*Form) Clear ¶
Clear removes all input elements from the form, including the buttons if specified.
func (*Form) ClearButtons ¶
func (f *Form) ClearButtons()
ClearButtons removes all buttons from the form.
func (*Form) GetAttributes ¶
func (f *Form) GetAttributes() *FormItemAttributes
GetAttributes returns the current attribute settings of a form.
func (*Form) GetButton ¶
GetButton returns the button at the specified 0-based index. Note that buttons have been specially prepared for this form and modifying some of their attributes may have unintended side effects.
func (*Form) GetButtonCount ¶
GetButtonCount returns the number of buttons in this form.
func (*Form) GetButtonIndex ¶
GetButtonIndex returns the index of the button with the given label, starting with 0 for the button that was added first. If no such label was found, -1 is returned.
func (*Form) GetFocusedItemIndex ¶
GetFocusedItemIndex returns the indices of the form element or button which currently has focus. If they don't, -1 is returned resepectively.
func (*Form) GetFormItem ¶
GetFormItem returns the form item at the given position, starting with index 0. Elements are referenced in the order they were added. Buttons are not included. If index is out of bounds it returns nil.
func (*Form) GetFormItemByLabel ¶
GetFormItemByLabel returns the first form element with the given label. If no such element is found, nil is returned. Buttons are not searched and will therefore not be returned.
func (*Form) GetFormItemCount ¶
GetFormItemCount returns the number of items in the form (not including the buttons).
func (*Form) GetFormItemIndex ¶
GetFormItemIndex returns the index of the first form element with the given label. If no such element is found, -1 is returned. Buttons are not searched and will therefore not be returned.
func (*Form) IndexOfFormItem ¶
IndexOfFormItem returns the index of the given FormItem.
func (*Form) MouseHandler ¶
func (f *Form) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*Form) RemoveButton ¶
RemoveButton removes the button at the specified position, starting with 0 for the button that was added first.
func (*Form) RemoveFormItem ¶
RemoveFormItem removes the form element at the given position, starting with index 0. Elements are referenced in the order they were added. Buttons are not included.
func (*Form) SetButtonBackgroundColor ¶
SetButtonBackgroundColor sets the background color of the buttons.
func (*Form) SetButtonBackgroundColorFocused ¶
SetButtonBackgroundColorFocused sets the background color of the buttons when focused.
func (*Form) SetButtonTextColor ¶
SetButtonTextColor sets the color of the button texts.
func (*Form) SetButtonTextColorFocused ¶
SetButtonTextColorFocused sets the color of the button texts when focused.
func (*Form) SetButtonsAlign ¶
SetButtonsAlign sets how the buttons align horizontally, one of AlignLeft (the default), AlignCenter, and AlignRight. This is only
func (*Form) SetCancelFunc ¶
SetCancelFunc sets a callback which is called when the user hits the Escape key.
func (*Form) SetFieldBackgroundColor ¶
SetFieldBackgroundColor sets the background color of the input areas.
func (*Form) SetFieldBackgroundColorFocused ¶
SetFieldBackgroundColorFocused sets the background color of the input areas when focused.
func (*Form) SetFieldTextColor ¶
SetFieldTextColor sets the text color of the input areas.
func (*Form) SetFieldTextColorFocused ¶
SetFieldTextColorFocused sets the text color of the input areas when focused.
func (*Form) SetFocus ¶
SetFocus shifts the focus to the form element with the given index, counting non-button items first and buttons last. Note that this index is only used when the form itself receives focus.
func (*Form) SetHorizontal ¶
SetHorizontal sets the direction the form elements are laid out. If set to true, instead of positioning them from top to bottom (the default), they are positioned from left to right, moving into the next row if there is not enough space.
func (*Form) SetItemPadding ¶
SetItemPadding sets the number of empty rows between form items for vertical layouts and the number of empty cells between form items for horizontal layouts.
func (*Form) SetLabelColor ¶
SetLabelColor sets the color of the labels.
func (*Form) SetLabelColorFocused ¶
SetLabelColorFocused sets the color of the labels when focused.
func (*Form) SetWrapAround ¶
SetWrapAround sets the flag that determines whether navigating the form will wrap around. That is, navigating downwards on the last item will move the selection to the first item (similarly in the other direction). If set to false, the selection won't change when navigating downwards on the last item or navigating upwards on the first item.
type FormItem ¶
type FormItem interface {
Widget
// GetLabel returns the item's label text.
GetLabel() string
// SetLabelWidth sets the screen width of the label. A value of 0 will cause the
// widget to use the width of the label string.
SetLabelWidth(int) FormItem
// SetLabelColor sets the color of the label.
SetLabelColor(tcell.Color) FormItem
// SetLabelColor sets the color of the label when focused.
SetLabelColorFocused(tcell.Color) FormItem
// GetFieldWidth returns the width of the form item's field (the area which
// is manipulated by the user) in number of screen cells. A value of 0
// indicates the the field width is flexible and may use as much space as
// required.
GetFieldWidth() int
// GetFieldHeight returns the height of the form item.
GetFieldHeight() int
// SetFieldTextColor sets the text color of the input area.
SetFieldTextColor(tcell.Color) FormItem
// SetFieldTextColorFocused sets the text color of the input area when focused.
SetFieldTextColorFocused(tcell.Color) FormItem
// SetFieldBackgroundColor sets the background color of the input area.
SetFieldBackgroundColor(tcell.Color) FormItem
// SetFieldBackgroundColor sets the background color of the input area when focused.
SetFieldBackgroundColorFocused(tcell.Color) FormItem
// SetBackgroundColor sets the background color of the form item.
SetBackgroundColor(tcell.Color) FormItem
// SetFinishedFunc sets a callback invoked when the user leaves the form item.
SetFinishedFunc(func(key tcell.Key)) FormItem
}
FormItem is the interface all form items must implement to be able to be included in a form.
type FormItemAttributes ¶
type FormItemAttributes struct {
// The screen width of the label. A value of 0 will cause the widget to
// use the width of the label string.
LabelWidth int
BackgroundColor tcell.Color
LabelColor tcell.Color
LabelColorFocused tcell.Color
FieldBackgroundColor tcell.Color
FieldBackgroundColorFocused tcell.Color
FieldTextColor tcell.Color
FieldTextColorFocused tcell.Color
FinishedFunc func(key tcell.Key)
}
FormItemAttributes is a set of attributes to be applied.
type Frame ¶
Frame is a wrapper which adds space around another widget. In addition, the top area (header) and the bottom area (footer) may also contain text.
func NewFrame ¶
NewFrame returns a new frame around the given widget. The widget's size will be changed to fit within this frame.
func (*Frame) AddText ¶
AddText adds text to the frame. Set "header" to true if the text is to appear in the header, above the contained widget. Set it to false for it to appear in the footer, below the contained widget. "align" must be one of the Align constants. Rows in the header are printed top to bottom, rows in the footer are printed bottom to top. Note that long text can overlap as different alignments will be placed on the same row.
func (*Frame) MouseHandler ¶
func (f *Frame) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*Frame) SetBorders ¶
SetBorders sets the width of the frame borders as well as "header" and "footer", the vertical space between the header and footer text and the contained widget (does not apply if there is no text).
type Grid ¶
Grid is an implementation of a grid-based layout. It works by defining the size of the rows and columns, then placing widgets into the grid.
Some settings can lead to the grid exceeding its available space. SetOffset() can then be used to scroll in steps of rows and columns. These offset values can also be controlled with the arrow keys (or the "g","G", "j", "k", "h", and "l" keys) while the grid has focus and none of its contained widgets do.
func NewGrid ¶
func NewGrid() *Grid
NewGrid returns a new grid-based layout container with no initial widgets.
Note that Grid will have a transparent background by default so that any areas not covered by any widgets will show widgets behind the Grid. To disable this transparency:
grid.SetBackgroundTransparent(false)
func (*Grid) AddItem ¶
func (g *Grid) AddItem(w Widget, row, column, rowSpan, colSpan, minGridHeight, minGridWidth int, focus bool)
AddItem adds a widget and its position to the grid. The top-left corner of the widget will be located in the top-left corner of the grid cell at the given row and column and will span "rowSpan" rows and "colSpan" columns. For example, for a widget to occupy rows 2, 3, and 4 and columns 5 and 6:
grid.AddItem(p, 2, 5, 3, 2, 0, 0, true)
If rowSpan or colSpan is 0, the widget will not be drawn.
You can add the same widget multiple times with different grid positions. The minGridWidth and minGridHeight values will then determine which of those positions will be used. This is similar to CSS media queries. These minimum values refer to the overall size of the grid. If multiple items for the same widget apply, the one that has at least one highest minimum value will be used, or the widget added last if those values are the same. Example:
grid.AddItem(p, 0, 0, 0, 0, 0, 0, true). // Hide in small grids. AddItem(p, 0, 0, 1, 2, 100, 0, true). // One-column layout for medium grids. AddItem(p, 1, 1, 3, 2, 300, 0, true) // Multi-column layout for large grids.
To use the same grid layout for all sizes, simply set minGridWidth and minGridHeight to 0.
If the item's focus is set to true, it will receive focus when the grid receives focus. If there are multiple items with a true focus flag, the last visible one that was added will receive focus.
func (*Grid) GetOffset ¶
GetOffset returns the current row and column offset (see SetOffset() for details).
func (*Grid) InputHandler ¶
InputHandler returns the handler for this widget.
func (*Grid) MouseHandler ¶
func (g *Grid) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*Grid) RemoveItem ¶
RemoveItem removes all items for the given widget from the grid, keeping the order of the remaining items intact.
func (*Grid) SetBorders ¶
SetBorders sets whether or not borders are drawn around grid items. Setting this value to true will cause the gap values (see SetGap()) to be ignored and automatically assumed to be 1 where the border graphics are drawn.
func (*Grid) SetBordersColor ¶
SetBordersColor sets the color of the item borders.
func (*Grid) SetColumns ¶
SetColumns defines how the columns of the grid are distributed. Each value defines the size of one column, starting with the leftmost column. Values greater 0 represent absolute column widths (gaps not included). Values less or equal 0 represent proportional column widths or fractions of the remaining free space, where 0 is treated the same as -1. That is, a column with a value of -3 will have three times the width of a column with a value of -1 (or 0). The minimum width set with SetMinSize() is always observed.
Widgets may extend beyond the columns defined explicitly with this function. A value of 0 is assumed for any undefined column. In fact, if you never call this function, all columns occupied by widgets will have the same width. On the other hand, unoccupied columns defined with this function will always take their place.
Assuming a total width of the grid of 100 cells and a minimum width of 0, the following call will result in columns with widths of 30, 10, 15, 15, and 30 cells:
grid.SetColumns(30, 10, -1, -1, -2)
If a widget were then placed in the 6th and 7th column, the resulting widths would be: 30, 10, 10, 10, 20, 10, and 10 cells.
If you then called SetMinSize() as follows:
grid.SetMinSize(15, 20)
The resulting widths would be: 30, 15, 15, 15, 20, 15, and 15 cells, a total of 125 cells, 25 cells wider than the available grid width.
func (*Grid) SetGap ¶
SetGap sets the size of the gaps between neighboring widgets on the grid. If borders are drawn (see SetBorders()), these values are ignored and a gap of 1 is assumed. Panics if negative values are provided.
func (*Grid) SetMinSize ¶
SetMinSize sets an absolute minimum width for rows and an absolute minimum height for columns. Panics if negative values are provided.
func (*Grid) SetOffset ¶
SetOffset sets the number of rows and columns which are skipped before drawing the first grid cell in the top-left corner. As the grid will never completely move off the screen, these values may be adjusted the next time the grid is drawn. The actual position of the grid may also be adjusted such that contained widgets that have focus remain visible.
func (*Grid) SetRows ¶
SetRows defines how the rows of the grid are distributed. These values behave the same as the column values provided with SetColumns(), see there for a definition and examples.
The provided values correspond to row heights, the first value defining the height of the topmost row.
type HexView ¶
type HexView struct {
*Box
// Colorize is a function to determine which color to make a given byte.
// If not set, will use DefaultColorizer.
Colorize func(byte) tcell.Color
sync.RWMutex
// contains filtered or unexported fields
}
HexView is a tview widget to display data in a hex viewer style. By default it responds to up/down/pgup/pgdn/home/end for moving through the data. It is fixed width but can handle variable heights.
func NewHexView ¶
func (*HexView) InputHandler ¶
func (*HexView) MouseHandler ¶
func (h *HexView) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
type Image ¶
Image is a box which displays animated gifs via Omnikron13's pixelview dynamic color rendering. It automatically draws the right frame based on time elapsed since creation. You can trigger re-drawing by executing Animate(App) in a goroutine.
func (*Image) GetCurrentFrame ¶
GetCurrentFrame returns the current frame the GIF is on
type InputField ¶
InputField is a one-line box (three lines if there is a title) where the user can enter text. Use SetAcceptanceFunc() to accept or reject input, SetChangedFunc() to listen for changes, and SetMaskCharacter() to hide input from onlookers (e.g. for password input).
The following keys can be used for navigation and editing:
- Left arrow: Move left by one character.
- Right arrow: Move right by one character.
- Home, Ctrl-A, Alt-a: Move to the beginning of the line.
- End, Ctrl-E, Alt-e: Move to the end of the line.
- Alt-left, Alt-b: Move left by one word.
- Alt-right, Alt-f: Move right by one word.
- Backspace: Delete the character before the cursor.
- Delete: Delete the character after the cursor.
- Ctrl-K: Delete from the cursor to the end of the line.
- Ctrl-W: Delete the last word before the cursor.
- Ctrl-U: Delete the entire line.
func (*InputField) Autocomplete ¶
func (i *InputField) Autocomplete()
Autocomplete invokes the autocomplete callback (if there is one). If the length of the returned autocomplete entries slice is greater than 0, the input field will present the user with a corresponding drop-down list the next time the input field is drawn.
It is safe to call this function from any goroutine. Note that the input field is not redrawn automatically unless called from the main goroutine (e.g. in response to events).
func (*InputField) Draw ¶
func (i *InputField) Draw(screen tcell.Screen)
Draw draws this widget onto the screen.
func (*InputField) GetCursorPosition ¶
func (i *InputField) GetCursorPosition() int
GetCursorPosition returns the cursor position.
func (*InputField) GetFieldHeight ¶
func (i *InputField) GetFieldHeight() int
GetFieldHeight returns the height of the field.
func (*InputField) GetFieldWidth ¶
func (i *InputField) GetFieldWidth() int
GetFieldWidth returns this widget's field width.
func (*InputField) GetLabel ¶
func (i *InputField) GetLabel() string
GetLabel returns the text to be displayed before the input area.
func (*InputField) GetText ¶
func (i *InputField) GetText() string
GetText returns the current text of the input field.
func (*InputField) InputHandler ¶
func (i *InputField) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
InputHandler returns the handler for this widget.
func (*InputField) MouseHandler ¶
func (i *InputField) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*InputField) ResetFieldNote ¶
func (i *InputField) ResetFieldNote() *InputField
ResetFieldNote sets the note to an empty string.
func (*InputField) SetAcceptanceFunc ¶
func (i *InputField) SetAcceptanceFunc(handler func(textToCheck string, lastChar rune) bool) *InputField
SetAcceptanceFunc sets a handler which may reject the last character that was entered (by returning false).
This package defines a number of variables prefixed with InputField which may be used for common input (e.g. numbers, maximum text length).
func (*InputField) SetAutocompleteFunc ¶
func (i *InputField) SetAutocompleteFunc(callback func(currentText string) (entries []*ListItem)) *InputField
SetAutocompleteFunc sets an autocomplete callback function which may return ListItems to be selected from a drop-down based on the current text of the input field. The drop-down appears only if len(entries) > 0. The callback is invoked in this function and whenever the current text changes or when Autocomplete() is called. Entries are cleared when the user selects an entry or presses Escape.
func (*InputField) SetAutocompleteListBackgroundColor ¶
func (i *InputField) SetAutocompleteListBackgroundColor(color tcell.Color) *InputField
SetAutocompleteListBackgroundColor sets the background color of the autocomplete list.
func (*InputField) SetAutocompleteListSelectedBackgroundColor ¶
func (i *InputField) SetAutocompleteListSelectedBackgroundColor(color tcell.Color) *InputField
SetAutocompleteListSelectedBackgroundColor sets the background of the selected ListItem.
func (*InputField) SetAutocompleteListSelectedTextColor ¶
func (i *InputField) SetAutocompleteListSelectedTextColor(color tcell.Color) *InputField
SetAutocompleteListSelectedTextColor sets the text color of the selected ListItem.
func (*InputField) SetAutocompleteListTextColor ¶
func (i *InputField) SetAutocompleteListTextColor(color tcell.Color) *InputField
SetAutocompleteListTextColor sets the text color of the ListItems.
func (*InputField) SetAutocompleteSuggestionTextColor ¶
func (i *InputField) SetAutocompleteSuggestionTextColor(color tcell.Color) *InputField
SetAutocompleteSuggestionTextColor sets the text color of the autocomplete suggestion in the input field.
func (*InputField) SetBackgroundColor ¶
func (i *InputField) SetBackgroundColor(color tcell.Color) FormItem
SetBackgroundColor sets the background color of the input field.
func (*InputField) SetChangedFunc ¶
func (i *InputField) SetChangedFunc(handler func(text string)) *InputField
SetChangedFunc sets a handler which is called whenever the text of the input field has changed. It receives the current text (after the change).
func (*InputField) SetCursorPosition ¶
func (i *InputField) SetCursorPosition(cursorPos int) *InputField
SetCursorPosition sets the cursor position.
func (*InputField) SetDoneFunc ¶
func (i *InputField) SetDoneFunc(handler func(key tcell.Key)) *InputField
SetDoneFunc sets a handler which is called when the user is done entering text.
func (*InputField) SetFieldBackgroundColor ¶
func (i *InputField) SetFieldBackgroundColor(color tcell.Color) FormItem
SetFieldBackgroundColor sets the background color of the input area.
func (*InputField) SetFieldBackgroundColorFocused ¶
func (i *InputField) SetFieldBackgroundColorFocused(color tcell.Color) FormItem
SetFieldBackgroundColorFocused sets the background color of the input area when focused.
func (*InputField) SetFieldNote ¶
func (i *InputField) SetFieldNote(note string) *InputField
SetFieldNote sets the text to show below the input field, e.g. when the input is invalid.
func (*InputField) SetFieldNoteTextColor ¶
func (i *InputField) SetFieldNoteTextColor(color tcell.Color) *InputField
SetFieldNoteTextColor sets the text color of the note.
func (*InputField) SetFieldTextColor ¶
func (i *InputField) SetFieldTextColor(color tcell.Color) FormItem
SetFieldTextColor sets the text color of the input area.
func (*InputField) SetFieldTextColorFocused ¶
func (i *InputField) SetFieldTextColorFocused(color tcell.Color) FormItem
SetFieldTextColorFocused sets the text color of the input area when focused.
func (*InputField) SetFieldWidth ¶
func (i *InputField) SetFieldWidth(width int) *InputField
SetFieldWidth sets the screen width of the input area. A value of 0 means extend as much as possible.
func (*InputField) SetFinishedFunc ¶
func (i *InputField) SetFinishedFunc(handler func(key tcell.Key)) FormItem
SetFinishedFunc sets a callback invoked when the user leaves this form item.
func (*InputField) SetLabel ¶
func (i *InputField) SetLabel(label string) *InputField
SetLabel sets the text to be displayed before the input area.
func (*InputField) SetLabelColor ¶
func (i *InputField) SetLabelColor(color tcell.Color) FormItem
SetLabelColor sets the color of the label.
func (*InputField) SetLabelColorFocused ¶
func (i *InputField) SetLabelColorFocused(color tcell.Color) FormItem
SetLabelColorFocused sets the color of the label when focused.
func (*InputField) SetLabelWidth ¶
func (i *InputField) SetLabelWidth(width int) FormItem
SetLabelWidth sets the screen width of the label. A value of 0 will cause the widget to use the width of the label string.
func (*InputField) SetMaskCharacter ¶
func (i *InputField) SetMaskCharacter(mask rune) *InputField
SetMaskCharacter sets a character that masks user input on a screen. A value of 0 disables masking.
func (*InputField) SetPlaceholder ¶
func (i *InputField) SetPlaceholder(text string) *InputField
SetPlaceholder sets the text to be displayed when the input text is empty.
func (*InputField) SetPlaceholderTextColor ¶
func (i *InputField) SetPlaceholderTextColor(color tcell.Color) *InputField
SetPlaceholderTextColor sets the text color of placeholder text.
func (*InputField) SetPlaceholderTextColorFocused ¶
func (i *InputField) SetPlaceholderTextColorFocused(color tcell.Color) *InputField
SetPlaceholderTextColorFocused sets the text color of placeholder text when focused.
func (*InputField) SetText ¶
func (i *InputField) SetText(text string) *InputField
SetText sets the current text of the input field.
type Key ¶
type Key struct {
Cancel []string
Select []string
Select2 []string
MoveUp []string
MoveUp2 []string
MoveDown []string
MoveDown2 []string
MoveLeft []string
MoveLeft2 []string
MoveRight []string
MoveRight2 []string
MoveFirst []string
MoveFirst2 []string
MoveLast []string
MoveLast2 []string
MovePreviousField []string
MoveNextField []string
MovePreviousPage []string
MoveNextPage []string
ShowContextMenu []string
}
Key defines the keyboard shortcuts of an application. Secondary shortcuts apply when not focusing a text input.
type List ¶
type List struct {
*Box
*ContextMenu
sync.RWMutex
// contains filtered or unexported fields
}
List displays rows of items, each of which can be selected.
func (*List) FindItems ¶
func (l *List) FindItems(mainSearch, secondarySearch string, mustContainBoth, ignoreCase bool) (indices []int)
FindItems searches the main and secondary texts for the given strings and returns a list of item indices in which those strings are found. One of the two search strings may be empty, it will then be ignored. Indices are always returned in ascending order.
If mustContainBoth is set to true, mainSearch must be contained in the main text AND secondarySearch must be contained in the secondary text. If it is false, only one of the two search strings must be contained.
Set ignoreCase to true for case-insensitive search.
func (*List) GetCurrentItem ¶
GetCurrentItem returns the currently selected list item, Returns nil if no item is selected.
func (*List) GetCurrentItemIndex ¶
GetCurrentItemIndex returns the index of the currently selected list item, starting at 0 for the first item and its struct.
func (*List) GetItem ¶
GetItem returns the ListItem at the given index. Returns nil when index is out of bounds.
func (*List) GetItemCount ¶
GetItemCount returns the number of items in the list.
func (*List) GetItemText ¶
GetItemText returns an item's texts (main and secondary). Panics if the index is out of range.
func (*List) GetOffset ¶
GetOffset returns the number of list items and columns by which the list is scrolled down/to the right.
func (*List) InputHandler ¶
InputHandler returns the handler for this widget.
func (*List) InsertItem ¶
InsertItem adds a new item to the list at the specified index. An index of 0 will insert the item at the beginning, an index of 1 before the second item, and so on. An index of GetItemCount() or higher will insert the item at the end of the list. Negative indices are also allowed: An index of -1 will insert the item at the end of the list, an index of -2 before the last item, and so on. An index of -GetItemCount()-1 or lower will insert the item at the beginning.
An item has a main text which will be highlighted when selected. It also has a secondary text which is shown underneath the main text (if it is set to visible) but which may remain empty.
The shortcut is a key binding. If the specified rune is entered, the item is selected immediately. Set to 0 for no binding.
The "selected" callback will be invoked when the user selects the item. You may provide nil if no such callback is needed or if all events are handled through the selected callback set with SetSelectedFunc().
The currently selected item will shift its position accordingly. If the list was previously empty, a "changed" event is fired because the new item becomes selected.
func (*List) MouseHandler ¶
func (l *List) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*List) RemoveItem ¶
RemoveItem removes the item with the given index (starting at 0) from the list. If a negative index is provided, items are referred to from the back (-1 = last item, -2 = second-to-last item, and so on). Out of range indices are clamped to the beginning/end, i.e. unless the list is empty, an item is always removed.
The currently selected item is shifted accordingly. If it is the one that is removed, a "changed" event is fired.
func (*List) SetChangedFunc ¶
SetChangedFunc sets the function which is called when the user navigates to a list item. The function receives the item's index in the list of items (starting with 0) and the list item.
This function is also called when the first item is added or when SetCurrentItem() is called.
func (*List) SetCurrentItem ¶
SetCurrentItem sets the currently selected item by its index, starting at 0 for the first item. If a negative index is provided, items are referred to from the back (-1 = last item, -2 = second-to-last item, and so on). Out of range indices are clamped to the beginning/end.
Calling this function triggers a "changed" event if the selection changes.
func (*List) SetDoneFunc ¶
SetDoneFunc sets a function which is called when the user presses the Escape key.
func (*List) SetHighlightFullLine ¶
SetHighlightFullLine sets a flag which determines whether the colored background of selected items spans the entire width of the view. If set to true, the highlight spans the entire view. If set to false, only the text of the selected item from beginning to end is highlighted.
func (*List) SetHover ¶
SetHover sets the flag that determines whether hovering over an item will highlight it (without triggering callbacks set with SetSelectedFunc).
func (*List) SetIndicators ¶
func (l *List) SetIndicators(selectedPrefix, selectedSuffix, unselectedPrefix, unselectedSuffix string) *List
SetIndicators is used to set prefix and suffix indicators for selected and unselected items.
func (*List) SetItemEnabled ¶
SetItemEnabled sets whether an item is selectable. Panics if the index is out of range.
func (*List) SetItemText ¶
SetItemText sets an item's main and secondary text. Panics if the index is out of range.
func (*List) SetMainTextColor ¶
SetMainTextColor sets the color of the items' main text.
func (*List) SetOffset ¶
SetOffset sets the number of list items and columns by which the list is scrolled down/to the right.
func (*List) SetScrollBarColor ¶
SetScrollBarColor sets the color of the scroll bar.
func (*List) SetScrollBarVisibility ¶
func (l *List) SetScrollBarVisibility(visibility ScrollBarVisibility) *List
SetScrollBarVisibility specifies the display of the scroll bar.
func (*List) SetSecondaryTextColor ¶
SetSecondaryTextColor sets the color of the items' secondary text.
func (*List) SetSelectedAlwaysCentered ¶
SetSelectedAlwaysCentered sets a flag which determines whether the currently selected list item must remain centered when scrolling.
func (*List) SetSelectedAlwaysVisible ¶
SetSelectedAlwaysVisible sets a flag which determines whether the currently selected list item must remain visible when scrolling.
func (*List) SetSelectedBackgroundColor ¶
SetSelectedBackgroundColor sets the background color of selected items.
func (*List) SetSelectedFocusOnly ¶
SetSelectedFocusOnly sets a flag which determines when the currently selected list item is highlighted. If set to true, selected items are only highlighted when the list has focus. If set to false, they are always highlighted.
func (*List) SetSelectedFunc ¶
SetSelectedFunc sets the function which is called when the user selects a list item by pressing Enter on the current selection. The function receives the item's index in the list of items (starting with 0) and its struct.
func (*List) SetSelectedTextAttributes ¶
SetSelectedTextAttributes sets the style attributes of selected items.
func (*List) SetSelectedTextColor ¶
SetSelectedTextColor sets the text color of selected items.
func (*List) SetShortcutColor ¶
SetShortcutColor sets the color of the items' shortcut.
func (*List) SetWrapAround ¶
SetWrapAround sets the flag that determines whether navigating the list will wrap around. That is, navigating downwards on the last item will move the selection to the first item (similarly in the other direction). If set to false, the selection won't change when navigating downwards on the last item or navigating upwards on the first item.
func (*List) ShowSecondaryText ¶
ShowSecondaryText determines whether or not to show secondary item texts.
func (*List) Transform ¶
func (l *List) Transform(tr Transformation)
Transform modifies the current selection.
type ListItem ¶
ListItem represents an item in a List.
func NewListItem ¶
NewListItem returns a new item for a list.
func (*ListItem) GetMainBytes ¶
GetMainBytes returns the item's main text.
func (*ListItem) GetMainText ¶
GetMainText returns the item's main text.
func (*ListItem) GetReference ¶
func (l *ListItem) GetReference() interface{}
GetReference returns the item's reference object.
func (*ListItem) GetSecondaryBytes ¶
GetSecondaryBytes returns the item's secondary text.
func (*ListItem) GetSecondaryText ¶
GetSecondaryText returns the item's secondary text.
func (*ListItem) GetShortcut ¶
GetShortcut returns the ListItem's shortcut.
func (*ListItem) SetMainBytes ¶
SetMainBytes sets the main text of the list item.
func (*ListItem) SetMainText ¶
SetMainText sets the main text of the list item.
func (*ListItem) SetReference ¶
SetReference allows you to store a reference of any type in the item
func (*ListItem) SetSecondaryBytes ¶
SetSecondaryBytes sets a secondary text to be shown underneath the main text.
func (*ListItem) SetSecondaryText ¶
SetSecondaryText sets a secondary text to be shown underneath the main text.
func (*ListItem) SetSelectedFunc ¶
SetSelectedFunc sets a function which is called when the ListItem is selected.
func (*ListItem) SetShortcut ¶
SetShortcut sets the key to select the ListItem directly, 0 if there is no shortcut.
type MenuBar ¶
func NewMenuBar ¶
func NewMenuBar() *MenuBar
func (*MenuBar) InputHandler ¶
func (*MenuBar) MouseHandler ¶
func (menuBar *MenuBar) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
type MenuItem ¶
type MenuItem struct {
*Box
Title string
SubItems []*MenuItem
// contains filtered or unexported fields
}
func NewMenuItem ¶
func (*MenuItem) SetOnClick ¶
type MessageDialog ¶
type MessageDialog struct {
*Box
// contains filtered or unexported fields
}
MessageDialog represents message dialog widget.
func NewMessageDialog ¶
func NewMessageDialog(dtype int) *MessageDialog
NewMessageDialog returns a new message dialog widget.
func (*MessageDialog) Draw ¶
func (d *MessageDialog) Draw(screen tcell.Screen)
Draw draws this widget onto the screen.
func (*MessageDialog) Focus ¶
func (d *MessageDialog) Focus(delegate func(w Widget))
Focus is called when this widget receives focus.
func (*MessageDialog) GetBackgroundColor ¶
func (d *MessageDialog) GetBackgroundColor() tcell.Color
GetBackgroundColor returns dialog background color.
func (*MessageDialog) HasFocus ¶
func (d *MessageDialog) HasFocus() bool
HasFocus returns whether or not this widget has focus.
func (*MessageDialog) InputHandler ¶
func (d *MessageDialog) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
InputHandler returns input handler function for this widget.
func (*MessageDialog) MouseHandler ¶
func (d *MessageDialog) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*MessageDialog) SetBackgroundColor ¶
func (d *MessageDialog) SetBackgroundColor(color tcell.Color) *MessageDialog
SetBackgroundColor sets dialog background color.
func (*MessageDialog) SetDoneFunc ¶
func (d *MessageDialog) SetDoneFunc(handler func()) *MessageDialog
SetDoneFunc sets callback function for when user clicked on the button or presses "enter" or "esc".
func (*MessageDialog) SetMessage ¶
func (d *MessageDialog) SetMessage(message string) *MessageDialog
SetMessage sets the dialog message to display.
func (*MessageDialog) SetRect ¶
func (d *MessageDialog) SetRect(x, y, width, height int) Widget
SetRect sets rect for this widget.
func (*MessageDialog) SetTextColor ¶
func (d *MessageDialog) SetTextColor(color tcell.Color) *MessageDialog
SetTextColor sets dialog's message text color.
func (*MessageDialog) SetTitle ¶
func (d *MessageDialog) SetTitle(title string) *MessageDialog
SetTitle sets dialog title.
func (*MessageDialog) SetType ¶
func (d *MessageDialog) SetType(dtype int) *MessageDialog
SetType sets dialog type to info or error.
type Modal ¶
Modal is a centered message window used to inform the user or prompt them for an immediate decision. It needs to have at least one button (added via AddButtons) or it will never disappear. You may change the title and appearance of the window by modifying the Frame returned by GetFrame. You may include additional elements within the window by modifying the Form returned by GetForm.
func (*Modal) AddButtons ¶
AddButtons adds buttons to the window. There must be at least one button and a "done" handler so the window can be closed again.
func (*Modal) ClearButtons ¶
func (m *Modal) ClearButtons()
ClearButtons removes all buttons from the window.
func (*Modal) GetForm ¶
GetForm returns the Form embedded in the window. The returned Form may be modified to include additional elements (e.g. AddInputField, AddFormItem).
func (*Modal) MouseHandler ¶
func (m *Modal) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*Modal) SetBackgroundColor ¶
SetBackgroundColor sets the color of the Modal Frame background.
func (*Modal) SetButtonBackgroundColor ¶
SetButtonBackgroundColor sets the background color of the buttons.
func (*Modal) SetButtonTextColor ¶
SetButtonTextColor sets the color of the button texts.
func (*Modal) SetButtonsAlign ¶
SetButtonsAlign sets the horizontal alignment of the buttons. This must be either AlignLeft, AlignCenter (the default), or AlignRight.
func (*Modal) SetDoneFunc ¶
SetDoneFunc sets a handler which is called when one of the buttons was pressed. It receives the index of the button as well as its label text. The handler is also called when the user presses the Escape key. The index will then be negative and the label text an empty string.
func (*Modal) SetText ¶
SetText sets the message text of the window. The text may contain line breaks. Note that words are wrapped, too, based on the final size of the window.
func (*Modal) SetTextAlign ¶
SetTextAlign sets the horizontal alignment of the text. This must be either AlignLeft, AlignCenter (the default), or AlignRight.
type MouseAction ¶
type MouseAction int16
MouseAction indicates one of the actions the mouse is logically doing.
const ( MouseMove MouseAction = iota MouseLeftDown MouseLeftUp MouseLeftClick MouseLeftDoubleClick MouseMiddleDown MouseMiddleUp MouseMiddleClick MouseMiddleDoubleClick MouseRightDown MouseRightUp MouseRightClick MouseRightDoubleClick MouseScrollUp MouseScrollDown MouseScrollLeft MouseScrollRight )
Available mouse actions.
type Pages
deprecated
type Pages struct {
*Panels
}
Pages is a wrapper around Panels.
Deprecated: This type is provided for backwards compatibility. Developers should use Panels instead.
func (*Pages) AddAndSwitchToPage ¶
AddAndSwitchToPage calls Add(), then SwitchTo() on that newly added panel.
func (*Pages) GetFrontPage ¶
GetFrontPage returns the front-most visible panel.
func (*Pages) GetPageCount ¶
GetPageCount returns the number of panels currently stored in this object.
func (*Pages) RemovePage ¶
RemovePage removes the panel with the given name.
func (*Pages) SwitchToPage ¶
SwitchToPage sets a panel's visibility to "true" and all other panels' visibility to "false".
type Panels ¶
Panels is a container for other widgets often used as the application's root widget. It allows to easily switch the visibility of the contained widgets.
func (*Panels) AddPanel ¶
AddPanel adds a new panel with the given name and widget. If there was previously a panel with the same name, it is overwritten. Leaving the name empty may cause conflicts in other functions so always specify a non-empty name.
Visible panels will be drawn in the order they were added (unless that order was changed in one of the other functions). If "resize" is set to true, the widget will be set to the size available to the Panels widget whenever the panels are drawn.
func (*Panels) GetFrontPanel ¶
GetFrontPanel returns the front-most visible panel. If there are no visible panels, ("", nil) is returned.
func (*Panels) GetPanelCount ¶
GetPanelCount returns the number of panels currently stored in this object.
func (*Panels) HasPanel ¶
HasPanel returns true if a panel with the given name exists in this object.
func (*Panels) MouseHandler ¶
func (p *Panels) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*Panels) RemovePanel ¶
RemovePanel removes the panel with the given name. If that panel was the only visible panel, visibility is assigned to the last panel.
func (*Panels) SendToBack ¶
SendToBack changes the order of the panels such that the panel with the given name comes first, causing it to be drawn first with the next update (if visible).
func (*Panels) SendToFront ¶
SendToFront changes the order of the panels such that the panel with the given name comes last, causing it to be drawn last with the next update (if visible).
func (*Panels) SetChangedFunc ¶
SetChangedFunc sets a handler which is called whenever the visibility or the order of any visible panels changes. This can be used to redraw the panels.
func (*Panels) SetCurrentPanel ¶
SetCurrentPanel sets a panel's visibility to "true" and all other panels' visibility to "false".
type PercentageModeGauge ¶
PercentageModeGauge represents percentage mode gauge permitive.
func NewPercentageModeGauge ¶
func NewPercentageModeGauge() *PercentageModeGauge
NewPercentageModeGauge returns new percentage mode gauge permitive.
func (*PercentageModeGauge) Draw ¶
func (g *PercentageModeGauge) Draw(screen tcell.Screen)
Draw draws this widget onto the screen.
func (*PercentageModeGauge) Focus ¶
func (g *PercentageModeGauge) Focus(delegate func(w Widget))
Focus is called when this widget receives focus.
func (*PercentageModeGauge) GetMaxValue ¶
func (g *PercentageModeGauge) GetMaxValue() int
GetMaxValue returns maximum allows value for the gauge.
func (*PercentageModeGauge) GetRect ¶
func (g *PercentageModeGauge) GetRect() (int, int, int, int)
GetRect return widget current rect.
func (*PercentageModeGauge) GetValue ¶
func (g *PercentageModeGauge) GetValue() int
GetValue returns current gauge value.
func (*PercentageModeGauge) HasFocus ¶
func (g *PercentageModeGauge) HasFocus() bool
HasFocus returns whether or not this widget has focus.
func (*PercentageModeGauge) Reset ¶
func (g *PercentageModeGauge) Reset()
Reset resets the gauge counter (set to 0).
func (*PercentageModeGauge) SetMaxValue ¶
func (g *PercentageModeGauge) SetMaxValue(value int) *PercentageModeGauge
SetMaxValue set maximum allows value for the gauge.
func (*PercentageModeGauge) SetPgBgColor ¶
func (g *PercentageModeGauge) SetPgBgColor(color tcell.Color) *PercentageModeGauge
SetPgBgColor sets progress block background color.
func (*PercentageModeGauge) SetRect ¶
func (g *PercentageModeGauge) SetRect(x, y, width, height int) Widget
SetRect sets rect for this widget.
func (*PercentageModeGauge) SetValue ¶
func (g *PercentageModeGauge) SetValue(value int) *PercentageModeGauge
SetValue update the gauge progress.
type Plot ¶
type Plot struct {
*Box
// contains filtered or unexported fields
}
Plot represents a plot widget used for different charts.
func (*Plot) GetPlotRect ¶
GetPlotRect returns the rect for the inner part of the plot, ie not including axes.
func (*Plot) SetAxesColor ¶
SetAxesColor sets axes x and y lines color.
func (*Plot) SetAxesLabelColor ¶
SetAxesLabelColor sets axes x and y label color.
func (*Plot) SetDotMarkerRune ¶
SetDotMarkerRune sets dot marker rune.
func (*Plot) SetDrawAxes ¶
SetDrawAxes set true in order to draw axes to screen.
func (*Plot) SetDrawXAxisLabel ¶
SetDrawXAxisLabel set true in order to draw x axis label to screen.
func (*Plot) SetDrawYAxisLabel ¶
SetDrawYAxisLabel set true in order to draw y axis label to screen.
func (*Plot) SetLineColor ¶
SetLineColor sets chart line color.
func (*Plot) SetPlotType ¶
SetPlotType sets plot type (linechart or scatter).
func (*Plot) SetXAxisLabelFunc ¶
SetXAxisLabelFunc sets x axis label function.
func (*Plot) SetYAxisAutoScaleMax ¶
SetYAxisAutoScaleMax enables YAxix max value autoscale.
func (*Plot) SetYAxisAutoScaleMin ¶
SetYAxisAutoScaleMin enables YAxis min value autoscale.
func (*Plot) SetYAxisLabelDataType ¶
func (plot *Plot) SetYAxisLabelDataType(dataType PlotYAxisLabelDataType) *Plot
SetYAxisLabelDataType sets Y axis label data type (integer or float).
type PlotYAxisLabelDataType ¶
type PlotYAxisLabelDataType uint
PlotYAxisLabelDataType represents plot y axis type (integer or float).
const ( PlotYAxisLabelDataInt PlotYAxisLabelDataType = iota PlotYAxisLabelDataFloat )
type ProgressBar ¶
ProgressBar indicates the progress of an operation.
func (*ProgressBar) AddProgress ¶
func (p *ProgressBar) AddProgress(progress int)
AddProgress adds to the current progress.
func (*ProgressBar) Complete ¶
func (p *ProgressBar) Complete() bool
Complete returns whether the progress bar has been filled.
func (*ProgressBar) Draw ¶
func (p *ProgressBar) Draw(screen tcell.Screen)
Draw draws this widget onto the screen.
func (*ProgressBar) GetMax ¶
func (p *ProgressBar) GetMax() int
GetMax returns the progress required to fill the bar.
func (*ProgressBar) GetProgress ¶
func (p *ProgressBar) GetProgress() int
GetProgress gets the current progress.
func (*ProgressBar) SetEmptyColor ¶
func (p *ProgressBar) SetEmptyColor(empty tcell.Color) *ProgressBar
SetEmptyColor sets the color of the empty area of the progress bar.
func (*ProgressBar) SetEmptyRune ¶
func (p *ProgressBar) SetEmptyRune(empty rune) *ProgressBar
SetEmptyRune sets the rune used for the empty area of the progress bar.
func (*ProgressBar) SetFilledColor ¶
func (p *ProgressBar) SetFilledColor(filled tcell.Color) *ProgressBar
SetFilledColor sets the color of the filled area of the progress bar.
func (*ProgressBar) SetFilledRune ¶
func (p *ProgressBar) SetFilledRune(filled rune) *ProgressBar
SetFilledRune sets the rune used for the filled area of the progress bar.
func (*ProgressBar) SetMax ¶
func (p *ProgressBar) SetMax(max int) *ProgressBar
SetMax sets the progress required to fill the bar.
func (*ProgressBar) SetProgress ¶
func (p *ProgressBar) SetProgress(progress int) *ProgressBar
SetProgress sets the current progress.
func (*ProgressBar) SetVertical ¶
func (p *ProgressBar) SetVertical(vertical bool) *ProgressBar
SetVertical sets the direction of the progress bar.
type ScrollBarVisibility ¶
type ScrollBarVisibility int
ScrollBarVisibility specifies the display of a scroll bar.
const ( // ScrollBarNever never shows a scroll bar. ScrollBarNever ScrollBarVisibility = iota // ScrollBarAuto shows a scroll bar when there are items offscreen. ScrollBarAuto // ScrollBarAlways always shows a scroll bar. ScrollBarAlways )
type Slider ¶
type Slider struct {
*ProgressBar
sync.RWMutex
// contains filtered or unexported fields
}
Slider is a progress bar which may be modified via keyboard and mouse.
func (*Slider) GetFieldHeight ¶
GetFieldHeight returns the height of the field.
func (*Slider) GetFieldWidth ¶
GetFieldWidth returns this widget's field width.
func (*Slider) InputHandler ¶
InputHandler returns the handler for this widget.
func (*Slider) MouseHandler ¶
func (s *Slider) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*Slider) SetBackgroundColor ¶
SetBackgroundColor sets the background color of the slider.
func (*Slider) SetChangedFunc ¶
SetChangedFunc sets a handler which is called when the value of this slider was changed by the user. The handler function receives the new value.
func (*Slider) SetDoneFunc ¶
SetDoneFunc sets a handler which is called when the user is done using the slider. The callback function is provided with the key that was pressed, which is one of the following:
- KeyEscape: Abort text input.
- KeyTab: Move to the next field.
- KeyBacktab: Move to the previous field.
func (*Slider) SetFieldBackgroundColor ¶
SetFieldBackgroundColor sets the background color of the input area.
func (*Slider) SetFieldBackgroundColorFocused ¶
SetFieldBackgroundColorFocused sets the background color of the input area when focused.
func (*Slider) SetFieldTextColor ¶
SetFieldTextColor sets the text color of the input area.
func (*Slider) SetFieldTextColorFocused ¶
SetFieldTextColorFocused sets the text color of the input area when focused.
func (*Slider) SetFinishedFunc ¶
SetFinishedFunc sets a callback invoked when the user leaves this form item.
func (*Slider) SetIncrement ¶
SetIncrement sets the amount the slider is incremented by when modified via keyboard.
func (*Slider) SetLabelColor ¶
SetLabelColor sets the color of the label.
func (*Slider) SetLabelColorFocused ¶
SetLabelColorFocused sets the color of the label when focused.
func (*Slider) SetLabelWidth ¶
SetLabelWidth sets the screen width of the label. A value of 0 will cause the widget to use the width of the label string.
type Sparkline ¶
type Sparkline struct {
*Box
// contains filtered or unexported fields
}
Sparkline represents a sparkline widgets.
func (*Sparkline) SetDataTitle ¶
SetDataTitle sets sparkline data title.
func (*Sparkline) SetDataTitleColor ¶
SetDataTitleColor sets sparkline data title color.
func (*Sparkline) SetLineColor ¶
SetLineColor sets sparkline line color.
type Spinner ¶
type Spinner struct {
*Box
// contains filtered or unexported fields
}
Spinner represents a spinner widget.
func (*Spinner) SetCustomStyle ¶
SetCustomStyle sets a list of runes as custom frames to show as the spinner.
func (*Spinner) SetStyle ¶
func (s *Spinner) SetStyle(style SpinnerStyle) *Spinner
SetStyle sets the spinner style.
type SpinnerStyle ¶
type SpinnerStyle int
SpinnerStyle spinner style.
const ( SpinnerDotsCircling SpinnerStyle = iota SpinnerDotsUpDown SpinnerBounce SpinnerLine SpinnerCircleQuarters SpinnerSquareCorners SpinnerCircleHalves SpinnerCorners SpinnerArrows SpinnerHamburger SpinnerStack SpinnerGrowHorizontal SpinnerGrowVertical SpinnerStar SpinnerBoxBounce )
type SubMenu ¶
func NewSubMenu ¶
func (*SubMenu) MouseHandler ¶
func (subMenu *SubMenu) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
type TabbedPanels ¶
type TabbedPanels struct {
*Flex
Switcher *TextView
sync.RWMutex
// contains filtered or unexported fields
}
TabbedPanels is a tabbed container for other widgets. The tab switcher may be positioned vertically or horizontally, before or after the content.
func NewTabbedPanels ¶
func NewTabbedPanels() *TabbedPanels
NewTabbedPanels returns a new TabbedPanels object.
func (*TabbedPanels) AddTab ¶
func (t *TabbedPanels) AddTab(name, label string, item Widget)
AddTab adds a new tab. Tab names should consist only of letters, numbers and spaces.
func (*TabbedPanels) Draw ¶
func (t *TabbedPanels) Draw(screen tcell.Screen)
Draw draws this widget onto the screen.
func (*TabbedPanels) GetCurrentTab ¶
func (t *TabbedPanels) GetCurrentTab() string
GetCurrentTab returns the currently visible tab.
func (*TabbedPanels) HasTab ¶
func (t *TabbedPanels) HasTab(name string) bool
HasTab returns true if a tab with the given name exists in this object.
func (*TabbedPanels) InputHandler ¶
func (t *TabbedPanels) InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
InputHandler returns the handler for this widget.
func (*TabbedPanels) MouseHandler ¶
func (t *TabbedPanels) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*TabbedPanels) RemoveTab ¶
func (t *TabbedPanels) RemoveTab(name string)
RemoveTab removes a tab.
func (*TabbedPanels) SetChangedFunc ¶
func (t *TabbedPanels) SetChangedFunc(handler func()) *TabbedPanels
SetChangedFunc sets a handler which is called whenever a tab is added, selected, reordered or removed.
func (*TabbedPanels) SetCurrentTab ¶
func (t *TabbedPanels) SetCurrentTab(name string) *TabbedPanels
SetCurrentTab sets the currently visible tab.
func (*TabbedPanels) SetTabBackgroundColor ¶
func (t *TabbedPanels) SetTabBackgroundColor(color tcell.Color) *TabbedPanels
SetTabBackgroundColor sets the background color of the tab.
func (*TabbedPanels) SetTabBackgroundColorFocused ¶
func (t *TabbedPanels) SetTabBackgroundColorFocused(color tcell.Color) *TabbedPanels
SetTabBackgroundColorFocused sets the background color of the tab when the tab is in focus.
func (*TabbedPanels) SetTabLabel ¶
func (t *TabbedPanels) SetTabLabel(name, label string) *TabbedPanels
SetTabLabel sets the label of a tab.
func (*TabbedPanels) SetTabSwitcherAfterContent ¶
func (t *TabbedPanels) SetTabSwitcherAfterContent(after bool) *TabbedPanels
SetTabSwitcherAfterContent sets whether the tab switcher is positioned after content.
func (*TabbedPanels) SetTabSwitcherDivider ¶
func (t *TabbedPanels) SetTabSwitcherDivider(start, mid, end string) *TabbedPanels
SetTabSwitcherDivider sets the tab switcher divider text. Color tags are supported.
func (*TabbedPanels) SetTabSwitcherHeight ¶
func (t *TabbedPanels) SetTabSwitcherHeight(height int) *TabbedPanels
SetTabSwitcherHeight sets the tab switcher height. This setting only applies when rendering horizontally. A value of 0 (the default) indicates the height should automatically adjust to fit all of the tab labels.
func (*TabbedPanels) SetTabSwitcherVertical ¶
func (t *TabbedPanels) SetTabSwitcherVertical(vertical bool) *TabbedPanels
SetTabSwitcherVertical sets the orientation of the tab switcher.
func (*TabbedPanels) SetTabTextColor ¶
func (t *TabbedPanels) SetTabTextColor(color tcell.Color) *TabbedPanels
SetTabTextColor sets the color of the tab text.
func (*TabbedPanels) SetTabTextColorFocused ¶
func (t *TabbedPanels) SetTabTextColorFocused(color tcell.Color) *TabbedPanels
SetTabTextColorFocused sets the color of the tab text when the tab is in focus.
type Table ¶
Table visualizes two-dimensional data consisting of rows and columns. Each Table cell is defined via SetCell() by the TableCell type. They can be added dynamically to the table and changed any time.
Each row of the table must have the same number of columns when it is drawn or navigated. This isn't strictly enforced, however you may encounter issues when navigating a table with rows of varied column sizes.
The most compact display of a table is without borders. Each row will then occupy one row on screen and columns are separated by the rune defined via SetSeparator() (a space character by default).
When borders are turned on (via SetBorders()), each table cell is surrounded by lines. Therefore one table row will require two rows on screen.
Columns will use as much horizontal space as they need. You can constrain their size with the MaxWidth parameter of the TableCell type.
Fixed Columns ¶
You can define fixed rows and rolumns via SetFixed(). They will always stay in their place, even when the table is scrolled. Fixed rows are always the top rows. Fixed columns are always the leftmost columns.
Selections ¶
You can call SetSelectable() to set columns and/or rows to "selectable". If the flag is set only for columns, entire columns can be selected by the user. If it is set only for rows, entire rows can be selected. If both flags are set, individual cells can be selected. The "selected" handler set via SetSelectedFunc() is invoked when the user presses Enter on a selection.
Navigation ¶
If the table extends beyond the available space, it can be navigated with key bindings similar to Vim:
- h, left arrow: Move left by one column.
- l, right arrow: Move right by one column.
- j, down arrow: Move down by one row.
- k, up arrow: Move up by one row.
- g, home: Move to the top.
- G, end: Move to the bottom.
- Ctrl-F, page down: Move down by one page.
- Ctrl-B, page up: Move up by one page.
When there is no selection, this affects the entire table (except for fixed rows and columns). When there is a selection, the user moves the selection. The class will attempt to keep the selection from moving out of the screen.
Use SetInputCapture() to override or modify keyboard input.
func (*Table) GetCell ¶
GetCell returns the contents of the cell at the specified position. A valid TableCell object is always returned but it will be uninitialized if the cell was not previously set. Such an uninitialized object will not automatically be inserted. Therefore, repeated calls to this function may return different pointers for uninitialized cells.
func (*Table) GetColumnCount ¶
GetColumnCount returns the (maximum) number of columns in the table.
func (*Table) GetOffset ¶
GetOffset returns the current row and column offset. This indicates how many rows and columns the table is scrolled down and to the right.
func (*Table) GetRowCount ¶
GetRowCount returns the number of rows in the table.
func (*Table) GetSelectable ¶
GetSelectable returns what can be selected in a table. Refer to SetSelectable() for details.
func (*Table) GetSelection ¶
GetSelection returns the position of the current selection. If entire rows are selected, the column index is undefined. Likewise for entire columns.
func (*Table) InputHandler ¶
InputHandler returns the handler for this widget.
func (*Table) InsertColumn ¶
InsertColumn inserts a column before the column with the given index. Cells in the given column and to its right will be shifted to the right by one column. Rows that have fewer initialized cells than "column" will remain unchanged.
func (*Table) InsertRow ¶
InsertRow inserts a row before the row with the given index. Cells on the given row and below will be shifted to the bottom by one row. If "row" is equal or larger than the current number of rows, this function has no effect.
func (*Table) MouseHandler ¶
func (t *Table) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*Table) RemoveColumn ¶
RemoveColumn removes the column at the given position from the table. If there is no such column, this has no effect.
func (*Table) RemoveRow ¶
RemoveRow removes the row at the given position from the table. If there is no such row, this has no effect.
func (*Table) ScrollToBeginning ¶
func (t *Table) ScrollToBeginning()
ScrollToBeginning scrolls the table to the beginning to that the top left corner of the table is shown. Note that this position may be corrected if there is a selection.
func (*Table) ScrollToEnd ¶
func (t *Table) ScrollToEnd()
ScrollToEnd scrolls the table to the beginning to that the bottom left corner of the table is shown. Adding more rows to the table will cause it to automatically scroll with the new data. Note that this position may be corrected if there is a selection.
func (*Table) Select ¶
Select sets the selected cell. Depending on the selection settings specified via SetSelectable(), this may be an entire row or column, or even ignored completely. The "selection changed" event is fired if such a callback is available (even if the selection ends up being the same as before and even if cells are not selectable).
func (*Table) SetBorders ¶
SetBorders sets whether or not each cell in the table is surrounded by a border.
func (*Table) SetBordersColor ¶
SetBordersColor sets the color of the cell borders.
func (*Table) SetCell ¶
SetCell sets the content of a cell the specified position. It is ok to directly instantiate a TableCell object. If the cell has content, at least the Text and Color fields should be set.
Note that setting cells in previously unknown rows and columns will automatically extend the internal table representation, e.g. starting with a row of 100,000 will immediately create 100,000 empty rows.
To avoid unnecessary garbage collection, fill columns from left to right.
func (*Table) SetCellSimple ¶
SetCellSimple calls SetCell() with the given text, left-aligned, in white.
func (*Table) SetDoneFunc ¶
SetDoneFunc sets a handler which is called whenever the user presses the Escape, Tab, or Backtab key. If nothing is selected, it is also called when user presses the Enter key (because pressing Enter on a selection triggers the "selected" handler set via SetSelectedFunc()).
func (*Table) SetEvaluateAllRows ¶
SetEvaluateAllRows sets a flag which determines the rows to be evaluated when calculating the widths of the table's columns. When false, only visible rows are evaluated. When true, all rows in the table are evaluated.
Set this flag to true to avoid shifting column widths when the table is scrolled. (May be slower for large tables.)
func (*Table) SetFixed ¶
SetFixed sets the number of fixed rows and columns which are always visible even when the rest of the cells are scrolled out of view. Rows are always the top-most ones. Columns are always the left-most ones.
func (*Table) SetOffset ¶
SetOffset sets how many rows and columns should be skipped when drawing the table. This is useful for large tables that do not fit on the screen. Navigating a selection can change these values.
Fixed rows and columns are never skipped.
func (*Table) SetScrollBarColor ¶
SetScrollBarColor sets the color of the scroll bar.
func (*Table) SetScrollBarVisibility ¶
func (t *Table) SetScrollBarVisibility(visibility ScrollBarVisibility) *Table
SetScrollBarVisibility specifies the display of the scroll bar.
func (*Table) SetSelectable ¶
SetSelectable sets the flags which determine what can be selected in a table. There are three selection modi:
- rows = false, columns = false: Nothing can be selected.
- rows = true, columns = false: Rows can be selected.
- rows = false, columns = true: Columns can be selected.
- rows = true, columns = true: Individual cells can be selected.
func (*Table) SetSelectedFunc ¶
SetSelectedFunc sets a handler which is called whenever the user presses the Enter key on a selected cell/row/column. The handler receives the position of the selection and its cell contents. If entire rows are selected, the column index is undefined. Likewise for entire columns.
func (*Table) SetSelectedStyle ¶
func (t *Table) SetSelectedStyle(foregroundColor, backgroundColor tcell.Color, attributes tcell.AttrMask) *Table
SetSelectedStyle sets a specific style for selected cells. If no such style is set, per default, selected cells are inverted (i.e. their foreground and background colors are swapped).
To reset a previous setting to its default, make the following call:
table.SetSelectedStyle(tcell.ColorDefault, tcell.ColorDefault, 0)
func (*Table) SetSelectionChangedFunc ¶
SetSelectionChangedFunc sets a handler which is called whenever the current selection changes. The handler receives the position of the new selection. If entire rows are selected, the column index is undefined. Likewise for entire columns.
func (*Table) SetSeparator ¶
SetSeparator sets the character used to fill the space between two neighboring cells. This is a space character ' ' per default but you may want to set it to Borders.Vertical (or any other rune) if the column separation should be more visible. If cell borders are activated, this is ignored.
Separators have the same color as borders.
func (*Table) SetSortClicked ¶
SetSortClicked sets a flag which determines whether the table is sorted when a fixed row is clicked. This flag is enabled by default.
func (*Table) SetSortFunc ¶
SetSortFunc sets the sorting function used for the table. When unset, a case-sensitive string comparison is used.
type TableCell ¶
type TableCell struct {
// The reference object.
Reference interface{}
// The text to be displayed in the table cell.
Text []byte
// The alignment of the cell text. One of AlignLeft (default), AlignCenter,
// or AlignRight.
Align int
// The maximum width of the cell in screen space. This is used to give a
// column a maximum width. Any cell text whose screen width exceeds this width
// is cut off. Set to 0 if there is no maximum width.
MaxWidth int
// If the total table width is less than the available width, this value is
// used to add extra width to a column. See SetExpansion() for details.
Expansion int
// The color of the cell text.
Color tcell.Color
// The background color of the cell.
BackgroundColor tcell.Color
// The style attributes of the cell.
Attributes tcell.AttrMask
// If set to true, this cell cannot be selected.
NotSelectable bool
sync.RWMutex
// contains filtered or unexported fields
}
TableCell represents one cell inside a Table. You can instantiate this type directly but all colors (background and text) will be set to their default which is black.
func NewTableCell ¶
NewTableCell returns a new table cell with sensible defaults. That is, left aligned text with the primary text color (see Styles) and a transparent background (using the background of the Table).
func (*TableCell) GetLastPosition ¶
GetLastPosition returns the position of the table cell the last time it was drawn on screen. If the cell is not on screen, the return values are undefined.
Because the Table class will attempt to keep selected cells on screen, this function is most useful in response to a "selected" event (see SetSelectedFunc()) or a "selectionChanged" event (see SetSelectionChangedFunc()).
func (*TableCell) GetReference ¶
func (c *TableCell) GetReference() interface{}
GetReference returns this cell's reference object.
func (*TableCell) SetAlign ¶
SetAlign sets the cell's text alignment, one of AlignLeft, AlignCenter, or AlignRight.
func (*TableCell) SetAttributes ¶
SetAttributes sets the cell's text attributes. You can combine different attributes using bitmask operations:
cell.SetAttributes(tcell.AttrUnderline | tcell.AttrBold)
func (*TableCell) SetBackgroundColor ¶
SetBackgroundColor sets the cell's background color. Set to tcell.ColorDefault to use the table's background color.
func (*TableCell) SetExpansion ¶
SetExpansion sets the value by which the column of this cell expands if the available width for the table is more than the table width (prior to applying this expansion value). This is a proportional value. The amount of unused horizontal space is divided into widths to be added to each column. How much extra width a column receives depends on the expansion value: A value of 0 (the default) will not cause the column to increase in width. Other values are proportional, e.g. a value of 2 will cause a column to grow by twice the amount of a column with a value of 1.
Since this value affects an entire column, the maximum over all visible cells in that column is used.
This function panics if a negative value is provided.
func (*TableCell) SetMaxWidth ¶
SetMaxWidth sets maximum width of the cell in screen space. This is used to give a column a maximum width. Any cell text whose screen width exceeds this width is cut off. Set to 0 if there is no maximum width.
func (*TableCell) SetReference ¶
SetReference allows you to store a reference of any type in this cell. This will allow you to establish a mapping between the cell and your actual data.
func (*TableCell) SetSelectable ¶
SetSelectable sets whether or not this cell can be selected by the user.
func (*TableCell) SetStyle ¶
SetStyle sets the cell's style (foreground color, background color, and attributes) all at once.
type TextView ¶
TextView is a box which displays text. It implements the io.Writer interface so you can stream text to it. This does not trigger a redraw automatically but if a handler is installed via SetChangedFunc(), you can cause it to be redrawn. (See SetChangedFunc() for more details.)
Navigation ¶
If the text view is scrollable (the default), text is kept in a buffer which may be larger than the screen and can be navigated similarly to Vim:
- h, left arrow: Move left.
- l, right arrow: Move right.
- j, down arrow: Move down.
- k, up arrow: Move up.
- g, home: Move to the top.
- G, end: Move to the bottom.
- Ctrl-F, page down: Move down by one page.
- Ctrl-B, page up: Move up by one page.
If the text is not scrollable, any text above the top visible line is discarded.
Use SetInputCapture() to override or modify keyboard input.
Colors ¶
If dynamic colors are enabled via SetDynamicColors(), text color can be changed dynamically by embedding color strings in square brackets. This works the same way as anywhere else. Please see the package documentation for more information.
Regions and Highlights ¶
If regions are enabled via SetRegions(), you can define text regions within the text and assign region IDs to them. Text regions start with region tags. Region tags are square brackets that contain a region ID in double quotes, for example:
We define a ["rg"]region[""] here.
A text region ends with the next region tag. Tags with no region ID ([""]) don't start new regions. They can therefore be used to mark the end of a region. Region IDs must satisfy the following regular expression:
[a-zA-Z0-9_,;: \-\.]+
Regions can be highlighted by calling the Highlight() function with one or more region IDs. This can be used to display search results, for example.
The ScrollToHighlight() function can be used to jump to the currently highlighted region once when the text view is drawn the next time.
func (*TextView) GetBufferSize ¶
GetBufferSize returns the number of lines and the length of the longest line in the text buffer. The screen size of the widget is available via GetRect.
func (*TextView) GetBytes ¶
GetBytes returns the current text of this text view. If "stripTags" is set to true, any region/color tags are stripped from the text.
func (*TextView) GetHighlights ¶
GetHighlights returns the IDs of all currently highlighted regions.
func (*TextView) GetRegionText ¶
GetRegionText returns the text of the region with the given ID. If dynamic colors are enabled, color tags are stripped from the text. Newlines are always returned as '\n' runes.
If the region does not exist or if regions are turned off, an empty string is returned.
func (*TextView) GetScrollOffset ¶
GetScrollOffset returns the number of rows and columns that are skipped at the top left corner when the text view has been scrolled.
func (*TextView) GetText ¶
GetText returns the current text of this text view. If "stripTags" is set to true, any region/color tags are stripped from the text.
func (*TextView) Highlight ¶
Highlight specifies which regions should be highlighted. If highlight toggling is set to true (see SetToggleHighlights()), the highlight of the provided regions is toggled (highlighted regions are un-highlighted and vice versa). If toggling is set to false, the provided regions are highlighted and all other regions will not be highlighted (you may also provide nil to turn off all highlights).
For more information on regions, see class description. Empty region strings are ignored.
Text in highlighted regions will be drawn inverted, i.e. with their background and foreground colors swapped.
func (*TextView) InputHandler ¶
InputHandler returns the handler for this widget.
func (*TextView) MouseHandler ¶
func (t *TextView) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*TextView) ScrollTo ¶
ScrollTo scrolls to the specified row and column (both starting with 0).
func (*TextView) ScrollToBeginning ¶
func (t *TextView) ScrollToBeginning()
ScrollToBeginning scrolls to the top left corner of the text if the text view is scrollable.
func (*TextView) ScrollToEnd ¶
func (t *TextView) ScrollToEnd()
ScrollToEnd scrolls to the bottom left corner of the text if the text view is scrollable. Adding new rows to the end of the text view will cause it to scroll with the new data.
func (*TextView) ScrollToHighlight ¶
func (t *TextView) ScrollToHighlight()
ScrollToHighlight will cause the visible area to be scrolled so that the highlighted regions appear in the visible area of the text view. This repositioning happens the next time the text view is drawn. It happens only once so you will need to call this function repeatedly to always keep highlighted regions in view.
Nothing happens if there are no highlighted regions or if the text view is not scrollable.
func (*TextView) SetBytes ¶
SetBytes sets the text of this text view to the provided byte slice. Previously contained text will be removed.
func (*TextView) SetChangedFunc ¶
SetChangedFunc sets a handler function which is called when the text of the text view has changed. This is useful when text is written to this io.Writer in a separate goroutine. Doing so does not automatically cause the screen to be refreshed so you may want to use the "changed" handler to redraw the screen.
Note that to avoid race conditions or deadlocks, there are a few rules you should follow:
- You can call App.Draw() from this handler.
- You can call TextView.HasFocus() from this handler.
- During the execution of this handler, access to any other variables from this widget or any other widget should be queued using App.QueueUpdate().
See package description for details on dealing with concurrency.
func (*TextView) SetDoneFunc ¶
SetDoneFunc sets a handler which is called when the user presses on the following keys: Escape, Enter, Tab, Backtab. The key is passed to the handler.
func (*TextView) SetDynamicColors ¶
SetDynamicColors sets the flag that allows the text color to be changed dynamically. See class description for details.
func (*TextView) SetHighlightBackgroundColor ¶
SetHighlightBackgroundColor sets the foreground color of highlighted text. The foreground color and background color of the text is swapped unless a custom highlight color has been set.
func (*TextView) SetHighlightForegroundColor ¶
SetHighlightForegroundColor sets the foreground color of highlighted text. The foreground color and background color of the text is swapped unless a custom highlight color has been set.
func (*TextView) SetHighlightedFunc ¶
SetHighlightedFunc sets a handler which is called when the list of currently highlighted regions change. It receives a list of region IDs which were newly highlighted, those that are not highlighted anymore, and those that remain highlighted.
Note that because regions are only determined during drawing, this function can only fire for regions that have existed during the last call to Draw().
func (*TextView) SetMaxLines ¶
SetMaxLines sets the maximum number of newlines the text view will hold before discarding older data from the buffer.
func (*TextView) SetRegions ¶
SetRegions sets the flag that allows to define regions in the text. See class description for details.
func (*TextView) SetReindexBuffer ¶
SetReindexBuffer set a flag controlling whether the buffer is reindexed when it is modified. This improves the performance of TextViews whose contents always have line-breaks in the same location. This must be called after the buffer has been indexed.
func (*TextView) SetScrollBarColor ¶
SetScrollBarColor sets the color of the scroll bar.
func (*TextView) SetScrollBarVisibility ¶
func (t *TextView) SetScrollBarVisibility(visibility ScrollBarVisibility) *TextView
SetScrollBarVisibility specifies the display of the scroll bar.
func (*TextView) SetScrollable ¶
SetScrollable sets the flag that decides whether or not the text view is scrollable. If true, text is kept in a buffer and can be navigated. If false, the last line will always be visible.
func (*TextView) SetText ¶
SetText sets the text of this text view to the provided string. Previously contained text will be removed.
func (*TextView) SetTextAlign ¶
SetTextAlign sets the horizontal alignment of the text. This must be either AlignLeft, AlignCenter, or AlignRight.
func (*TextView) SetTextColor ¶
SetTextColor sets the initial color of the text (which can be changed dynamically by sending color strings in square brackets to the text view if dynamic colors are enabled).
func (*TextView) SetToggleHighlights ¶
SetToggleHighlights sets a flag to determine how regions are highlighted. When set to true, the Highlight() function (or a mouse click) will toggle the provided/selected regions. When set to false, Highlight() (or a mouse click) will simply highlight the provided regions.
func (*TextView) SetVerticalAlign ¶
func (t *TextView) SetVerticalAlign(valign VerticalAlignment) *TextView
SetVerticalAlign sets the vertical alignment of the text. This must be either AlignTop, AlignMiddle, or AlignBottom.
func (*TextView) SetWordWrap ¶
SetWordWrap sets the flag that, if true and if the "wrap" flag is also true (see SetWrap()), wraps the line at spaces or after punctuation marks. Note that trailing spaces will not be printed.
This flag is ignored if the "wrap" flag is false.
func (*TextView) SetWrap ¶
SetWrap sets the flag that, if true, leads to lines that are longer than the available width being wrapped onto the next line. If false, any characters beyond the available width are not displayed.
func (*TextView) SetWrapWidth ¶
SetWrapWidth set the maximum width of lines when wrapping is enabled. When set to 0 the width of the TextView is used.
type Theme ¶
type Theme struct {
// Title, border and other lines
TitleColor tcell.Color // Box titles.
BorderColor tcell.Color // Box borders.
GraphicsColor tcell.Color // Graphics.
// Text
PrimaryTextColor tcell.Color // Primary text.
SecondaryTextColor tcell.Color // Secondary text (e.g. labels).
TertiaryTextColor tcell.Color // Tertiary text (e.g. subtitles, notes).
InverseTextColor tcell.Color // Text on primary-colored backgrounds.
ContrastPrimaryTextColor tcell.Color // Primary text for contrasting elements.
ContrastSecondaryTextColor tcell.Color // Secondary text on ContrastBackgroundColor-colored backgrounds.
// Background
WidgetBackgroundColor tcell.Color // Main background color for widgets.
ContrastBackgroundColor tcell.Color // Background color for contrasting elements.
MoreContrastBackgroundColor tcell.Color // Background color for even more contrasting elements.
// Button
ButtonCursorRune rune // The symbol to draw at the end of button labels when focused.
// Check box
CheckBoxCheckedRune rune
CheckBoxCursorRune rune // The symbol to draw within the checkbox when focused.
// Context menu
ContextMenuPaddingTop int
ContextMenuPaddingBottom int
ContextMenuPaddingLeft int
ContextMenuPaddingRight int
// Drop down
DropDownAbbreviationChars string // The chars to show when the option's text gets shortened.
DropDownSymbol rune // The symbol to draw at the end of the field when closed.
DropDownOpenSymbol rune // The symbol to draw at the end of the field when opened.
DropDownSelectedSymbol rune // The symbol to draw to indicate the selected list item.
// Scroll bar
ScrollBarColor tcell.Color
// Window
WindowMinWidth int
WindowMinHeight int
}
Theme defines the colors used when widgets are initialized.
type Transformation ¶
type Transformation int
Transformation describes a widget state modification.
const ( TransformFirstItem Transformation = 1 TransformLastItem Transformation = 2 TransformPreviousItem Transformation = 3 TransformNextItem Transformation = 4 TransformPreviousPage Transformation = 5 TransformNextPage Transformation = 6 )
Widget transformations.
type TreeNode ¶
TreeNode represents one node in a tree view.
func (*TreeNode) ClearChildren ¶
func (n *TreeNode) ClearChildren()
ClearChildren removes all child nodes from this node.
func (*TreeNode) Collapse ¶
func (n *TreeNode) Collapse()
Collapse makes the child nodes of this node disappear.
func (*TreeNode) CollapseAll ¶
func (n *TreeNode) CollapseAll()
CollapseAll collapses this node and all descendent nodes.
func (*TreeNode) Expand ¶
func (n *TreeNode) Expand()
Expand makes the child nodes of this node appear.
func (*TreeNode) ExpandAll ¶
func (n *TreeNode) ExpandAll()
ExpandAll expands this node and all descendent nodes.
func (*TreeNode) GetChildren ¶
GetChildren returns this node's children.
func (*TreeNode) GetReference ¶
func (n *TreeNode) GetReference() interface{}
GetReference returns this node's reference object.
func (*TreeNode) IsExpanded ¶
IsExpanded returns whether the child nodes of this node are visible.
func (*TreeNode) SetChildren ¶
SetChildren sets this node's child nodes.
func (*TreeNode) SetExpanded ¶
SetExpanded sets whether or not this node's child nodes should be displayed.
func (*TreeNode) SetFocusedFunc ¶
SetFocusedFunc sets the function which is called when the user navigates to this node.
This function is also called when the user selects this node.
func (*TreeNode) SetIndent ¶
SetIndent sets an additional indentation for this node's text. A value of 0 keeps the text as far left as possible with a minimum of line graphics. Any value greater than that moves the text to the right.
func (*TreeNode) SetReference ¶
SetReference allows you to store a reference of any type in this node. This will allow you to establish a mapping between the TreeView hierarchy and your internal tree structure.
func (*TreeNode) SetSelectable ¶
SetSelectable sets a flag indicating whether this node can be focused and selected by the user.
func (*TreeNode) SetSelectedFunc ¶
SetSelectedFunc sets a function which is called when the user selects this node by hitting Enter when it is focused.
func (*TreeNode) Walk ¶
Walk traverses this node's subtree in depth-first, pre-order (NLR) order and calls the provided callback function on each traversed node (which includes this node) with the traversed node and its parent node (nil for this node). The callback returns whether traversal should continue with the traversed node's child nodes (true) or not recurse any deeper (false).
type TreeView ¶
TreeView displays tree structures. A tree consists of nodes (TreeNode objects) where each node has zero or more child nodes and exactly one parent node (except for the root node which has no parent node).
The SetRoot() function is used to specify the root of the tree. Other nodes are added locally to the root node or any of its descendents. See the TreeNode documentation for details on node attributes. (You can use SetReference() to store a reference to nodes of your own tree structure.)
Nodes can be focused by calling SetCurrentNode(). The user can navigate the selection or the tree by using the following keys:
- j, down arrow, right arrow: Move (the selection) down by one node.
- k, up arrow, left arrow: Move (the selection) up by one node.
- g, home: Move (the selection) to the top.
- G, end: Move (the selection) to the bottom.
- Ctrl-F, page down: Move (the selection) down by one page.
- Ctrl-B, page up: Move (the selection) up by one page.
Selected nodes can trigger the "selected" callback when the user hits Enter.
The root node corresponds to level 0, its children correspond to level 1, their children to level 2, and so on. Per default, the first level that is displayed is 0, i.e. the root node. You can call SetTopLevel() to hide levels.
If graphics are turned on (see SetGraphics()), lines indicate the tree's hierarchy. Alternative (or additionally), you can set different prefixes using SetPrefixes() for different levels, for example to display hierarchical bullet point lists.
func (*TreeView) GetCurrentNode ¶
GetCurrentNode returns the currently selected node or nil of no node is currently selected.
func (*TreeView) GetRoot ¶
GetRoot returns the root node of the tree. If no such node was previously set, nil is returned.
func (*TreeView) GetRowCount ¶
GetRowCount returns the number of "visible" nodes. This includes nodes which fall outside the tree view's box but notably does not include the children of collapsed nodes. Note that this value is only up to date after the tree view has been drawn.
func (*TreeView) GetScrollOffset ¶
GetScrollOffset returns the number of node rows that were skipped at the top of the tree view. Note that when the user navigates the tree view, this value is only updated after the tree view has been redrawn.
func (*TreeView) InputHandler ¶
InputHandler returns the handler for this widget.
func (*TreeView) MouseHandler ¶
func (t *TreeView) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*TreeView) SetAlign ¶
SetAlign controls the horizontal alignment of the node texts. If set to true, all texts except that of top-level nodes will be placed in the same column. If set to false, they will indent with the hierarchy.
func (*TreeView) SetChangedFunc ¶
SetChangedFunc sets the function which is called when the user navigates to a new tree node.
func (*TreeView) SetCurrentNode ¶
SetCurrentNode focuses a node or, when provided with nil, clears focus. Selected nodes must be visible and selectable, or else the selection will be changed to the top-most selectable and visible node.
This function does NOT trigger the "changed" callback.
func (*TreeView) SetDoneFunc ¶
SetDoneFunc sets a handler which is called whenever the user presses the Escape, Tab, or Backtab key.
func (*TreeView) SetGraphics ¶
SetGraphics sets a flag which determines whether or not line graphics are drawn to illustrate the tree's hierarchy.
func (*TreeView) SetGraphicsColor ¶
SetGraphicsColor sets the colors of the lines used to draw the tree structure.
func (*TreeView) SetPrefixes ¶
SetPrefixes defines the strings drawn before the nodes' texts. This is a slice of strings where each element corresponds to a node's hierarchy level, i.e. 0 for the root, 1 for the root's children, and so on (levels will cycle).
For example, to display a hierarchical list with bullet points:
treeView.SetGraphics(false).
SetPrefixes([]string{"* ", "- ", "x "})
func (*TreeView) SetScrollBarColor ¶
SetScrollBarColor sets the color of the scroll bar.
func (*TreeView) SetScrollBarVisibility ¶
func (t *TreeView) SetScrollBarVisibility(visibility ScrollBarVisibility) *TreeView
SetScrollBarVisibility specifies the display of the scroll bar.
func (*TreeView) SetSelectedBackgroundColor ¶
SetSelectedBackgroundColor sets the background color of selected items.
func (*TreeView) SetSelectedFunc ¶
SetSelectedFunc sets the function which is called when the user selects a node by pressing Enter on the current selection.
func (*TreeView) SetSelectedTextColor ¶
SetSelectedTextColor sets the text color of selected items.
func (*TreeView) SetTopLevel ¶
SetTopLevel sets the first tree level that is visible with 0 referring to the root, 1 to the root's child nodes, and so on. Nodes above the top level are not displayed.
func (*TreeView) Transform ¶
func (t *TreeView) Transform(tr Transformation)
Transform modifies the current selection.
type UtilisationGauge ¶
UtilisationGauge represents utilisation mode gauge permitive.
func NewUtilModeGauge ¶
func NewUtilModeGauge() *UtilisationGauge
NewUtilModeGauge returns new utilisation mode gauge permitive.
func (*UtilisationGauge) Draw ¶
func (g *UtilisationGauge) Draw(screen tcell.Screen)
Draw draws this widget onto the screen.
func (*UtilisationGauge) Focus ¶
func (g *UtilisationGauge) Focus(delegate func(w Widget))
Focus is called when this widget receives focus.
func (*UtilisationGauge) GetRect ¶
func (g *UtilisationGauge) GetRect() (int, int, int, int)
GetRect return widget current rect.
func (*UtilisationGauge) GetValue ¶
func (g *UtilisationGauge) GetValue() float64
GetValue returns current gauge value.
func (*UtilisationGauge) HasFocus ¶
func (g *UtilisationGauge) HasFocus() bool
HasFocus returns whether or not this widget has focus.
func (*UtilisationGauge) SetCritPercentage ¶
func (g *UtilisationGauge) SetCritPercentage(percentage float64) *UtilisationGauge
SetCritPercentage sets critical percentage start range.
func (*UtilisationGauge) SetEmptyColor ¶
func (g *UtilisationGauge) SetEmptyColor(color tcell.Color) *UtilisationGauge
SetEmptyColor sets empty gauge color.
func (*UtilisationGauge) SetLabel ¶
func (g *UtilisationGauge) SetLabel(label string) *UtilisationGauge
SetLabel sets label for this widget.
func (*UtilisationGauge) SetLabelColor ¶
func (g *UtilisationGauge) SetLabelColor(color tcell.Color) *UtilisationGauge
SetLabelColor sets label text color.
func (*UtilisationGauge) SetRect ¶
func (g *UtilisationGauge) SetRect(x, y, width, height int) Widget
SetRect sets rect for this widget.
func (*UtilisationGauge) SetValue ¶
func (g *UtilisationGauge) SetValue(value float64) *UtilisationGauge
SetValue update the gauge progress.
func (*UtilisationGauge) SetWarnPercentage ¶
func (g *UtilisationGauge) SetWarnPercentage(percentage float64) *UtilisationGauge
SetWarnPercentage sets warning percentage start range.
type VerticalAlignment ¶
type VerticalAlignment int
VerticalAlignment represents vertical alignment.
const ( AlignTop VerticalAlignment = iota AlignMiddle AlignBottom )
Vertical alignment within a box.
type View ¶
type View interface {
// Put content in the View at the given location.
// Only a single grapheme cluster is drawn.
// This will generally be called by the Draw() method of a Widget.
// It returns the remaining string (after removing the first grapheme cluster),
// and the width (number of cells) displayed
Put(x int, y int, str string, style tcell.Style) (string, int)
// SetContent is used to update the content of the View at the given
// location. This will generally be called by the Draw() method of
// a Widget.
//
// Deprecated: Use Put instead.
SetContent(x int, y int, ch rune, comb []rune, style tcell.Style)
// Size represents the visible size. The actual content may be
// larger or smaller.
Size() (int, int)
// Resize tells the View that its visible dimensions have changed.
// It also tells it that it has a new offset relative to any parent
// view.
Resize(x, y, width, height int)
// Fill fills the displayed content with the given rune and style.
Fill(rune, tcell.Style)
// Clear clears the content. Often just Fill(' ', tcell.StyleDefault)
Clear()
}
View represents a logical view on an area. It will have some underlying physical area as well, generally. Views are operated on by Widgets.
type ViewPort ¶
type ViewPort struct {
// contains filtered or unexported fields
}
ViewPort is an implementation of a View, that provides a smaller logical view of larger content area. For example, a scrollable window of text, the visible window would be the ViewPort, on the underlying content. ViewPorts have a two dimensional size, and a two dimensional offset.
In some ways, as the underlying content is not kept persistently by the view port, it can be thought perhaps a little more precisely as a clipping region.
func NewViewPort ¶
NewViewPort returns a new ViewPort (and hence also a View). The x and y coordinates are an offset relative to the parent. The origin 0,0 represents the upper left. The width and height indicate a width and height. If the value -1 is supplied, then the dimension is calculated from the parent.
func (*ViewPort) Clear ¶
func (v *ViewPort) Clear()
Clear clears the displayed content, filling it with spaces of default text attributes.
func (*ViewPort) GetContentSize ¶
GetContentSize returns the size of content as width, height in character cells.
func (*ViewPort) GetPhysical ¶
GetPhysical returns the upper left and lower right coordinates of the visible content in the coordinate space of the parent. This is may be the physical coordinates of the screen, if the screen is the view's parent.
func (*ViewPort) GetVisible ¶
GetVisible returns the upper left and lower right coordinates of the visible content. That is, it will return x1, y1, x2, y2 where the upper left cell is position x1, y1, and the lower right is x2, y2. These coordinates are in the space of the content, that is the content area uses coordinate 0,0 as its first cell position.
func (*ViewPort) MakeVisible ¶
MakeVisible moves the ViewPort the minimum necessary to make the given point visible. This should be called before any content is changed with SetContent, since otherwise it may be possible to move the location onto a region whose contents have been discarded.
func (*ViewPort) Put ¶
Put is used to place data at the given cell location. Note that since the ViewPort doesn't retain this data, if the location is outside of the visible area, it is simply discarded.
Generally, this is called during the Draw() phase by the object that represents the content.
func (*ViewPort) Reset ¶
func (v *ViewPort) Reset()
Reset resets the record of content, and also resets the offset back to the origin. It doesn't alter the dimensions of the view port, nor the physical location relative to its parent.
func (*ViewPort) Resize ¶
Resize is called by the enclosing view to change the size of the ViewPort, usually in response to a window resize event. The x, y refer are the ViewPort's location relative to the parent View. A negative value for either width or height will cause the ViewPort to expand to fill to the end of parent View in the relevant dimension.
func (*ViewPort) ScrollDown ¶
ScrollDown moves the view down, showingh higher numbered rows of content.
func (*ViewPort) ScrollLeft ¶
ScrollLeft moves the view to the left.
func (*ViewPort) ScrollRight ¶
ScrollRight moves the view to the left.
func (*ViewPort) SetContent
deprecated
SetContent is used to place data at the given cell location. Note that since the ViewPort doesn't retain this data, if the location is outside of the visible area, it is simply discarded.
Generally, this is called during the Draw() phase by the object that represents the content.
Deprecated: Use Put instead.
func (*ViewPort) SetContentSize ¶
SetContentSize sets the size of the content area; this is used to limit scrolling and view moment. If locked is true, then the content size will not automatically grow even if content is placed outside of this area with the SetContent() method. If false, and content is drawn outside of the existing size, then the size will automatically grow to include the new content.
func (*ViewPort) SetSize ¶
SetSize is used to set the visible size of the view. Enclosing views or layout managers can use this to inform the View of its correct visible size.
func (*ViewPort) ValidateView ¶
func (v *ViewPort) ValidateView()
ValidateView does both ValidateViewX and ValidateViewY, ensuring both offsets are valid.
func (*ViewPort) ValidateViewX ¶
func (v *ViewPort) ValidateViewX()
ValidateViewX ensures that the X offset of the view port is limited so that it cannot scroll away from the content.
func (*ViewPort) ValidateViewY ¶
func (v *ViewPort) ValidateViewY()
ValidateViewY ensures that the Y offset of the view port is limited so that it cannot scroll away from the content.
type Widget ¶
type Widget interface {
// Draw draws this widget onto the screen. Implementers can call the
// screen's ShowCursor() function but should only do so when they have focus.
// (They will need to keep track of this themselves.)
Draw(screen tcell.Screen)
// GetRect returns the current position of the widget, x, y, width, and
// height.
GetRect() (int, int, int, int)
// SetRect sets a new position of the widget.
SetRect(x, y, width, height int) Widget
// GetVisible returns whether or not the widget is visible.
GetVisible() bool
// SetVisible sets whether or not the widget is visible.
SetVisible(v bool) Widget
// InputHandler returns a handler which receives key events when it has focus.
// It is called by the App class.
//
// A value of nil may also be returned, in which case this widget cannot
// receive focus and will not process any key events.
//
// The handler will receive the key event and a function that allows it to
// set the focus to a different widget, so that future key events are sent
// to that widget.
//
// The App's Draw() function will be called automatically after the
// handler returns.
//
// The Box class provides functionality to intercept keyboard input. If you
// subclass from Box, it is recommended that you wrap your handler using
// Box.WrapInputHandler() so you inherit that functionality.
InputHandler() func(event *tcell.EventKey, setFocus func(w Widget))
// Focus is called by the application when the widget receives focus.
// Implementers may call delegate() to pass the focus on to another widget.
Focus(delegate func(w Widget))
// Blur is called by the application when the widget loses focus.
Blur()
// GetFocusable returns the item's Focusable.
GetFocusable() Focusable
// MouseHandler returns a handler which receives mouse events.
// It is called by the App class.
//
// A value of nil may also be returned to stop the downward propagation of
// mouse events.
//
// The Box class provides functionality to intercept mouse events. If you
// subclass from Box, it is recommended that you wrap your handler using
// Box.WrapMouseHandler() so you inherit that functionality.
MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
}
Widget is the top-most interface for all graphical widgets.
type Window ¶
Window is a draggable, resizable frame around a widget. Windows must be added to a WindowManager.
func (*Window) InputHandler ¶
InputHandler returns the handler for this widget.
func (*Window) MouseHandler ¶
func (w *Window) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
func (*Window) SetFullscreen ¶
SetFullscreen sets the flag indicating whether or not the the window should be drawn fullscreen.
type WindowManager ¶
WindowManager provides an area which windows may be added to.
func NewWindowManager ¶
func NewWindowManager() *WindowManager
NewWindowManager returns a new window manager.
func (*WindowManager) Add ¶
func (wm *WindowManager) Add(w ...*Window)
Add adds a window to the manager.
func (*WindowManager) Clear ¶
func (wm *WindowManager) Clear()
Clear removes all windows from the manager.
func (*WindowManager) Draw ¶
func (wm *WindowManager) Draw(screen tcell.Screen)
Draw draws this widget onto the screen.
func (*WindowManager) Focus ¶
func (wm *WindowManager) Focus(delegate func(w Widget))
Focus is called when this widget receives focus.
func (*WindowManager) HasFocus ¶
func (wm *WindowManager) HasFocus() bool
HasFocus returns whether or not this widget has focus.
func (*WindowManager) MouseHandler ¶
func (wm *WindowManager) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(w Widget)) (consumed bool, capture Widget)
MouseHandler returns the mouse handler for this widget.
Notes ¶
Bugs ¶
Text containing square brackets is not escaped properly. Use TextView.SetWrapWidth where possible.
Source Files
¶
- ansi.go
- app.go
- barchart.go
- bind.go
- borders.go
- box.go
- button.go
- checkbox.go
- contextmenu.go
- cui.go
- dialog.go
- doc.go
- dropdown.go
- flex.go
- focus.go
- form.go
- frame.go
- gauge.go
- grid.go
- hexview.go
- image.go
- inputfield.go
- keys.go
- list.go
- menu.go
- modal.go
- mouse.go
- panels.go
- plot.go
- primitive.go
- progressbar.go
- semigraphics.go
- slider.go
- sparkline.go
- spinner.go
- styles.go
- tabbedpanels.go
- table.go
- textview.go
- treeview.go
- util.go
- view.go
- window.go
- windowmanager.go
Directories
¶
| Path | Synopsis |
|---|---|
|
demo
|
|
|
barchart
command
Demo code for the bar chart widget.
|
Demo code for the bar chart widget. |
|
box
command
Demo code for the Box widget.
|
Demo code for the Box widget. |
|
button
command
Demo code for the Button widget.
|
Demo code for the Button widget. |
|
checkbox
command
Demo code for the CheckBox widget.
|
Demo code for the CheckBox widget. |
|
dialog
command
Demo code for the bar chart widget.
|
Demo code for the bar chart widget. |
|
dropdown
command
Demo code for the DropDown widget.
|
Demo code for the DropDown widget. |
|
edit
command
|
|
|
edit/autocomplete
command
Demo code for edit.View autocomplete.
|
Demo code for edit.View autocomplete. |
|
flex
command
Demo code for the Flex widget.
|
Demo code for the Flex widget. |
|
focusmanager
command
Demo code for the FocusManager utility.
|
Demo code for the FocusManager utility. |
|
form
command
Demo code for the Form widget.
|
Demo code for the Form widget. |
|
frame
command
Demo code for the Frame widget.
|
Demo code for the Frame widget. |
|
gauge_pm
command
Demo code for the bar chart widget.
|
Demo code for the bar chart widget. |
|
gauge_um
command
Demo code for the bar chart widget.
|
Demo code for the bar chart widget. |
|
grid
command
Demo code for the Grid widget.
|
Demo code for the Grid widget. |
|
hexview
command
Demo code for the Box widget.
|
Demo code for the Box widget. |
|
image
command
|
|
|
inputfield/autocomplete
command
|
|
|
inputfield/autocompleteasync
command
|
|
|
inputfield/simple
command
Demo code for the InputField widget.
|
Demo code for the InputField widget. |
|
list
command
Demo code for the List widget.
|
Demo code for the List widget. |
|
menu
command
|
|
|
modal
command
Demo code for the Modal widget.
|
Demo code for the Modal widget. |
|
panels
command
Demo code for the Panels widget.
|
Demo code for the Panels widget. |
|
plot
command
|
|
|
plot_x_labels
command
|
|
|
presentation
command
A presentation of the cui package, implemented with cui.
|
A presentation of the cui package, implemented with cui. |
|
primitive
command
Demo code which illustrates how to implement your own widget.
|
Demo code which illustrates how to implement your own widget. |
|
progressbar
command
Demo code for the ProgressBar widget.
|
Demo code for the ProgressBar widget. |
|
sparkline
command
|
|
|
spinner
command
|
|
|
tabbedpanels
command
Demo code for the TabbedPanels widget.
|
Demo code for the TabbedPanels widget. |
|
table
command
Demo code for the Table widget.
|
Demo code for the Table widget. |
|
textview
command
Demo code for the TextView widget.
|
Demo code for the TextView widget. |
|
treeview
command
Demo code for the TreeView widget.
|
Demo code for the TreeView widget. |
|
unicode
command
Demo code for unicode support (demonstrates wide Chinese characters).
|
Demo code for unicode support (demonstrates wide Chinese characters). |
|
vte/bash
command
Demo showing how to run an interactive shell inside a cui terminal widget.
|
Demo showing how to run an interactive shell inside a cui terminal widget. |
|
vte/command
command
Demo showing how to run a one-shot command inside a cui terminal widget.
|
Demo showing how to run a one-shot command inside a cui terminal widget. |
|
vte/shell
command
|
|
|
vte/ssh
command
|
|
|
whichkeybind
command
|
|
|
runtime/files/syntax
command
|
|
|
pty/examples/command
command
|
|
|
pty/examples/shell
command
|
|
|
pty/examples/ssh
command
|