Skip to content

Commit 88d1efa

Browse files
Add disambiguated keycodes to default keymaps
With the enhanced keyboard protocol enabled, some additional key combinations must be added to the defaults. Mostly this involves combinations that couldn't be disambiguated without the enhanced keyboard protocol like 'S-backspace'. Some other key combinations change the way that the KeyEvent is structured. For example, `A-_` becomes `A-S-minus`. Co-authored-by: lesleyrs <[email protected]>
1 parent 59c6e6e commit 88d1efa

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

book/src/keymap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ experience.
350350
| `Alt-d`, `Alt-Delete` | Delete next word | `delete_word_forward` |
351351
| `Ctrl-u` | Delete to start of line | `kill_to_line_start` |
352352
| `Ctrl-k` | Delete to end of line | `kill_to_line_end` |
353-
| `Ctrl-h`, `Backspace` | Delete previous char | `delete_char_backward` |
353+
| `Ctrl-h`, `Backspace`, `Shift-Backspace` | Delete previous char | `delete_char_backward` |
354354
| `Ctrl-d`, `Delete` | Delete next char | `delete_char_forward` |
355355
| `Ctrl-j`, `Enter` | Insert new line | `insert_newline` |
356356

@@ -431,7 +431,7 @@ Keys to use within prompt, Remapping currently not supported.
431431
| `Alt-d`, `Alt-Delete`, `Ctrl-Delete` | Delete next word |
432432
| `Ctrl-u` | Delete to start of line |
433433
| `Ctrl-k` | Delete to end of line |
434-
| `Backspace`, `Ctrl-h` | Delete previous char |
434+
| `Backspace`, `Ctrl-h`, `Shift-Backspace` | Delete previous char |
435435
| `Delete`, `Ctrl-d` | Delete next char |
436436
| `Ctrl-s` | Insert a word under doc cursor, may be changed to Ctrl-r Ctrl-w later |
437437
| `Ctrl-p`, `Up` | Select previous history |

helix-term/src/keymap/default.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
7979

8080
"s" => select_regex,
8181
"A-s" => split_selection_on_newline,
82-
"A-_" => merge_consecutive_selections,
82+
"A-_" | "A-S-minus" => merge_consecutive_selections,
8383
"S" => split_selection,
8484
";" => collapse_selection,
8585
"A-;" => flip_selections,
@@ -167,8 +167,8 @@ pub fn default() -> HashMap<Mode, Keymap> {
167167

168168
"(" => rotate_selections_backward,
169169
")" => rotate_selections_forward,
170-
"A-(" => rotate_selection_contents_backward,
171-
"A-)" => rotate_selection_contents_forward,
170+
"A-(" | "A-S-9" => rotate_selection_contents_backward,
171+
"A-)" | "A-S-0" => rotate_selection_contents_forward,
172172

173173
"A-:" => ensure_selections_forward,
174174

@@ -313,7 +313,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
313313
"|" => shell_pipe,
314314
"A-|" => shell_pipe_to,
315315
"!" => shell_insert_output,
316-
"A-!" => shell_append_output,
316+
"A-!" | "A-S-1" => shell_append_output,
317317
"$" => shell_keep_pipe,
318318
"C-z" => suspend,
319319

@@ -363,7 +363,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
363363
"A-d" | "A-del" => delete_word_forward,
364364
"C-u" => kill_to_line_start,
365365
"C-k" => kill_to_line_end,
366-
"C-h" | "backspace" => delete_char_backward,
366+
"C-h" | "backspace" | "S-backspace" => delete_char_backward,
367367
"C-d" | "del" => delete_char_forward,
368368
"C-j" | "ret" => insert_newline,
369369
"tab" => insert_tab,

helix-term/src/ui/editor.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,11 +1447,11 @@ impl Component for EditorView {
14471447
}
14481448

14491449
fn canonicalize_key(key: &mut KeyEvent) {
1450-
if let KeyEvent {
1451-
code: KeyCode::Char(_),
1452-
modifiers: _,
1453-
} = key
1454-
{
1455-
key.modifiers.remove(KeyModifiers::SHIFT)
1450+
match key {
1451+
KeyEvent {
1452+
code: KeyCode::Char(char),
1453+
modifiers: _,
1454+
} if char.is_alphabetic() => key.modifiers.remove(KeyModifiers::SHIFT),
1455+
_ => (),
14561456
}
14571457
}

helix-term/src/ui/prompt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ impl Component for Prompt {
513513
alt!('d') | alt!(Delete) | ctrl!(Delete) => self.delete_word_forwards(cx.editor),
514514
ctrl!('k') => self.kill_to_end_of_line(cx.editor),
515515
ctrl!('u') => self.kill_to_start_of_line(cx.editor),
516-
ctrl!('h') | key!(Backspace) => {
516+
ctrl!('h') | key!(Backspace) | shift!(Backspace) => {
517517
self.delete_char_backwards(cx.editor);
518518
(self.callback_fn)(cx, &self.line, PromptEvent::Update);
519519
}

0 commit comments

Comments
 (0)