Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@nicholasjpaterno
Copy link
Contributor

No description provided.

Implements a comprehensive keybinding system that allows users to customize
keyboard shortcuts via TOML configuration files.

Key features:
- Mode-based keybinding architecture (Normal, Interactive, LinkFollow, etc.)
- 50+ bindable actions covering all application functionality
- Flexible key string parsing ("ctrl-c", "alt-enter", "shift-tab")
- Default keybindings matching existing vim-style shortcuts
- User keybindings merge with defaults (user config takes precedence)
- Dynamic help text generation reflecting actual key mappings

Configuration example (in ~/.config/treemd/config.toml):
```toml
[keybindings.Normal]
"ctrl-q" = "Quit"
"space" = "ToggleExpand"

[keybindings.LinkFollow]
"ctrl-enter" = "FollowLink"
```

This lays the groundwork for a future keybinding settings modal similar
to the theme picker.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Add keybinds-rs crate with crossterm and serde features to provide
robust multi-key sequence support and pattern-based key matching.
Also update strum to 0.27 for improved enum derivation capabilities.
Replace custom key parsing logic with keybinds-rs, providing:
- Multi-key sequence support (e.g., 'g g', 'Ctrl+x Ctrl+c')
- Simplified dispatch API via KeybindingMode
- Consistent key string format across all platforms
- Removed parse.rs module in favor of keybinds-rs parser

The new system maintains all existing keybindings while enabling
advanced features like multi-key sequences and custom patterns.
Update TUI integration to use the new keybindings dispatch API:
- Call dispatch() instead of get_action() with KeyCode/KeyModifiers
- Use is_sequence_ongoing() to handle multi-key sequences
- Pass crossterm KeyEvent directly to dispatch method
- Minor help text formatting updates

These changes maintain the existing functionality while supporting
the new multi-key sequence capabilities.
Add detailed documentation for the new custom keybindings feature:
- Keybinding syntax guide (single keys, modifiers, sequences, special keys)
- Complete list of available modes with descriptions
- Example configuration showing common patterns
- Notes on key format conventions

Also update navigation keybinding descriptions in the shortcuts table
for clarity and consistency.
@nicholasjpaterno
Copy link
Contributor Author

cc @firecat53 - I made this PR with you in mind. This should enable custom keys! If you have a chance to check out this branch and ensure it works great for your usecase and keybindings!

@firecat53
Copy link

Keybindings seem to work. However:

  1. When I assign "K" = "JumpToParent" it only works when I'm in the outline tab. I would expect the binding to work in the main document as well.
  2. I think you need more JumpTo.... options. JumpToNextChild, JumpToPrevChild, JumpToNextSibling, JumpToPrevSibling, JumpToRoot (top of main document, not just top of the current section).

@firecat53
Copy link

Also, the "PageUp" and "PageDown" actions don't work in the Help mode.

@firecat53
Copy link

ToggleExpand and ToggleOutline are the same. Maybe ToggleExpand could cycle through each of the outline widths, including hidden, and ToggleOutline can just hide/show the outline at the current width.

@nicholasjpaterno
Copy link
Contributor Author

@firecat53 you are the amazing! Working on these in the next 15-20mins!

nicholasjpaterno added a commit that referenced this pull request Dec 10, 2025
- JumpToParent now works in both Outline and Content focus
- PageDown/PageUp now properly scroll help popup when in Help mode
- Add scroll_help_page_down/up methods for half-page scrolling
@nicholasjpaterno
Copy link
Contributor Author

Moving this to #35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants