From 712f25c2b952672d496d393552d1545d54de3d51 Mon Sep 17 00:00:00 2001 From: Jan Hrastnik Date: Wed, 2 Jun 2021 22:45:36 +0200 Subject: [PATCH] removed shift matching --- helix-term/src/keymap.rs | 39 ++++++++++++++----------------------- helix-term/src/ui/editor.rs | 7 ++++++- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index fc7bb86e..de569656 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -103,15 +103,6 @@ macro_rules! key { }; } -macro_rules! shift { - ($($ch:tt)*) => { - KeyEvent { - code: KeyCode::Char($($ch)*), - modifiers: KeyModifiers::SHIFT, - } - }; -} - macro_rules! ctrl { ($($ch:tt)*) => { KeyEvent { @@ -139,8 +130,8 @@ pub fn default() -> Keymaps { key!('t') => commands::find_till_char, key!('f') => commands::find_next_char, - shift!('T') => commands::till_prev_char, - shift!('F') => commands::find_prev_char, + key!('T') => commands::till_prev_char, + key!('F') => commands::find_prev_char, // and matching set for select mode (extend) // key!('r') => commands::replace, @@ -157,11 +148,11 @@ pub fn default() -> Keymaps { key!(':') => commands::command_mode, key!('i') => commands::insert_mode, - shift!('I') => commands::prepend_to_line, + key!('I') => commands::prepend_to_line, key!('a') => commands::append_mode, - shift!('A') => commands::append_to_line, + key!('A') => commands::append_to_line, key!('o') => commands::open_below, - shift!('O') => commands::open_above, + key!('O') => commands::open_above, // [ ] equivalents too (add blank new line, no edit) @@ -174,12 +165,12 @@ pub fn default() -> Keymaps { key!('s') => commands::select_regex, alt!('s') => commands::split_selection_on_newline, - shift!('S') => commands::split_selection, + key!('S') => commands::split_selection, key!(';') => commands::collapse_selection, alt!(';') => commands::flip_selections, key!('%') => commands::select_all, key!('x') => commands::select_line, - shift!('X') => commands::extend_line, + key!('X') => commands::extend_line, // or select mode X? // extend_to_whole_line, crop_to_whole_line @@ -199,25 +190,25 @@ pub fn default() -> Keymaps { key!('/') => commands::search, // ? for search_reverse key!('n') => commands::search_next, - shift!('N') => commands::extend_search_next, + key!('N') => commands::extend_search_next, // N for search_prev key!('*') => commands::search_selection, key!('u') => commands::undo, - shift!('U') => commands::redo, + key!('U') => commands::redo, key!('y') => commands::yank, // yank_all key!('p') => commands::paste_after, // paste_all - shift!('P') => commands::paste_before, + key!('P') => commands::paste_before, key!('>') => commands::indent, key!('<') => commands::unindent, key!('=') => commands::format_selections, - shift!('J') => commands::join_selections, + key!('J') => commands::join_selections, // TODO: conflicts hover/doc - shift!('K') => commands::keep_selections, + key!('K') => commands::keep_selections, // TODO: and another method for inverse // TODO: clashes with space mode @@ -256,7 +247,7 @@ pub fn default() -> Keymaps { // move under c ctrl!('c') => commands::toggle_comments, - shift!('K') => commands::hover, + key!('K') => commands::hover, // z family for save/restore/combine from/to sels from register @@ -284,8 +275,8 @@ pub fn default() -> Keymaps { key!('t') => commands::extend_till_char, key!('f') => commands::extend_next_char, - shift!('T') => commands::extend_till_prev_char, - shift!('F') => commands::extend_prev_char, + key!('T') => commands::extend_till_prev_char, + key!('F') => commands::extend_prev_char, KeyEvent { code: KeyCode::Esc, diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 15e64b72..19db3fa7 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -543,10 +543,15 @@ impl Component for EditorView { cx.editor.resize(Rect::new(0, 0, width, height - 1)); EventResult::Consumed(None) } - Event::Key(key) => { + Event::Key(mut key) => { // clear status cx.editor.status_msg = None; + //canonicalize the key + if key.modifiers == KeyModifiers::SHIFT { + key.modifiers = KeyModifiers::NONE; + } + let (view, doc) = cx.editor.current(); let mode = doc.mode();