Documentation
¶
Overview ¶
Package keybindings lets a person remap Flockdeck's own window shortcuts -- the ones internal/help/keys.go compiles in as ID, Keys, Label and Section -- without touching the binary.
This is a different layer from the Claude Code CLI's own keybindings.json (~/.claude/keybindings.json), which remaps keystrokes inside the terminal tool running in a pane. That file is read by the agent running in the pane; this one is read by the window around it, for the chords the window intercepts before a pane ever sees them.
help.Keys stays the source of defaults and metadata -- label, section, help page, palette eligibility. This package holds only the overrides: a map of action id to a binding, absent meaning "use the built-in default." A future release that adds an action, or changes a default nobody has touched, needs no migration here.
Index ¶
Constants ¶
const FileName = "keybindings.json"
FileName is where the overrides are kept, in the state directory -- its own file for its own concern, following agents.json and remote.json rather than growing prefs.json.
const Version = 1
Version is the schema version written into the file. Nothing rejects a file for its version: the map is additive, and refusing to start with somebody's remapping because a newer build wrote a 2 into it would be a poor trade for a field nothing reads.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConflictError ¶
type ConflictError struct {
// Keys is the binding that was asked for.
Keys string
// With is the action that already has it.
With help.Key
}
ConflictError is returned when a binding would collide with another action's, whether that action's own default or its own override. Two actions can never share a chord: whichever ran second would simply never run.
func (*ConflictError) Error ¶
func (e *ConflictError) Error() string
type File ¶
type File struct {
Version int `json:"version"`
// Overrides maps an action's id (help.Key.ID) to the binding it has been
// given instead of its built-in default. An id mapped to "" has
// deliberately been given no binding at all -- reachable from the command
// palette alone -- which is different from the id being absent, which
// means the default.
Overrides map[string]string `json:"overrides,omitempty"`
}
File is keybindings.json as it is written on disk.
func Load ¶
Load reads the overrides. Absent or damaged, they are no overrides at all -- every binding is the built-in default -- and never a startup failure, the same way ReadPrefs treats a missing or damaged prefs.json.
func ResetBinding ¶
ResetBinding takes id back to its built-in default, removing whatever override it had -- including one that deliberately gave it no binding.
func SetBinding ¶
SetBinding gives action id the binding keys, or takes its binding away for keys == "" -- reachable from the command palette alone, like the actions that have always had no binding. It refuses a binding already given to another action, and one that cannot be expressed as a single chord (what help.Key.Keys marks with "…", for selectTab's Alt+1 … Alt+9 range, which is not remappable).
A binding set back to exactly the built-in default is not kept as an override: a future release changing that default should reach somebody who never touched this action, the same way an absent field in prefs.json means the default rather than freezing whatever the default happened to be when the file was written.