keys

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Keybinds every legend, palette and menu derives its keys from, bound per context and kept in one host file

Index

Constants

View Source
const (
	Global     = "global"
	Panel      = "panel"
	Session    = "session"
	Complete   = "complete"
	Question   = "question"
	Search     = "search"
	Confirm    = "confirm"
	Edit       = "edit"
	Capture    = "capture"
	Palette    = "palette"
	Tabs       = "tabs"
	List       = "list"
	Filter     = "filter"
	Detail     = "detail"
	Sessions   = "sessions"
	Agents     = "agents"
	Findings   = "findings"
	Jobs       = "jobs"
	Transcript = "transcript"
	Approval   = "approval"
	Mission    = "mission"
	Form       = "form"
	Area       = "area"
	Profiles   = "config.profiles"
	Models     = "config.models"
	App        = "config.app"
	Rules      = "config.rules"
	Hooks      = "config.hooks"
	MCP        = "config.mcp"
	Tools      = "config.tools"
	Keybinds   = "config.keys"
	Extensions = "config.ext"
	Terminal   = "terminal"
)

Keybinding contexts. The focused window determines which contexts are active. Global bindings are checked last.

View Source
const FileName = "keybinds.json"

Name of the keybind file inside the configuration directory

Variables

View Source
var ContextDocs = map[string]string{
	Global:     "everywhere",
	Panel:      "all panels except the session",
	Session:    "session prompt and transcript",
	Complete:   "completion popup",
	Question:   "question waiting in the session prompt",
	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",
	Sessions:   "sessions panel",
	Agents:     "agents panel",
	Findings:   "findings panel",
	Jobs:       "jobs panel",
	Transcript: "agent transcripts",
	Approval:   "approval dialog",
	Mission:    "mission panels",
	Form:       "dialogs",
	Area:       "multi line fields in dialogs",
	Profiles:   "profiles tab",
	Models:     "models tab",
	App:        "app tab",
	Rules:      "rules tab",
	Hooks:      "hooks tab",
	MCP:        "MCP tab",
	Tools:      "tools tab",
	Keybinds:   "keys tab",
	Extensions: "extensions tab",
	Terminal:   "terminal windows, every other key going to the shell",
}

ContextDocs describes each context in the keybind editor.

Functions

func Add

func Add(a Action) error

Adds an action every later map starts with, refusing a taken id, an unknown context or a chord that does not parse

func AddContext

func AddContext(name, doc string) error

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

func Format(chord string) string

Chord as legends and the file spell it, a shifted letter as its capital and other keys by name

func Option added in v1.0.13

func Option() bool

Reports whether Option typed characters are read as alt chords

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

func Pair(a, b string) string

Two chords as a pair such as j/k, arrows in reading order, either alone when the other is unbound

func Parse

func Parse(s string) (string, error)

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 SetOption added in v1.0.13

func SetOption(on bool)

Turns the reading of Option typed characters as alt chords on or off

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 Default

func Default() *Map

Map holding every registered action at its default keys

func Open

func Open(path string) (*Map, error)

Map read from the file at path, written there with the defaults when none exists, every rejected entry reported

func (*Map) Action

func (m *Map) Action(id string) (Action, bool)

Action with the id

func (*Map) Actions

func (m *Map) Actions() []Action

Every action in registry order

func (*Map) Add

func (m *Map) Add(id, chord string) error

Adds a chord to the action

func (*Map) AtDefault

func (m *Map) AtDefault(id string) bool

Reports whether the action holds its default keys

func (*Map) Contexts

func (m *Map) Contexts() []string

Contexts in registry order

func (*Map) Display

func (m *Map) Display(id string) string

First chord of the action formatted for a legend, empty when it is unbound

func (*Map) DisplayAll

func (m *Map) DisplayAll(id string) string

Every chord of the action formatted, space separated

func (*Map) First

func (m *Map) First(id string) string

First chord bound to the action, empty when it is unbound

func (*Map) Holder

func (m *Map) Holder(id, chord string) string

Id of another action in the same context holding the chord, empty when it is free

func (*Map) InContexts

func (m *Map) InContexts(contexts []string) []Action

Actions of the contexts in registry order, the global ones last

func (*Map) Keys

func (m *Map) Keys(id string) []string

Chords bound to the action, none when it is unbound

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

func (m *Map) Path() string

File the map is written to

func (*Map) Read

func (m *Map) Read(data []byte) error

Applies the file text as one swap so actions that trade keys both bind

func (*Map) Rebind

func (m *Map) Rebind(id, chord string) error

Binds the action to the one chord

func (*Map) Register

func (m *Map) Register(a Action)

Adds an action to the registry at its default keys, replacing one with the same id

func (*Map) Reload

func (m *Map) Reload() error

Reads the file again over the default keys, keeping the keys in force when the file does not parse

func (*Map) Reset

func (m *Map) Reset(id string) error

Returns the action to its default keys

func (*Map) Save

func (m *Map) Save() error

Writes the file

func (*Map) Set

func (m *Map) Set(id string, chords []string) error

Replaces every chord of the action with the given ones

func (*Map) Stale

func (m *Map) Stale() bool

Reports whether the file changed on disk since it was last read or written

func (*Map) Text

func (m *Map) Text() []byte

File text, contexts in registry order each holding its actions and their chords

func (*Map) Unbind

func (m *Map) Unbind(id string) error

Leaves the action without keys

Jump to

Keyboard shortcuts

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