Documentation
¶
Overview ¶
Package selector provides a lightweight cursor component for list-style UI elements. It holds the list of option items (label + key), tracks the selected index, handles up/down key navigation, and renders itself. Disabled items are skipped during navigation but still displayed dimmed.
Index ¶
Constants ¶
const Unselected = -1
Unselected is the sentinel cursor value meaning no item is highlighted.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
Item is a single entry in a Selector. Label is the human-readable display string; Key is arbitrary client data. Disabled items are shown dimmed and cannot be navigated to.
type ItemStyle ¶
type ItemStyle int
ItemStyle controls how a selector item is rendered when it is highlighted.
type Selection ¶
Selection is the value returned by Selected(). It bundles the chosen item's Label, Key, Disabled flag, and its position Index in the list.
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector manages cursor position within a list of Items.
func New ¶
New returns a Selector holding items with the given initial cursor. Pass Unselected (-1) if no item should be initially highlighted.
func (Selector) Selected ¶
Selected returns the selected item and its index. The second return value is false when the cursor is Unselected.