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 ¶
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 ¶
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 ¶
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.
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.
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 Resolve ¶
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
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.