Documentation
¶
Overview ¶
Package palette is the `:` command overlay: a filtered list of commands with a live query, driven entirely by a caller-supplied item list.
It deliberately knows nothing about what a command does. The app owns the registry and executes; this package owns the query, the filtering, the selection, and the drawing. That split is what lets the registry stay the single source for the palette, the help card, and the keymap without this package importing any of them.
Index ¶
- Constants
- func SplitQuery(q string) (name, args string)
- type Action
- type Item
- type Model
- func (m *Model) Close()
- func (m Model) IsVisible() bool
- func (m Model) Matches() []Item
- func (m *Model) Open()
- func (m Model) Query() string
- func (m Model) Selected() (Item, bool)
- func (m *Model) SetItems(items []Item)
- func (m Model) Update(msg tea.KeyPressMsg) (Model, Action)
- func (m Model) View() string
Constants ¶
const Width = 60
Width is the overlay's fixed width in cells (docs/tui-2.0.md, "Composer, modes, and palette"). Fixed rather than responsive because the palette is a reading surface: a 200-column terminal should not stretch a list of short command names across the whole screen.
Variables ¶
This section is empty.
Functions ¶
func SplitQuery ¶
SplitQuery separates the command word from its arguments.
Types ¶
type Item ¶
type Item struct {
// Name is the command word without the leading colon, e.g. "mark-read".
Name string
// Args is the argument shape shown after the name, e.g. "<query>".
// Empty for commands that take none.
Args string
// Description is the one-line explanation shown beside the name.
Description string
// Key is the equivalent key binding, right-aligned so the palette
// teaches the keymap. Empty when the command has no key of its own.
Key string
}
Item is one command as the palette displays it. The app builds these from its registry; the palette never interprets them beyond matching Name.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the palette overlay.
func (*Model) Close ¶
func (m *Model) Close()
Close hides the palette and drops the query, so reopening never resurrects a half-typed command from last time.
func (Model) Matches ¶
Matches returns the currently filtered items, for tests and for callers that want to know whether anything matched.
func (Model) Update ¶
func (m Model) Update(msg tea.KeyPressMsg) (Model, Action)
Update handles a keypress while the palette owns input.
Navigation is arrows and ctrl+n/ctrl+p only — NOT j/k. The handoff specified j/k, but the palette is a text surface: every printable key has to reach the query or commands like ":jump" and ":keymap" could not be typed at all. See docs/tui-2.0.md, "Divergences from the handoff prose".