Documentation
¶
Overview ¶
Package picker is a generic, minimal list picker. It supports two modes: a flat list of items, and a list grouped by an optional provider-style header per group. The cursor walks items only; headers are non-selectable. With a non-empty filter, the picker keeps every group whose name or any model name matches the (case-insensitive) needle.
The picker is the shared building block for /model (one provider or many) and /agents (single flat list). The ProviderModelGroup metadata carried by the config catalog (Active, Selectable, DisabledReason) is intentionally not rendered here: Selectable gates the catalog before it reaches the picker, Active renders in the top bar, and DisabledReason is a config-time error.
Index ¶
- type CancelMsg
- type Group
- type Model
- func (m *Model) ClearFilter()
- func (m Model) CursorRow() int
- func (m Model) Filter() string
- func (m *Model) MoveTo(index int)
- func (m *Model) Rebind(items []string)
- func (m *Model) RebindGroups(groups []Group)
- func (m Model) Selected() (string, bool)
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- func (m Model) ViewWindow(maxRows int) string
- type SelectMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Group ¶
Group is one header-and-items block in the picker. An empty Provider renders the items without a header, so a single Group with Provider "" is a flat list.
type Model ¶
Model is a single-component picker. Construct it with New for a flat list, or with NewGroups for a list of groups. NewGroups with one Group whose Provider is "" renders a flat list.
func NewGroups ¶
NewGroups returns a picker over grouped items. Empty groups (Models: nil) are dropped. A group with an empty Provider renders without a header, so a single anonymous group acts as a flat list. The cursor starts on the first model item.
func (*Model) ClearFilter ¶
func (m *Model) ClearFilter()
ClearFilter drops the active filter and resets the cursor to the first model item. Owners that dismiss the list (or hand focus away from it) use it so a stale filter cannot resurface as an unexplained short list.
func (Model) CursorRow ¶
CursorRow is the cursor's row within the visible list, so a caller that windows the list into a pane can keep the highlighted row on screen.
func (Model) Filter ¶
Filter exposes the active filter: a caller that rebinds and holds a cursor by row index needs to know whether that row is even visible.
func (*Model) MoveTo ¶
MoveTo places the cursor on the row at index, clamped to the visible list. Callers that rebuild a picker (a live-updating list) use it to hold the selection steady across the rebuild.
func (*Model) Rebind ¶
Rebind swaps the item set, keeping the filter and clamping the cursor to a model item. A live-updating list (the files panel) refreshes its rows through this, so an in-progress filter survives a rebuild that picker.New would reset.
func (*Model) RebindGroups ¶
RebindGroups swaps the grouped item set, keeping the filter and clamping the cursor to a model item.
func (Model) Selected ¶
Selected returns the currently highlighted item and whether the (visible) list has a model under the cursor. Headers are not selectable, so the bool is false whenever the cursor sits on a header.
func (Model) ViewWindow ¶
ViewWindow returns a window of items sized to fit within maxRows lines, ensuring the currently selected item (cursor) is always visible. If maxRows <= 0, all items are rendered.