removed shift matching

This commit is contained in:
Jan Hrastnik 2021-06-02 22:45:36 +02:00 committed by Blaž Hrastnik
parent abe8a83d8e
commit 712f25c2b9
2 changed files with 21 additions and 25 deletions

View file

@ -103,15 +103,6 @@ macro_rules! key {
}; };
} }
macro_rules! shift {
($($ch:tt)*) => {
KeyEvent {
code: KeyCode::Char($($ch)*),
modifiers: KeyModifiers::SHIFT,
}
};
}
macro_rules! ctrl { macro_rules! ctrl {
($($ch:tt)*) => { ($($ch:tt)*) => {
KeyEvent { KeyEvent {
@ -139,8 +130,8 @@ pub fn default() -> Keymaps {
key!('t') => commands::find_till_char, key!('t') => commands::find_till_char,
key!('f') => commands::find_next_char, key!('f') => commands::find_next_char,
shift!('T') => commands::till_prev_char, key!('T') => commands::till_prev_char,
shift!('F') => commands::find_prev_char, key!('F') => commands::find_prev_char,
// and matching set for select mode (extend) // and matching set for select mode (extend)
// //
key!('r') => commands::replace, key!('r') => commands::replace,
@ -157,11 +148,11 @@ pub fn default() -> Keymaps {
key!(':') => commands::command_mode, key!(':') => commands::command_mode,
key!('i') => commands::insert_mode, key!('i') => commands::insert_mode,
shift!('I') => commands::prepend_to_line, key!('I') => commands::prepend_to_line,
key!('a') => commands::append_mode, key!('a') => commands::append_mode,
shift!('A') => commands::append_to_line, key!('A') => commands::append_to_line,
key!('o') => commands::open_below, key!('o') => commands::open_below,
shift!('O') => commands::open_above, key!('O') => commands::open_above,
// [<space> ]<space> equivalents too (add blank new line, no edit) // [<space> ]<space> equivalents too (add blank new line, no edit)
@ -174,12 +165,12 @@ pub fn default() -> Keymaps {
key!('s') => commands::select_regex, key!('s') => commands::select_regex,
alt!('s') => commands::split_selection_on_newline, alt!('s') => commands::split_selection_on_newline,
shift!('S') => commands::split_selection, key!('S') => commands::split_selection,
key!(';') => commands::collapse_selection, key!(';') => commands::collapse_selection,
alt!(';') => commands::flip_selections, alt!(';') => commands::flip_selections,
key!('%') => commands::select_all, key!('%') => commands::select_all,
key!('x') => commands::select_line, key!('x') => commands::select_line,
shift!('X') => commands::extend_line, key!('X') => commands::extend_line,
// or select mode X? // or select mode X?
// extend_to_whole_line, crop_to_whole_line // extend_to_whole_line, crop_to_whole_line
@ -199,25 +190,25 @@ pub fn default() -> Keymaps {
key!('/') => commands::search, key!('/') => commands::search,
// ? for search_reverse // ? for search_reverse
key!('n') => commands::search_next, key!('n') => commands::search_next,
shift!('N') => commands::extend_search_next, key!('N') => commands::extend_search_next,
// N for search_prev // N for search_prev
key!('*') => commands::search_selection, key!('*') => commands::search_selection,
key!('u') => commands::undo, key!('u') => commands::undo,
shift!('U') => commands::redo, key!('U') => commands::redo,
key!('y') => commands::yank, key!('y') => commands::yank,
// yank_all // yank_all
key!('p') => commands::paste_after, key!('p') => commands::paste_after,
// paste_all // paste_all
shift!('P') => commands::paste_before, key!('P') => commands::paste_before,
key!('>') => commands::indent, key!('>') => commands::indent,
key!('<') => commands::unindent, key!('<') => commands::unindent,
key!('=') => commands::format_selections, key!('=') => commands::format_selections,
shift!('J') => commands::join_selections, key!('J') => commands::join_selections,
// TODO: conflicts hover/doc // TODO: conflicts hover/doc
shift!('K') => commands::keep_selections, key!('K') => commands::keep_selections,
// TODO: and another method for inverse // TODO: and another method for inverse
// TODO: clashes with space mode // TODO: clashes with space mode
@ -256,7 +247,7 @@ pub fn default() -> Keymaps {
// move under <space>c // move under <space>c
ctrl!('c') => commands::toggle_comments, ctrl!('c') => commands::toggle_comments,
shift!('K') => commands::hover, key!('K') => commands::hover,
// z family for save/restore/combine from/to sels from register // 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!('t') => commands::extend_till_char,
key!('f') => commands::extend_next_char, key!('f') => commands::extend_next_char,
shift!('T') => commands::extend_till_prev_char, key!('T') => commands::extend_till_prev_char,
shift!('F') => commands::extend_prev_char, key!('F') => commands::extend_prev_char,
KeyEvent { KeyEvent {
code: KeyCode::Esc, code: KeyCode::Esc,

View file

@ -543,10 +543,15 @@ impl Component for EditorView {
cx.editor.resize(Rect::new(0, 0, width, height - 1)); cx.editor.resize(Rect::new(0, 0, width, height - 1));
EventResult::Consumed(None) EventResult::Consumed(None)
} }
Event::Key(key) => { Event::Key(mut key) => {
// clear status // clear status
cx.editor.status_msg = None; cx.editor.status_msg = None;
//canonicalize the key
if key.modifiers == KeyModifiers::SHIFT {
key.modifiers = KeyModifiers::NONE;
}
let (view, doc) = cx.editor.current(); let (view, doc) = cx.editor.current();
let mode = doc.mode(); let mode = doc.mode();