Documentation
¶
Index ¶
- type RichList
- func (l *RichList) AddItem(mainText string) *RichList
- func (l *RichList) Clear() *RichList
- func (l *RichList) Draw(screen tcell.Screen)
- func (l *RichList) FindItems(mainSearch string, ignoreCase bool) (indices []int)
- func (l *RichList) GetCurrentItem() int
- func (l *RichList) GetItemCount() int
- func (l *RichList) GetItemText(index int) (main string)
- func (l *RichList) InputHandler() func(event *tcell.EventKey, setFocus func(p cview.Primitive))
- func (l *RichList) InsertItem(index int, mainText string) *RichList
- func (l *RichList) RemoveItem(index int) *RichList
- func (l *RichList) SetChangedFunc(handler func(index int, mainText string)) *RichList
- func (l *RichList) SetCurrentItem(index int) *RichList
- func (l *RichList) SetHighlightFullLine(highlight bool) *RichList
- func (l *RichList) SetHighlightedMainTextFunc(handler func(index int, mainText string) string) *RichList
- func (l *RichList) SetInfiniteScroll(infiniteScroll bool) *RichList
- func (l *RichList) SetItemText(index int, main string) *RichList
- func (l *RichList) SetMainTextColor(color tcell.Color) *RichList
- func (l *RichList) SetPrefixWithLineNumber(prefixWithLineNumber bool) *RichList
- func (l *RichList) SetSelectedBackgroundColor(color tcell.Color) *RichList
- func (l *RichList) SetUnfocusedSelectedBackgroundColor(color tcell.Color) *RichList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RichList ¶
RichList displays rows of items, each of which can be selected.
See https://code.rocketnine.space/tslocum/cview/wiki/List for an example.
func (*RichList) Draw ¶
func (l *RichList) Draw(screen tcell.Screen)
Draw draws this primitive onto the screen.
func (*RichList) FindItems ¶
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 (*RichList) GetCurrentItem ¶
GetCurrentItem returns the index of the currently selected list item, starting at 0 for the first item.
func (*RichList) GetItemCount ¶
GetItemCount returns the number of items in the list.
func (*RichList) GetItemText ¶
GetItemText returns an item's texts (main). Panics if the index is out of range.
func (*RichList) InputHandler ¶
InputHandler returns the handler for this primitive.
func (*RichList) 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 (*RichList) 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 (*RichList) 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), 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 (*RichList) 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 (*RichList) 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 (*RichList) SetHighlightedMainTextFunc ¶
func (*RichList) SetInfiniteScroll ¶
SetInfiniteScroll sets a flag which determines whether the scroll should be endless or not.
func (*RichList) SetItemText ¶
SetItemText sets an item's main text. Panics if the index is out of range.
func (*RichList) SetMainTextColor ¶
SetMainTextColor sets the color of the items' main text.
func (*RichList) SetPrefixWithLineNumber ¶
func (*RichList) SetSelectedBackgroundColor ¶
SetSelectedBackgroundColor sets the background color of selected items.
func (*RichList) SetUnfocusedSelectedBackgroundColor ¶
SetUnfocusedSelectedBackgroundColor sets the background color of unfocused selected items.