Documentation
¶
Overview ¶
Keybinds every legend, palette and menu derives its keys from, bound per context and kept in one host file
Index ¶
- Constants
- Variables
- func AddContext(name, doc string) error
- func Captured(msg tea.KeyPressMsg) (string, bool)
- func Chords(msg tea.KeyPressMsg) []string
- func Format(chord string) string
- func OptionAlt(msg tea.KeyPressMsg) bool
- func Pair(a, b string) string
- func Parse(s string) (string, error)
- func Press(chord string) tea.KeyPressMsg
- func Unshifted(msg tea.KeyPressMsg) (tea.KeyPressMsg, bool)
- type Action
- type ChangedMsg
- type Map
- func (m *Map) Action(id string) (Action, bool)
- func (m *Map) Actions() []Action
- func (m *Map) Add(id, chord string) error
- func (m *Map) AtDefault(id string) bool
- func (m *Map) Contexts() []string
- func (m *Map) Display(id string) string
- func (m *Map) DisplayAll(id string) string
- func (m *Map) First(id string) string
- func (m *Map) Holder(id, chord string) string
- func (m *Map) InContexts(contexts []string) []Action
- func (m *Map) Keys(id string) []string
- func (m *Map) Lookup(contexts []string, msg tea.KeyPressMsg) []string
- func (m *Map) Path() string
- func (m *Map) Read(data []byte) error
- func (m *Map) Rebind(id, chord string) error
- func (m *Map) Register(a Action)
- func (m *Map) Reload() error
- func (m *Map) Reset(id string) error
- func (m *Map) Save() error
- func (m *Map) Sendable(id string) []string
- func (m *Map) Set(id string, chords []string) error
- func (m *Map) SetShiftApart(on bool)
- func (m *Map) Stale() bool
- func (m *Map) Text() []byte
- func (m *Map) Unbind(id string) error
Constants ¶
const ( Global = "global" Panel = "panel" Session = "session" Complete = "complete" Search = "search" Confirm = "confirm" Edit = "edit" Capture = "capture" Palette = "palette" Tabs = "tabs" List = "list" Filter = "filter" Detail = "detail" Transcript = "transcript" Approval = "approval" Terminal = "terminal" )
Keybinding contexts. The focused window determines which contexts are active. Global bindings are checked last.
const FileName = "keybinds.json"
Name of the keybind file inside the configuration directory
Variables ¶
var ContextDocs = map[string]string{ Global: "everywhere", Panel: "all panels except the session", Session: "session prompt and transcript", Complete: "completion popup", Search: "search bars", Confirm: "yes/no prompts", Edit: "table cells while editing", Capture: "keybind editor while recording a key", Palette: "command palette and pickers", Tabs: "tabbed panels, such as config", List: "tables", Filter: "tables with filters", Detail: "open detail panes", Transcript: "agent transcripts", Approval: "approval dialog", Terminal: "terminal windows, every other key going to the shell", }
ContextDocs describes each context in the keybind editor.
Functions ¶
func AddContext ¶
Adds a keymap context the file and the editor know, refusing a taken name
func Captured ¶
func Captured(msg tea.KeyPressMsg) (string, bool)
Chord a key press is stored as when captured, an Option typed character as its alt chord and the shifted symbol over the base key
func Chords ¶
func Chords(msg tea.KeyPressMsg) []string
Every canonical chord a key press may stand for, the shifted symbol and the base layout key included
func Format ¶
Chord as legends and the file spell it, a shifted letter as its capital, other keys by name and the command key as cmd on a Mac
func OptionAlt ¶ added in v1.0.13
func OptionAlt(msg tea.KeyPressMsg) bool
Reports whether the press is an Option typed character read as an alt chord
func Pair ¶
Two chords as a pair such as j/k, arrows in reading order, either alone when the other is unbound
func Parse ¶
Canonical form of a chord written by a person, such as Alt+Shift+L, G, ctrl+pgdn or alt++
func Press ¶
func Press(chord string) tea.KeyPressMsg
Key press a terminal reports for the chord, a shifted letter carrying its capital as text
func Unshifted ¶
func Unshifted(msg tea.KeyPressMsg) (tea.KeyPressMsg, bool)
Press of a named key such as backspace without its shift, false for a printable key or one without shift
Types ¶
type Action ¶
type Action struct {
ID string
Context string
// Word shown beside the key in legends
Label string
// One line for the editor
Doc string
Default []string
// Fires while an overlay holds the input
Overlay bool
// Stays out of the palette, for editing and movement keys
Quiet bool
}
Something a key may fire, handled by the manager, the app or the focused card depending on its context
type ChangedMsg ¶
type ChangedMsg struct{}
Sent to every card once a bind changed, so inputs rebuild the bindings they hold
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Keybinds in force, with the registry they are drawn from and the file they are kept in
func (*Map) Display ¶
First chord of the action the terminal can send, formatted for a legend, empty when there is none
func (*Map) DisplayAll ¶
Every chord of the action the terminal can send, formatted and space separated
func (*Map) Holder ¶
Id of another action in the same context holding the chord, empty when it is free
func (*Map) InContexts ¶
Actions of the contexts in registry order, the global ones last
func (*Map) Lookup ¶
func (m *Map) Lookup(contexts []string, msg tea.KeyPressMsg) []string
Actions bound to the key press by context, a shifted key no chord names looked up as the key alone
func (*Map) Register ¶
Adds an action to the registry at its default keys, replacing one with the same id
func (*Map) Reload ¶
Reads the file again over the default keys without writing it, keeping the keys in force when it does not parse
func (*Map) Sendable ¶
Chords of the action the terminal can send, ctrl and shift on a letter needing a terminal reporting them apart and the command key a Mac whose terminal reports it
func (*Map) SetShiftApart ¶
Records whether the terminal reports ctrl and shift on a letter apart from ctrl alone
func (*Map) Stale ¶
Reports whether the text of the file changed since it was last read or written, a rewrite of the same text passing silently