Add user-configurable keybindings#420
Conversation
|
I honestly don't know what to do with this. Reviewing 2810 lines of code is a lot of work, and I'd need to do that since I'm the one who'd have to maintain this if merged. Any suggestions? |
|
I think it's not too bad. A lot of the added lines are tests (+1311). My motivation comes from still looking for a not ancient pager with key binding support. That is a feature with a bigger audience then people might think, probably people like me who never got over You might want to start by looking at |
acdb997 to
8f5c75e
Compare
Users can now customise all key bindings by placing a file at
~/.config/moor/keybindings (or any path passed via --keybindings).
The file uses a simple INI-style format with one [section] per pager
mode. A !clear directive wipes the built-in defaults for a clean
slate.
New flags:
--keybindings <file> Load keybindings from a specific file
--print-default-keybindings Print the built-in bindings to stdout,
ready to use as a starting template
Each mode's key lookup falls back through a defined chain: the mode's
own bindings are checked first, then (for not-found mode) the viewing
bindings, and common actions are available everywhere.
Implementation notes:
- All pager modes carry a ModeBindings reference and dispatch through
it instead of hard-wired key checks.
- scrollToNextSearchHit / scrollToPreviousSearchHit now take an
explicit wrapAround bool instead of inspecting p.mode, removing
the mode-awareness from search logic. isNotFound() is gone.
- Status bar hints in viewing and goto-line modes are generated via
keyForAction so they reflect whatever the user has bound.
8f5c75e to
86787c8
Compare
Users can now customize keyboard shortcuts by placing a keybindings file at
~/.config/moor/keybindings(or$XDG_CONFIG_HOME/moor/keybindings).Usage
Print the built-in defaults as a ready-to-edit starting point:
Point moor at a specific file (errors are fatal):
File format
By default the file is overlaid on top of the defaults: only the keys you
list change, everything else stays as-is. Add
!clearat the top to startfrom a blank slate instead.
Error handling
--keybindings(explicit)Implementation notes
switch key / switch charblocks are replaced by atable-driven dispatch through
ModeBindings, with common scroll/quit/editactions factored into a single
executeCommonActionmethod on*Pager.What doesn't change
Default key bindings are identical to before. Users who don't create a config
file see no difference in behavior.
Related issues