cmdpalette

package
v1.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 14 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Grouped

func Grouped(query string) bool

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.

func IsMessage

func IsMessage(message tea.Msg) bool

IsMessage reports whether a non-key message belongs to the palette: pointer feedback, or one of its own pointer activations. Key presses are routed by the caller's own open-overlay branch, which owns the interrupt ladder, so they are deliberately not claimed here.

Types

type Entry

type Entry struct {
	Action  action.Action
	Matched []int
}

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

func Filter(actions []action.Action, query string) []Entry

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 New

func New() Model

New builds a closed palette.

func (*Model) Close

func (m *Model) Close()

Close hides the palette and drops its state.

func (*Model) ConsumeChoice

func (m *Model) ConsumeChoice() (action.Action, bool)

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) IsOpen

func (m Model) IsOpen() bool

IsOpen reports whether the palette is on screen.

func (Model) MouseHandler

func (m Model) MouseHandler(width, height int) func(tea.MouseMsg) tea.Cmd

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

func (m *Model) Open() tea.Cmd

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

func (m Model) Overlay(background string, width, height int) string

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

func (m Model) PointerSession() uint64

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

func (m Model) PointerSurface(width, height int) pointer.Surface

PointerSurface publishes the rendered handler together with its immutable stable-control topology for root-level stale-generation admission.

func (*Model) SetFeatures

func (m *Model) SetFeatures(features action.Features)

SetFeatures records what this board was built with, so the palette offers the same actions the help pane reports as enabled.

func (*Model) SetStyles

func (m *Model) SetStyles(styles *theme.Styles)

SetStyles adopts the root model's resolved theme.

func (*Model) Update

func (m *Model) Update(message tea.Msg) tea.Cmd

Update handles one message while the palette is open.

func (Model) View

func (m Model) View(width, height int) string

View renders the panel centered on the terminal with no board behind it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL