Documentation ¶
Index ¶
- type List
- func (l *List) AddItem(mainText, secondaryText string, shortcut rune, selected func()) *List
- func (l *List) Clear() *List
- func (l *List) Draw(screen tcell.Screen)
- func (l *List) FindItems(mainSearch, secondarySearch string, mustContainBoth, ignoreCase bool) (indices []int)
- func (l *List) GetCurrentItem() int
- func (l *List) GetItemCount() int
- func (l *List) GetItemText(index int) (main, secondary string)
- func (l *List) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))
- func (l *List) InsertItem(index int, mainText, secondaryText string, shortcut rune, selected func()) *List
- func (l *List) RemoveItem(index int) *List
- func (l *List) SetChangedFunc(handler func(index int, mainText string, secondaryText string, shortcut rune)) *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) SetItemText(index int, main, secondary string) *List
- func (l *List) SetMainTextColor(color tcell.Color) *List
- func (l *List) SetSecondaryTextColor(color tcell.Color) *List
- func (l *List) SetSelectedBackgroundColor(color tcell.Color) *List
- func (l *List) SetSelectedFocusOnly(focusOnly bool) *List
- func (l *List) SetSelectedFunc(handler func(int, string, string, rune)) *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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type List ¶
List displays rows of items, each of which can be selected.
See https://github.com/rivo/tview/wiki/List for an example.
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 index of the currently selected list item, starting at 0 for the first item.
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) InputHandler ¶
InputHandler returns the handler for this primitive.
func (*List) InsertItem ¶
func (l *List) InsertItem(index int, mainText, secondaryText string, shortcut rune, selected func()) *List
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) 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 ¶
func (l *List) SetChangedFunc(handler func(index int, mainText string, secondaryText string, shortcut rune)) *List
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), its main text, secondary text, and its shortcut rune.
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) 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) SetSecondaryTextColor ¶
SetSecondaryTextColor sets the color of the items' secondary text.
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), its main text, secondary text, and its shortcut rune.
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.