module Obsctl::TUI::Keymap

Overview

The multi-key half of the dashboard keymap, in the shape an AstroNvim user already has in their fingers: a leader key that opens a which-key menu, g for goto motions, and Ctrl-w for window moves.

Single-key bindings stay in Input because they resolve without any pending state. Everything here is a sequence, so it lives in one table that both the resolver and the which-key panel read — a binding cannot be dispatchable but missing from the menu, or listed but unbound.

Extended Modules

Defined in:

obsctl/tui/keymap.cr

Constant Summary

BINDINGS = [Binding.new("gg", ActionKind::NavigateTop, "first item"), Binding.new("G", ActionKind::NavigateBottom, "last item"), Binding.new("<C-d>", ActionKind::NavigateHalfPageDown, "half page down"), Binding.new("<C-u>", ActionKind::NavigateHalfPageUp, "half page up"), Binding.new("<C-w>h", ActionKind::FocusPaneLeft, "pane left"), Binding.new("<C-w>j", ActionKind::FocusPaneDown, "pane down"), Binding.new("<C-w>k", ActionKind::FocusPaneUp, "pane up"), Binding.new("<C-w>l", ActionKind::FocusPaneRight, "pane right"), Binding.new("#{LEADER}q", ActionKind::Quit, "quit"), Binding.new("#{LEADER}m", ActionKind::ToggleMute, "toggle mute"), Binding.new("#{LEADER}fs", ActionKind::FocusScenes, "scenes"), Binding.new("#{LEADER}fa", ActionKind::FocusAudio, "audio"), Binding.new("#{LEADER}fp", ActionKind::FocusProfiles, "profiles"), Binding.new("#{LEADER}fc", ActionKind::FocusCollections, "collections"), Binding.new("#{LEADER}ut", ActionKind::OpenSettings, "themes"), Binding.new("#{LEADER}or", ActionKind::ReloadConfig, "reload config"), Binding.new("#{LEADER}od", ActionKind::DumpConfig, "dump config"), Binding.new("#{LEADER}oc", ActionKind::RetryConnect, "reconnect")]
GROUPS = {LEADER => "obsctl", "#{LEADER}f" => "find", "#{LEADER}u" => "ui", "#{LEADER}o" => "obs", "g" => "goto", "<C-w>" => "window"}

Titles for the prefixes that are groups rather than commands.

LEADER = "<leader>"

Space, the AstroNvim leader. Written as a token so sequences read the way they do in a Neovim config rather than starting with a space.

Instance Method Summary

Instance Method Detail

def [](sequence : String) : ActionKind | Nil #

The action a completed sequence runs, or nil when it is not a binding.


[View source]
def continuations(pending : String) : Array(Entry) #

Every key that can follow pending, for the which-key panel and for clicks on it. Sorted so the menu order is stable between frames.


[View source]
def prefix?(sequence : String) : Bool #

True when at least one binding continues past sequence, which is what makes a key worth holding onto instead of discarding.


[View source]
def title(pending : String) : String #

What the which-key panel calls the sequence being typed.


[View source]
def token(key : CryTUI::KeyEvent) : String | Nil #

The key token for a press, or nil for keys that never start a sequence.


[View source]
def tokens(sequence : String) : Array(String) #

Splits a sequence into keys, keeping <...> tokens whole.


[View source]