Skip to content

Commit

Permalink
Only canonicalize alphabetic keys
Browse files Browse the repository at this point in the history
The Kitty keyboard protocol separates out the shift modifier for a
bunch of these keys, I think based on default english keyboard
layouts (?).

This is a little mind-bending since I get an `A-S-9` key event when
I press `A-)` on my keyboard but my keyboard is mapped so that this
particular chord doesn't include shift.

This most likely isn't all of the keys that need to be remapped in the
default keymap. Perhaps we can do some magic in `canonicalize_key` to
match the expected keys?
  • Loading branch information
the-mikedavis committed Jan 11, 2023
1 parent 57d63a3 commit 4be72f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions helix-term/src/keymap/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ pub fn default() -> HashMap<Mode, Keymap> {

"(" => rotate_selections_backward,
")" => rotate_selections_forward,
"A-(" => rotate_selection_contents_backward,
"A-)" => rotate_selection_contents_forward,
"A-(" | "A-S-9" => rotate_selection_contents_backward,
"A-)" | "A-S-0" => rotate_selection_contents_forward,

"A-:" => ensure_selections_forward,

Expand Down Expand Up @@ -329,7 +329,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
"|" => shell_pipe,
"A-|" => shell_pipe_to,
"!" => shell_insert_output,
"A-!" => shell_append_output,
"A-!" | "A-S-1" => shell_append_output,
"$" => shell_keep_pipe,
"C-z" => suspend,

Expand Down
12 changes: 6 additions & 6 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1641,11 +1641,11 @@ impl Component for EditorView {
}

fn canonicalize_key(key: &mut KeyEvent) {
if let KeyEvent {
code: KeyCode::Char(_),
modifiers: _,
} = key
{
key.modifiers.remove(KeyModifiers::SHIFT)
match key {
KeyEvent {
code: KeyCode::Char(char),
modifiers: _,
} if char.is_alphabetic() => key.modifiers.remove(KeyModifiers::SHIFT),
_ => (),
}
}

0 comments on commit 4be72f7

Please sign in to comment.