keymap

package
v1.23.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package keymap maps the normal-mode action keys (inspect, logs, filter, …) to the keys that trigger them, loaded from the same d9c-config.yaml file the theme uses. It ships sensible defaults and lets the user remap any action via a "keys:" section without touching navigation (j/k/arrows), Enter or the exit keys (q/esc/Ctrl+C), which stay fixed so the app can never lock itself out.

Example d9c-config.yaml:

keys:                # optional; only the actions you want to change
  logs: g            # show logs with "g" instead of "l"
  filter: f          # filter with "f" instead of "/"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Names

func Names() []string

Names returns the configurable action names in stable order (for docs/errors).

Types

type Action

type Action string

Action identifies a remappable normal-mode action. The string value is also the key used under "keys:" in the config file.

const (
	Inspect   Action = "inspect"
	Logs      Action = "logs"
	Edit      Action = "edit"
	Exec      Action = "exec"
	Filter    Action = "filter"
	Command   Action = "command"
	ToggleAll Action = "toggle-all"
	Stats     Action = "stats"
	Select    Action = "select"
	Copy      Action = "copy"
	Refresh   Action = "refresh"
	Pause     Action = "pause"
	Help      Action = "help"
)

The remappable normal-mode actions. Navigation, Enter and the exit keys are intentionally not actions: they stay fixed.

func Actions

func Actions() []Action

Actions returns every action in stable order (for the help screen).

type Map

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

Map binds actions to keys (and the reverse, for key dispatch). The zero value is unusable; build one with Default or Resolve.

func Default

func Default() Map

Default returns the built-in key bindings.

func Load

func Load(path string) (Map, error)

Load reads the config file at path and resolves its "keys:" overrides on top of the defaults. A missing file yields the defaults (not an error); malformed YAML, an unknown action, an empty/reserved key, or a key bound to two actions is an error.

func Resolve

func Resolve(overrides map[string]string) (Map, error)

Resolve applies the given action→key overrides on top of the defaults, validating action names, keys and conflicts. A nil/empty map yields the defaults unchanged.

func (Map) ActionFor

func (m Map) ActionFor(key string) (Action, bool)

ActionFor returns the action a key triggers, reporting whether one is bound.

func (Map) Display

func (m Map) Display(a Action) string

Display returns a human-readable label for the key bound to an action (e.g. "space" for the space key), for use in the help screen.

func (Map) KeyFor

func (m Map) KeyFor(a Action) string

KeyFor returns the key bound to the action (empty if the action is unknown).

Jump to

Keyboard shortcuts

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