action

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package action owns kb's keyboard action registry: one table naming every action the board offers, the key that drives it, and the words that describe it.

The table exists so that two surfaces cannot disagree about the keymap. The ? help pane of spec section 5.2 reads it to build its bindings, and the ctrl+k command palette reads it to build its entries. Neither spells a key or a description of its own, so a rebind or a reword is one edit here and both surfaces move together. A surface that needs an action the table does not carry has found a missing row, not a reason for a literal.

Everything here is a pure function over immutable data: no styles, no bubbletea state, no store. The one dependency is bubbletea, and only so that a row can hand back the key press it stands for.

Index

Constants

View Source
const PaletteKey = "ctrl+k"

PaletteKey is the chord that opens the command palette. It is named here rather than in the palette package because the registry is where every key kb binds is written down.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	ID    ID
	Group Group
	Need  Feature
	Key   string
	Hint  string
	Name  string
}

Action is one row of the registry.

Key is the key string the root model's own handler matches, which is why the palette can run an action by replaying it rather than by carrying a second copy of the dispatch. Hint is how that key is spelled to a reader and may name a pair the row stands for ("j/k"). Name is a lowercase verb phrase and is both the help description and the palette label, so the two can never drift.

func All

func All() []Action

All is the whole registry in declaration order. The returned slice is a copy: the table is the durable artifact and no caller gets to edit it.

func InGroup

func InGroup(group Group) []Action

InGroup is every row of one group, enabled or not, in declaration order. The help pane wants the disabled rows too, so it can render them dimmed rather than silently shrink a column.

func Listed

func Listed(features Features) []Action

Listed is every action the palette offers on this board: the enabled rows of the Navigate and Act groups, minus the row that opens the palette itself. Offering a palette entry that reopens the palette the user is already looking at is noise, and the Dismiss group's rows only make sense from the help pane.

func Lookup

func Lookup(id ID) (Action, bool)

Lookup is one row by id, and reports false for an id the table does not carry. A surface that names an action - the empty state's tail of spec section 10.8.3 is the first one that is not a keymap surface - reads its key and its words from here rather than spelling either of them.

func (Action) Enabled

func (a Action) Enabled(features Features) bool

Enabled reports whether the board was built with what this action needs.

func (Action) KeyPress

func (a Action) KeyPress() (tea.KeyPressMsg, bool)

KeyPress is the key press this action stands for, and reports false for a key the registry spells as a chord or a name the constructor does not cover.

This is what lets the palette run an action without owning a second copy of the board's dispatch: it replays the press and the root model's own handler does the rest. It is also what feeds widget.Hotkey, which reads the press to decide where a label's underline lands.

type Feature

type Feature uint8

Feature is the board capability an action needs before it is offered. A board built without a card editor still carries the n and e rows; they are reported disabled rather than omitted, which is the self-managing-keymap property the help pane already relies on.

const (
	Always Feature = iota
	Editor
	Settings
	ADR
	Issues
)

The capabilities the registry gates on.

type Features

type Features struct {
	Editor   bool
	Settings bool
	ADR      bool
	Issues   bool
}

Features is what this board was built with, resolved once by the root model.

type Group

type Group uint8

Group is one column of the help pane and one section band of the palette.

const (
	Navigate Group = iota
	Act
	Dismiss
)

The three groups. Navigate and Act are the help pane's two columns and the palette's two sections; Dismiss is the help pane's short-help ladder and is not offered by the palette, because closing the help pane is not something a palette entry can usefully do.

func (Group) Label

func (g Group) Label() string

Label is the group's section band title in the palette.

type ID

type ID uint8

ID is the stable identity of one action, independent of the key currently bound to it and of the words currently describing it.

const (
	OpenCard ID = iota
	LiftCard
	SelectCard
	SelectColumn
	JumpColumn
	FilterText
	FilterLabel
	FilterClear
	SwitchProject
	OpenPalette

	ShipCard
	CancelCard
	RestoreCard
	PurgeCard
	NewCard
	EditCard
	OpenSettings
	SplitADR
	ImportIssue

	CloseHelp
	Quit
)

The registry's rows. Order is the order the help pane and the palette list them in.

Jump to

Keyboard shortcuts

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