Skip to main content

Module keymap

Module keymap 

Source
Expand description

Global keyboard shortcut resolver for the TUI.

Tasks 5 and 6 (settings-panel keybindings) and T8 (per-feature shortcuts merged from feat/tui-omp-ideas) consume GlobalAction, KeyCombo, and Keymap. The resolver is fully additive: user overrides in Settings::keybindings extend the default bindings rather than replacing the whole table; a user override for an action replaces only that action’s combo list (and only when the override list parses to at least one valid combo).

KeyCombo parses and serializes the canonical textual form used in settings files and in the /settings panel:

  • modifier prefix order is Ctrl+, Alt+, Shift+.
  • the char payload is uppercased when SHIFT is set, mirroring crossterm’s KeyEvent::normalize_case (shifted letter keys arrive as uppercase KeyCode::Char); parse normalizes the input the same way so a shift-letter combo parses canonically regardless of case.
  • named keys (Enter, Esc, Tab, Backspace, PageUp, PageDown, arrow keys, Home, End, BackTab, Delete) keep their literal names; the parser maps lower-case variants too.

Note: the original feat/tui-omp-ideas branch shipped its own KeyAction enum + ~/.oxicode/keybindings.yml loader + KeyCombo struct + matches/conflicts API. The squash merged that into the established GlobalAction resolver: every KeyAction variant maps to a GlobalAction (Submit→Submit, SubmitNow→SendNow, QueueToggle→ ToggleQueuePanel, Interrupt→Interrupt, Clear→FoldAll, ModelPicker→ OpenCommandPalette, ToggleThinking→ToggleMultiline, Help→Help, ScrollUp→ ScrollUp, ScrollDown→ScrollDown). The YAML loader is dropped in favor of Settings::keybindings.

Structs§

KeyCombo
Keymap

Enums§

GlobalAction
Every remappable action in the TUI. The set is the union of the settings-panel’s GlobalAction (FoldAll/SendNow/etc.) and the feat/tui-omp-ideas branch’s KeyAction (Submit/ScrollUp/etc.). Each variant maps to a single user-visible keybinding in the TUI; char-level composer input (typing, vim insert mode) is NOT represented here and is left untouched.

Constants§

DEFAULT_KEYBINDINGS
Default bindings. Combos mirror the keys that were hardcoded in the input dispatch before this module existed (settings-panel work) plus the keys introduced by feat/tui-omp-ideas (Submit, ScrollUp/Down, Clear, Help, ModelPicker, ToggleThinking). The order matters: GlobalAction::all / Keymap::resolve iterate in this order, so when two actions share a combo (only reachable via user overrides) the earlier action wins — deterministically across runs.