Documentation
¶
Index ¶
Constants ¶
const ( ModAlt = "alt+" ModCtrl = "ctrl+" ModShift = "shift+" )
const ( AltEnter = ModAlt + Enter CtrlA = ModCtrl + "a" CtrlB = ModCtrl + "b" CtrlC = ModCtrl + "c" CtrlD = ModCtrl + "d" CtrlE = ModCtrl + "e" CtrlF = ModCtrl + "f" CtrlN = ModCtrl + "n" CtrlP = ModCtrl + "p" CtrlS = ModCtrl + "s" )
const ( N = "n" Down = "down" Enter = "enter" Esc = "esc" Left = "left" Right = "right" Space = "space" Tab = "tab" Up = "up" Y = "y" )
const ( ArrowsLeftRight = "←→" ArrowsVertical = "↕" ShiftArrowsVertical = ModShift + ArrowsVertical )
Variables ¶
This section is empty.
Functions ¶
func Replay ¶ added in v0.2.0
func Replay(s string) tea.KeyPressMsg
Replay rebuilds the KeyPressMsg for a binding's key string ("t", "tab", "shift+tab", "ctrl+u", "ctrl+f5"), so replaying a command-palette selection is byte-for-byte the same event pressing the key would raise - key.Matches compares String(), and this reconstructs exactly that. Modifier prefixes strip left to right; the remainder is a named key, a lone rune, or - for a multi-rune name we don't know - an extended key.
Text is set only when unmodified. A KeyPressMsg's String() returns its Text verbatim when present, ignoring the modifier, so setting Text on a modified key would collapse "ctrl+f99" to a bare "f99" and could fire a command bound to that literal. Leaving Text empty lets String() fall through to the modifier-prefixed keystroke form, so an unsupported modified rebind renders as a stub that matches nothing rather than misfiring.
Types ¶
type Registry ¶ added in v0.2.0
Registry maps stable lower-case names to the owner's binding fields. Values are pointers so Rebind mutates the owner's key map in place; build the registry from the same struct the app reads bindings off. The registry knows nothing about which bindings exist - the owner declares its own key map struct and hands in the pointers.
func (Registry) Names ¶ added in v0.2.0
Names returns every rebindable binding name, sorted. Useful for docs and for validating a config file's keybinding overrides.
func (Registry) Rebind ¶ added in v0.2.0
Rebind applies user overrides keyed by binding name (e.g. {"transition": {"x"}}). An empty key slice is ignored so a partial config never silently unbinds an action. The first key becomes the help label; the description is kept. An unknown name is an error rather than a silent no-op, so a typo in a config file is surfaced - and it is checked before anything mutates, so a failed Rebind leaves every binding exactly as it was.