feat(keybindings): Ctrl+Arrow word navigation#58
Open
roramirez wants to merge 1 commit into
Open
Conversation
Ctrl+Left/Right/Up/Down now emit the xterm CSI 1;5 D/C/A/B sequences so shells (readline) and editors can jump by word. Ctrl+Shift+Arrow still resizes the active pane and Ctrl+PageUp/Down still switches tabs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
Ctrl+Arrow now sends the standard xterm word-navigation sequences to the PTY:
CSI 1;5DCSI 1;5CCSI 1;5ACSI 1;5BReadline-based shells (bash/zsh) and editors (vim, nano, micro) use these to jump word by word. mmterm did not emit them before.
Changes
src/input/keybindings.rs: 4 new arms inctrl_char_action(the Ctrl-without-Shift branch). No collision with Ctrl+Shift+Arrow (pane resize) or Ctrl+PageUp/Down (tab switching).src/input/keybindings_test.rs: tests for all 4 directions, one in Normal mode, plus a regression that Ctrl+Shift+→ still maps toResizePaneRight.CHANGELOG.md.How to test manually
cargo run.foo bar bazand leave the cursor at the end.Ctrl+←jumps to the start ofbaz; again to the start ofbar; etc.Ctrl+→jumps forward word by word.cat -v, then pressCtrl+←/Ctrl+→and confirm^[[1;5D/^[[1;5Cappear.Ctrl+Shift+←/→still resizes the active pane (does not move by word).Ctrl+PageUp/PageDownstill switches tabs.Tests
cargo test— full suite green (includesctrl_arrow_left_sends_word_back,ctrl_arrow_right_sends_word_forward,ctrl_arrow_up/down,ctrl_arrow_word_nav_works_in_normal_mode,ctrl_shift_arrow_right_still_resizes).