keybindings

package
v0.3.30 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 9 Imported by: 0 modules, 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

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

View Source
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.

View Source
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

func Effective

func Effective(overrides map[string]string) []help.Key

Effective returns help.Keys with every override applied: each entry's Keys replaced by what overrides gives its ID, when it gives one. help.Keys itself is never modified.

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

func Load() (*File, error)

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 ResetAll

func ResetAll() (*File, error)

ResetAll takes every binding back to its built-in default.

func ResetBinding

func ResetBinding(id string) (*File, error)

ResetBinding takes id back to its built-in default, removing whatever override it had -- including one that deliberately gave it no binding.

func SetBinding

func SetBinding(id, keys string) (*File, error)

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.

Jump to

Keyboard shortcuts

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