ui

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2025 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DropDown struct {
	*tview.Box
	// contains filtered or unexported fields
}

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 NewDropDown

func NewDropDown() *DropDown

NewDropDown returns a new drop-down.

func (d *DropDown) AddOption(text string, selected func()) *DropDown

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 (d *DropDown) CloseList(setFocus func(p tview.Primitive))
func (d *DropDown) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (d *DropDown) Focus(delegate func(p tview.Primitive))

Focus is called by the application when the primitive receives focus.

func (d *DropDown) GetCurrentOption() (int, string)

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 (d *DropDown) GetFieldHeight() int

GetFieldHeight returns this primitive's field height.

func (d *DropDown) GetFieldWidth() int

GetFieldWidth returns this primitive's field screen width.

func (d *DropDown) GetLabel() string

GetLabel returns the text to be displayed before the input area.

func (d *DropDown) GetList() *tview.List
func (d *DropDown) GetOptionCount() int

GetOptionCount returns the number of options in the drop-down.

func (d *DropDown) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (d *DropDown) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler returns the handler for this primitive.

func (d *DropDown) IsListOpen() bool
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 (d *DropDown) OpenList(setFocus func(p tview.Primitive))
func (d *DropDown) RemoveOption(index int) *DropDown

RemoveOption removes the specified option from the drop-down. Panics if the index is out of range.

func (d *DropDown) SetCurrentOption(index int) *DropDown

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 (d *DropDown) SetDisabled(disabled bool) tview.FormItem

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 (d *DropDown) SetDoneFunc(handler func(key tcell.Key)) *DropDown

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 (d *DropDown) SetFieldBackgroundColor(color tcell.Color) *DropDown

SetFieldBackgroundColor sets the background color of the options area.

func (d *DropDown) SetFieldTextColor(color tcell.Color) *DropDown

SetFieldTextColor sets the text color of the options area.

func (d *DropDown) SetFieldWidth(width int) *DropDown

SetFieldWidth sets the screen width of the options area. A value of 0 means extend to as long as the longest option text.

func (d *DropDown) SetFinishedFunc(handler func(key tcell.Key)) tview.FormItem

SetFinishedFunc sets a callback invoked when the user leaves this form item.

func (d *DropDown) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) tview.FormItem

SetFormAttributes sets attributes shared by all form items.

func (d *DropDown) SetLabel(label string) *DropDown

SetLabel sets the text to be displayed before the input area.

func (d *DropDown) SetLabelColor(color tcell.Color) *DropDown

SetLabelColor sets the color of the label.

func (d *DropDown) SetLabelWidth(width int) *DropDown

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 (d *DropDown) SetListStyles(unselected, selected tcell.Style) *DropDown

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 (d *DropDown) SetOptions(texts []string, selected func(text string, index int)) *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 text and its index into the options slice. The "selected" parameter may be nil.

func (d *DropDown) SetPrefixTextColor(color tcell.Color) *DropDown

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 (d *DropDown) SetSelectedFunc(handler func(text string, index int)) *DropDown

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 (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

type TableWithDropdown struct {
	*tview.Table
	// contains filtered or unexported fields
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL