keymap

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 5 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 keymap is what a key pressed after conch's prefix does, and which key that is. The prefix table is tmux's, key for key, so somebody who has rebound tmux's wants to rebind conch's: `[keys.bind]` in config.toml names an action and the key that runs it, the way tmux's bind-key does.

It is a package of its own, and not part of the TUI, because more than the TUI has to talk about these: `conch keys` lists them, `conch doctor` says when one is bound to nothing or twice, and the settings page offers the names. An action's name is a promise to somebody's config.toml — renaming one breaks their file silently, so a name here is kept.

Index

Constants

This section is empty.

Variables

View Source
var Defaults = map[Action][]string{
	SplitRight:      {"v", "%", "|"},
	SplitDown:       {"-", `"`, "_"},
	CloseSplit:      {"x"},
	FocusLeft:       {"left", "h"},
	FocusRight:      {"right"},
	FocusUp:         {"up", "k"},
	FocusDown:       {"down", "j"},
	NextSplit:       {"o"},
	LastSplit:       {";"},
	SwapPrev:        {"{"},
	SwapNext:        {"}"},
	Numbers:         {"q"},
	Equalize:        {"="},
	NextLayout:      {" "},
	LayoutEvenH:     {"alt+1"},
	LayoutEvenV:     {"alt+2"},
	LayoutMainH:     {"alt+3"},
	LayoutMainV:     {"alt+4"},
	LayoutTiled:     {"alt+5"},
	Zoom:            {"z"},
	Back:            {"b"},
	NewTab:          {"c"},
	ChangesTab:      {"C"},
	NextTab:         {"n"},
	PrevTab:         {"p"},
	LastTab:         {"l"},
	MoveTab:         {"."},
	MoveTabLeft:     {"<"},
	MoveTabRight:    {">"},
	CloseTab:        {"&"},
	RenameTab:       {","},
	TabPicker:       {"w", "s"},
	NewWorkspace:    {"N"},
	PrevWorkspace:   {"("},
	NextWorkspace:   {")"},
	RenameWorkspace: {"$"},
	CloseWorkspace:  {"X"},
	ScrollMode:      {"[", "pgup"},
	Redraw:          {"r"},
	OpenLinks:       {"u"},
	MonitorQuiet:    {"M"},
	MonitorOutput:   {"A"},
	SyncPanes:       {"S"},
	NextWaiting:     {"!"},
	Palette:         {"/"},
	Ask:             {":"},
	Help:            {"?"},
	Detach:          {"d"},
}

Defaults is the key, or keys, each action answers to when nothing is rebound — tmux's own wherever tmux binds that thing.

Functions

func Normalize

func Normalize(key string) string

Normalize is a key as written in config.toml in conch's own spelling. tmux's is taken too — `C-a`, `M-x`, `Space` — because somebody rebinding conch's prefix table has tmux's in front of them, and a key that silently never matches is the worst way to find that out.

func Show

func Show(key string) string

Show is a key as it is shown to somebody — the arrows as arrows, space as a word rather than a blank in the middle of a list.

func ShowAll

func ShowAll(keys []string) string

ShowAll is the keys of one action, as a key column shows them.

func What

func What(a Action) string

What is what an action does, for a list or a label.

Types

type Action

type Action string

Action is something a key after the prefix does. Its value is the name written in config.toml.

const (
	SplitRight  Action = "split_right"
	SplitDown   Action = "split_down"
	CloseSplit  Action = "close_split"
	FocusLeft   Action = "focus_left"
	FocusRight  Action = "focus_right"
	FocusUp     Action = "focus_up"
	FocusDown   Action = "focus_down"
	NextSplit   Action = "next_split"
	LastSplit   Action = "last_split"
	SwapPrev    Action = "swap_split_left"
	SwapNext    Action = "swap_split_right"
	Numbers     Action = "split_numbers"
	Equalize    Action = "equalize"
	NextLayout  Action = "next_layout"
	LayoutEvenH Action = "layout_even_h"
	LayoutEvenV Action = "layout_even_v"
	LayoutMainH Action = "layout_main_h"
	LayoutMainV Action = "layout_main_v"
	LayoutTiled Action = "layout_tiled"
	Zoom        Action = "zoom"
	Back        Action = "back"

	NewTab       Action = "new_tab"
	ChangesTab   Action = "changes_tab"
	NextTab      Action = "next_tab"
	PrevTab      Action = "prev_tab"
	LastTab      Action = "last_tab"
	MoveTab      Action = "move_tab"
	MoveTabLeft  Action = "move_tab_left"
	MoveTabRight Action = "move_tab_right"
	CloseTab     Action = "close_tab"
	RenameTab    Action = "rename_tab"
	TabPicker    Action = "tab_picker"

	NewWorkspace    Action = "new_workspace"
	PrevWorkspace   Action = "prev_workspace"
	NextWorkspace   Action = "next_workspace"
	RenameWorkspace Action = "rename_workspace"
	CloseWorkspace  Action = "close_workspace"

	ScrollMode    Action = "scroll_mode"
	Redraw        Action = "redraw"
	OpenLinks     Action = "open_links"
	MonitorQuiet  Action = "monitor_quiet"
	MonitorOutput Action = "monitor_output"
	SyncPanes     Action = "sync_panes"

	NextWaiting Action = "next_waiting"
	Palette     Action = "palette"
	Ask         Action = "ask"
	Help        Action = "help"
	Detach      Action = "detach"
)

Every action a key can be bound to. The comment on each is what `conch keys` and the settings page say it does.

func Actions

func Actions() []Action

Actions is every action there is, in a settled order: the order they are listed in, which is the order `conch keys` prints and the docs follow.

type Map

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

Map says what each key does after the prefix, both ways round: by key to route a press, and by action to say which key to press.

Its zero value is the default keys, not no keys. Everything that holds one of these holds it by value — a Model copied for every message, a test that builds one field by field — and a zero Map that answered nothing would be a conch whose prefix table did nothing at all, which is a worse failure than any mistake in config.toml.

func Default

func Default() Map

Default is the map with nothing rebound.

func Resolve

func Resolve(bind map[string]string) (Map, []string)

Resolve reads a `[keys.bind]` table — an action's name to the key that runs it — into a Map, and says what was wrong with it rather than quietly dropping it. The rules, which are tmux's:

  • what is not named keeps its default keys;
  • a key named for one action is taken off whatever default held it, so rebinding never needs the other action unbound first;
  • an empty key (or "none") unbinds the action, as tmux's unbind-key;
  • two actions on one key is a mistake, not a race: the first in alphabetical order keeps it and the other is reported, so the same file always gives the same keys.

Nothing here can leave conch unreachable: the prefix is `[keys] prefix`, not an action, and a file that is all mistakes is a help overlay with nothing in its key column — never a TUI that cannot be typed at.

func ResolveFor added in v0.1.10

func ResolveFor(bind map[string]string, prefix string) (Map, []string)

ResolveFor is Resolve for a prefix: a binding on the prefix key itself is taken out and said, since the prefix twice is how a program below conch is given its own ctrl+b, so an action there could never be pressed and would quietly cost somebody that. The TUI and Conch.app (through conch keys -json) both read the table this way, so the same file gives the same keys in each.

func (Map) Action

func (m Map) Action(key string) Action

Action is what key does, or "" if it does nothing.

func (Map) Bound

func (m Map) Bound(a Action) bool

Bound reports whether a can be pressed at all.

func (Map) Key

func (m Map) Key(a Action) string

Key is the first key an action answers to, or "" when it is unbound.

func (Map) Keys

func (m Map) Keys(a Action) []string

Keys is the keys an action answers to, in the order they are shown. It is empty for an action somebody has unbound.

func (Map) Rebound

func (m Map) Rebound(a Action) bool

Rebound reports whether anything in config.toml moved this action, which is what makes a hint worth spelling out rather than assuming.

Jump to

Keyboard shortcuts

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