keys

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package keys is the binding registry (doc 02 section 12). Every keystroke the UI acts on is a semantic Action bound in one scope; config rebinds by Action name, the help line reads the live binding, and a collision inside a scope is a load error rather than a silent winner.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action int

Action names a semantic action, not a key.

const (
	// Global scope.
	Quit Action = iota
	HelpToggle
	Palette
	ThemePick
	Cancel
	FocusNext

	// Editor scope.
	Submit
	Newline
	ExternalEditor

	// Chat scope.
	ScrollUp
	ScrollDown
	PageUp
	PageDown
	GotoBottom

	// Dialog scope.
	Confirm
	NextChoice
	PrevChoice

	// Diff scope: the edit-result and approval diff view.
	NextHunk
	PrevHunk
	ToggleDiff
	DiffLeft
	DiffRight
)

func (Action) String

func (a Action) String() string

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map is the full live keymap. The zero value is unusable; start from Default and overlay config with Apply.

func Default

func Default() Map

Default returns the built-in bindings.

func (Map) Apply

func (m Map) Apply(overrides map[string][]string) (Map, error)

Apply overlays user bindings, keyed by action name, then validates. A rebind replaces the whole key set for that action; the first key listed becomes the one help shows. Unknown action names and same- scope collisions are errors, listed exhaustively so one config pass fixes them all.

func (Map) Binding

func (m Map) Binding(a Action) key.Binding

Binding returns the live binding for an action, for help rendering.

func (Map) Help

func (m Map) Help(scope Scope) []key.Binding

Help projects the short help for a scope plus the always-on globals, in a stable order, reading the live bindings so a rebind shows up.

func (Map) Lookup

func (m Map) Lookup(scope Scope, keystroke string) (Action, bool)

Lookup matches a key string against one scope only; the caller has already decided the scope. The bool reports a match.

type Scope

type Scope int

Scope is where a binding applies. The router decides scope before matching keys: an open dialog owns input, else the focused pane, else global, so one key can mean different things without ambiguity.

const (
	Global Scope = iota
	Editor
	Chat
	Dialog
	Diff
)

func (Scope) String

func (s Scope) String() string

Jump to

Keyboard shortcuts

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