Documentation
¶
Overview ¶
Package cmdpalette renders kb's ctrl+k command palette: a fuzzy search over the action registry, elevated as the overlay of spec section 4.
The palette owns no actions of its own. It reads internal/tui/action, and when the user picks a row it hands the root model back the key press that row stands for, so the board's existing handler runs the action. That is what keeps the palette from becoming a second, divergent dispatch: there is one keymap, one help pane and one palette, all reading one table.
Index ¶
- func Grouped(query string) bool
- func IsMessage(message tea.Msg) bool
- type Entry
- type Model
- func (m *Model) Close()
- func (m *Model) ConsumeChoice() (action.Action, bool)
- func (m Model) IsOpen() bool
- func (m Model) MouseHandler(width, height int) func(tea.MouseMsg) tea.Cmd
- func (m *Model) Open() tea.Cmd
- func (m Model) Overlay(background string, width, height int) string
- func (m Model) PointerSession() uint64
- func (m Model) PointerSurface(width, height int) pointer.Surface
- func (m *Model) SetFeatures(features action.Features)
- func (m *Model) SetStyles(styles *theme.Styles)
- func (m *Model) Update(message tea.Msg) tea.Cmd
- func (m Model) View(width, height int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Grouped ¶
Grouped reports whether a result list should carry its section bands: only an unfiltered list, which is in registry order and so is genuinely grouped.
Types ¶
type Entry ¶
Entry is one row the palette offers: a registry action and, when a query narrowed the list, the byte offsets in its Name that the query matched.
Matched carries byte offsets because that is what sahilm/fuzzy reports; widget.MatchRuns is where they become display columns. Nothing between here and there interprets them.
func Filter ¶
Filter is the palette's whole search, and it is a pure function of its two arguments: same actions and same query, same result, no styles and no model state involved. That is deliberate — the ranking is the part most likely to need tuning, and it should be tunable against a table test rather than against a rendered frame.
An empty query is not a search: it lists every action in registry order, so opening the palette and pressing enter runs the first thing the help pane also lists first. A non-empty query ranks by fuzzy score, best first, across every group at once — a ranked list that still carried group headers would be claiming an order it does not have.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the palette. The zero value is a closed palette on a board with no optional features, which is a usable fallback rather than a crash.
func (*Model) ConsumeChoice ¶
ConsumeChoice reports the action the user ran, exactly once. The root model calls it after every Update and replays the key of whatever comes back.
func (Model) MouseHandler ¶
MouseHandler returns the immutable pointer map of the frame just rendered. Every region is derived from the row that drew it, never from matching rendered text: an action's name is a table value and must not be able to address a control by spelling one.
The panel's surround is the palette's own backdrop rather than a hole, per spec section 10.5.3: an overlay whose panel does not contain the point still consumes the motion - clearing its own hover - so the board underneath can never light a card beneath a dimmed backdrop.
func (*Model) Open ¶
Open clears the query and shows the palette. Opening is always a fresh search: a palette that reopened onto the last query would make the second use of the day guess what the first one was looking for.
func (Model) Overlay ¶
Overlay composes the palette over the board surface. Spec section 4: elevation is a shade step plus a shadow, never a frame.
func (Model) PointerSession ¶
PointerSession identifies the current filtered palette owner. Query changes advance it because row identities may be replaced while the palette stays open.
func (Model) PointerSurface ¶
PointerSurface publishes the rendered handler together with its immutable stable-control topology for root-level stale-generation admission.
func (*Model) SetFeatures ¶
SetFeatures records what this board was built with, so the palette offers the same actions the help pane reports as enabled.