Documentation
¶
Overview ¶
Package list renders a cursor-and-scroll list over pre-rendered row blocks.
Rows arrive as Items whose Block text is already styled and wrapped; the model owns only selection and viewport state. It is not a tea model — deck views and CLI panes drive it by calling Move/Scroll and printing View.
Index ¶
- type Item
- type Model
- func (m *Model) EnsureVisible()
- func (m *Model) Height() int
- func (m *Model) Move(delta int)
- func (m *Model) Scroll(delta int)
- func (m *Model) Selectable() bool
- func (m *Model) Selected() (Item, bool)
- func (m *Model) SetFocused(f bool)
- func (m *Model) SetItems(items []Item)
- func (m *Model) SetItemsKeepingCursor(items []Item)
- func (m *Model) SetSize(w, h int)
- func (m *Model) SetTheme(t theme.Theme)
- func (m *Model) View() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct {
Block string
Key string
Selectable bool
GapStem string
// Payload carries the caller's domain value for the row, handed back by
// Selected and selection callbacks so callers need no key→value side table.
Payload any
}
Item is one list row. Block is the pre-rendered (possibly multi-line) body; Key identifies the row to the caller; unselectable rows are skipped by the cursor. GapStem, when set, is repeated in the blank line drawn after the row so tree rules survive the gap.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the list state: rows plus cursor, scroll offset, size, and focus. Callers mutate it with SetItems/Move/Scroll and render it with View; it is not a Bubble Tea model and has no Update loop.
func (*Model) EnsureVisible ¶ added in v0.1.17
func (m *Model) EnsureVisible()
EnsureVisible scrolls just enough to bring the selected row into view.
func (*Model) Move ¶
Move steps the cursor by delta over selectable rows, scrolling as needed; with no selectable rows it scrolls the viewport instead.
func (*Model) Scroll ¶
Scroll shifts the viewport by delta lines and drags the cursor along so it stays on a visible row.
func (*Model) Selectable ¶
Selectable reports whether any row currently holds the cursor.
func (*Model) SetFocused ¶
SetFocused switches the cursor glyph between focused and dimmed styles.
func (*Model) SetItemsKeepingCursor ¶ added in v0.1.13
SetItemsKeepingCursor replaces the rows while trying to keep the current selection: first by Key, then by index, falling back to the first selectable row.