Documentation
¶
Index ¶
- type DropDown
- func (d *DropDown) AddOption(text string, selected func()) *DropDown
- func (d *DropDown) CloseList(setFocus func(p tview.Primitive))
- func (d *DropDown) Draw(screen tcell.Screen)
- func (d *DropDown) Focus(delegate func(p tview.Primitive))
- func (d *DropDown) GetCurrentOption() (int, string)
- func (d *DropDown) GetFieldHeight() int
- func (d *DropDown) GetFieldWidth() int
- func (d *DropDown) GetLabel() string
- func (d *DropDown) GetList() *tview.List
- func (d *DropDown) GetOptionCount() int
- func (d *DropDown) HasFocus() bool
- func (d *DropDown) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))
- func (d *DropDown) IsListOpen() bool
- func (d *DropDown) MouseHandler() ...
- func (d *DropDown) OpenList(setFocus func(p tview.Primitive))
- func (d *DropDown) RemoveOption(index int) *DropDown
- func (d *DropDown) SetCurrentOption(index int) *DropDown
- func (d *DropDown) SetDisabled(disabled bool) tview.FormItem
- func (d *DropDown) SetDoneFunc(handler func(key tcell.Key)) *DropDown
- func (d *DropDown) SetFieldBackgroundColor(color tcell.Color) *DropDown
- func (d *DropDown) SetFieldTextColor(color tcell.Color) *DropDown
- func (d *DropDown) SetFieldWidth(width int) *DropDown
- func (d *DropDown) SetFinishedFunc(handler func(key tcell.Key)) tview.FormItem
- func (d *DropDown) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) tview.FormItem
- func (d *DropDown) SetLabel(label string) *DropDown
- func (d *DropDown) SetLabelColor(color tcell.Color) *DropDown
- func (d *DropDown) SetLabelWidth(width int) *DropDown
- func (d *DropDown) SetListStyles(unselected, selected tcell.Style) *DropDown
- func (d *DropDown) SetOptions(texts []string, selected func(text string, index int)) *DropDown
- func (d *DropDown) SetPrefixTextColor(color tcell.Color) *DropDown
- func (d *DropDown) SetSelectedFunc(handler func(text string, index int)) *DropDown
- func (d *DropDown) SetTextOptions(prefix, suffix, currentPrefix, currentSuffix, noSelection string) *DropDown
- type TableWithDropdown
- func (t *TableWithDropdown) AddOption(text string, selected func()) *TableWithDropdown
- func (t *TableWithDropdown) ClearOptions() *TableWithDropdown
- func (t *TableWithDropdown) CloseDropdownList(setFocus func(p tview.Primitive))
- func (t *TableWithDropdown) Draw(screen tcell.Screen)
- func (t *TableWithDropdown) Focus(delegate func(p tview.Primitive))
- func (t *TableWithDropdown) GetDropdownList() *tview.List
- func (t *TableWithDropdown) HasFocus() bool
- func (t *TableWithDropdown) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))
- func (t *TableWithDropdown) IsDropdownOpen() bool
- func (t *TableWithDropdown) OpenDropdownList(row, col int, setFocus func(p tview.Primitive))
- func (t *TableWithDropdown) SetListStyles(unselected, selected tcell.Style) *TableWithDropdown
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DropDown ¶
DropDown implements a selection widget whose options become visible in a drop-down list when activated.
See https://github.com/rivo/tview/wiki/DropDown for an example.
func (*DropDown) AddOption ¶
AddOption adds a new selectable option to this drop-down. The "selected" callback is called when this option was selected. It may be nil.
func (*DropDown) GetCurrentOption ¶
GetCurrentOption returns the index of the currently selected option as well as its text. If no option was selected, -1 and an empty string is returned.
func (*DropDown) GetFieldHeight ¶ added in v1.9.0
GetFieldHeight returns this primitive's field height.
func (*DropDown) GetFieldWidth ¶
GetFieldWidth returns this primitive's field screen width.
func (*DropDown) GetOptionCount ¶
GetOptionCount returns the number of options in the drop-down.
func (*DropDown) InputHandler ¶
InputHandler returns the handler for this primitive.
func (*DropDown) IsListOpen ¶
func (*DropDown) MouseHandler ¶
func (d *DropDown) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)
MouseHandler returns the mouse handler for this primitive.
func (*DropDown) RemoveOption ¶
RemoveOption removes the specified option from the drop-down. Panics if the index is out of range.
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) SetDisabled ¶ added in v1.9.0
SetDisabled sets whether or not the item is disabled / read-only. Currently it's a no-op, just to make DropDown satisfy the FormItem interface after updating tview from v0.0.0-20220307222120-9994674d60a8 to v0.0.0-20230530133550-8bd761dda819..
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) SetFieldBackgroundColor ¶
SetFieldBackgroundColor sets the background color of the options area.
func (*DropDown) SetFieldTextColor ¶
SetFieldTextColor sets the text color of the options area.
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) SetFormAttributes ¶
func (d *DropDown) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) tview.FormItem
SetFormAttributes sets attributes shared by all form items.
func (*DropDown) SetLabelColor ¶
SetLabelColor sets the color of the label.
func (*DropDown) SetLabelWidth ¶
SetLabelWidth sets the screen width of the label. A value of 0 will cause the primitive to use the width of the label string.
func (*DropDown) SetListStyles ¶
SetListStyles sets the styles of the items in the drop-down list (unselected as well as selected items). Style attributes are currently ignored but may be used in the future.
func (*DropDown) SetOptions ¶
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 text and its index into the options slice. The "selected" parameter may be nil.
func (*DropDown) SetPrefixTextColor ¶
SetPrefixTextColor sets the color of the prefix string. The prefix string is shown when the user starts typing text, which directly selects the first option that starts with the typed string.
func (*DropDown) SetSelectedFunc ¶
SetSelectedFunc sets a handler which is called when the user changes the 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 text and index. If "no option" was selected, these values are an empty string and -1.
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 TableWithDropdown ¶
func NewTableWithDropdown ¶
func NewTableWithDropdown() *TableWithDropdown
func (*TableWithDropdown) AddOption ¶
func (t *TableWithDropdown) AddOption(text string, selected func()) *TableWithDropdown
func (*TableWithDropdown) ClearOptions ¶
func (t *TableWithDropdown) ClearOptions() *TableWithDropdown
func (*TableWithDropdown) CloseDropdownList ¶
func (t *TableWithDropdown) CloseDropdownList(setFocus func(p tview.Primitive))
func (*TableWithDropdown) Draw ¶
func (t *TableWithDropdown) Draw(screen tcell.Screen)
func (*TableWithDropdown) Focus ¶
func (t *TableWithDropdown) Focus(delegate func(p tview.Primitive))
Focus is called by the application when the primitive receives focus.
func (*TableWithDropdown) GetDropdownList ¶
func (t *TableWithDropdown) GetDropdownList() *tview.List
func (*TableWithDropdown) HasFocus ¶
func (t *TableWithDropdown) HasFocus() bool
HasFocus returns whether or not this primitive has focus.
func (*TableWithDropdown) InputHandler ¶
func (t *TableWithDropdown) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))
func (*TableWithDropdown) IsDropdownOpen ¶
func (t *TableWithDropdown) IsDropdownOpen() bool
func (*TableWithDropdown) OpenDropdownList ¶
func (t *TableWithDropdown) OpenDropdownList(row, col int, setFocus func(p tview.Primitive))
func (*TableWithDropdown) SetListStyles ¶
func (t *TableWithDropdown) SetListStyles(unselected, selected tcell.Style) *TableWithDropdown