summaryrefslogtreecommitdiff
path: root/src/normal.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-10-26 18:42:36 +0100
committerMaxime Coste <frrrwww@gmail.com>2013-10-26 18:42:36 +0100
commitcf6c07d37dc1c81ec50d50404b8161d5f041b398 (patch)
treefb8505ebc74e1018d02458547c8cca31194d163c /src/normal.cc
parent0746e7309eb6159ab93e4603ddcd6df36094bd39 (diff)
Specify key modifiers using constexpr functions for brevity
Diffstat (limited to 'src/normal.cc')
-rw-r--r--src/normal.cc248
1 files changed, 124 insertions, 124 deletions
diff --git a/src/normal.cc b/src/normal.cc
index 9b453907..7f2c9568 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -885,132 +885,132 @@ void move(Context& context, int count)
KeyMap keymap =
{
- { { Key::Modifiers::None, 'h' }, move<CharCount, Backward> },
- { { Key::Modifiers::None, 'j' }, move<LineCount, Forward> },
- { { Key::Modifiers::None, 'k' }, move<LineCount, Backward> },
- { { Key::Modifiers::None, 'l' }, move<CharCount, Forward> },
-
- { { Key::Modifiers::None, 'H' }, move<CharCount, Backward, SelectMode::Extend> },
- { { Key::Modifiers::None, 'J' }, move<LineCount, Forward, SelectMode::Extend> },
- { { Key::Modifiers::None, 'K' }, move<LineCount, Backward, SelectMode::Extend> },
- { { Key::Modifiers::None, 'L' }, move<CharCount, Forward, SelectMode::Extend> },
-
- { { Key::Modifiers::None, 't' }, select_to_next_char<SelectFlags::None> },
- { { Key::Modifiers::None, 'f' }, select_to_next_char<SelectFlags::Inclusive> },
- { { Key::Modifiers::None, 'T' }, select_to_next_char<SelectFlags::Extend> },
- { { Key::Modifiers::None, 'F' }, select_to_next_char<SelectFlags::Inclusive | SelectFlags::Extend> },
- { { Key::Modifiers::Alt, 't' }, select_to_next_char<SelectFlags::Reverse> },
- { { Key::Modifiers::Alt, 'f' }, select_to_next_char<SelectFlags::Inclusive | SelectFlags::Reverse> },
- { { Key::Modifiers::Alt, 'T' }, select_to_next_char<SelectFlags::Extend | SelectFlags::Reverse> },
- { { Key::Modifiers::Alt, 'F' }, select_to_next_char<SelectFlags::Inclusive | SelectFlags::Extend | SelectFlags::Reverse> },
-
- { { Key::Modifiers::None, 'd' }, erase_selections },
- { { Key::Modifiers::None, 'c' }, change },
- { { Key::Modifiers::None, 'i' }, insert<InsertMode::Insert> },
- { { Key::Modifiers::None, 'I' }, insert<InsertMode::InsertAtLineBegin> },
- { { Key::Modifiers::None, 'a' }, insert<InsertMode::Append> },
- { { Key::Modifiers::None, 'A' }, insert<InsertMode::AppendAtLineEnd> },
- { { Key::Modifiers::None, 'o' }, insert<InsertMode::OpenLineBelow> },
- { { Key::Modifiers::None, 'O' }, insert<InsertMode::OpenLineAbove> },
- { { Key::Modifiers::None, 'r' }, replace_with_char },
-
- { { Key::Modifiers::None, 'g' }, goto_commands<SelectMode::Replace> },
- { { Key::Modifiers::None, 'G' }, goto_commands<SelectMode::Extend> },
-
- { { Key::Modifiers::None, 'v' }, view_commands },
-
- { { Key::Modifiers::None, 'y' }, yank },
- { { Key::Modifiers::None, 'Y' }, cat_yank },
- { { Key::Modifiers::None, 'p' }, repeated(paste<InsertMode::Append>) },
- { { Key::Modifiers::None, 'P' }, repeated(paste<InsertMode::Insert>) },
- { { Key::Modifiers::Alt, 'p' }, paste<InsertMode::Replace> },
-
- { { Key::Modifiers::None, 's' }, select_regex },
- { { Key::Modifiers::None, 'S' }, split_regex },
- { { Key::Modifiers::Alt, 's' }, split_lines },
-
- { { Key::Modifiers::None, '.' }, repeat_insert },
-
- { { Key::Modifiers::None, '%' }, [](Context& context, int) { context.editor().clear_selections(); context.editor().select(select_whole_buffer); } },
-
- { { Key::Modifiers::None, ':' }, command },
- { { Key::Modifiers::None, '|' }, pipe },
- { { Key::Modifiers::None, ' ' }, [](Context& context, int count) { if (count == 0) context.editor().clear_selections();
+ { 'h', move<CharCount, Backward> },
+ { 'j', move<LineCount, Forward> },
+ { 'k', move<LineCount, Backward> },
+ { 'l', move<CharCount, Forward> },
+
+ { 'H', move<CharCount, Backward, SelectMode::Extend> },
+ { 'J', move<LineCount, Forward, SelectMode::Extend> },
+ { 'K', move<LineCount, Backward, SelectMode::Extend> },
+ { 'L', move<CharCount, Forward, SelectMode::Extend> },
+
+ { 't', select_to_next_char<SelectFlags::None> },
+ { 'f', select_to_next_char<SelectFlags::Inclusive> },
+ { 'T', select_to_next_char<SelectFlags::Extend> },
+ { 'F', select_to_next_char<SelectFlags::Inclusive | SelectFlags::Extend> },
+ { alt('t'), select_to_next_char<SelectFlags::Reverse> },
+ { alt('f'), select_to_next_char<SelectFlags::Inclusive | SelectFlags::Reverse> },
+ { alt('T'), select_to_next_char<SelectFlags::Extend | SelectFlags::Reverse> },
+ { alt('F'), select_to_next_char<SelectFlags::Inclusive | SelectFlags::Extend | SelectFlags::Reverse> },
+
+ { 'd', erase_selections },
+ { 'c', change },
+ { 'i', insert<InsertMode::Insert> },
+ { 'I', insert<InsertMode::InsertAtLineBegin> },
+ { 'a', insert<InsertMode::Append> },
+ { 'A', insert<InsertMode::AppendAtLineEnd> },
+ { 'o', insert<InsertMode::OpenLineBelow> },
+ { 'O', insert<InsertMode::OpenLineAbove> },
+ { 'r', replace_with_char },
+
+ { 'g', goto_commands<SelectMode::Replace> },
+ { 'G', goto_commands<SelectMode::Extend> },
+
+ { 'v', view_commands },
+
+ { 'y', yank },
+ { 'Y', cat_yank },
+ { 'p', repeated(paste<InsertMode::Append>) },
+ { 'P', repeated(paste<InsertMode::Insert>) },
+ { alt('p'), paste<InsertMode::Replace> },
+
+ { 's', select_regex },
+ { 'S', split_regex },
+ { alt('s'), split_lines },
+
+ { '.', repeat_insert },
+
+ { '%', [](Context& context, int) { context.editor().clear_selections(); context.editor().select(select_whole_buffer); } },
+
+ { ':', command },
+ { '|', pipe },
+ { ' ', [](Context& context, int count) { if (count == 0) context.editor().clear_selections();
else context.editor().keep_selection(count-1); } },
- { { Key::Modifiers::Alt, ' ' }, [](Context& context, int count) { if (count == 0) context.editor().flip_selections();
+ { alt(' '), [](Context& context, int count) { if (count == 0) context.editor().flip_selections();
else context.editor().remove_selection(count-1); } },
- { { Key::Modifiers::None, 'w' }, repeated(select<SelectMode::Replace>(select_to_next_word<Word>)) },
- { { Key::Modifiers::None, 'e' }, repeated(select<SelectMode::Replace>(select_to_next_word_end<Word>)) },
- { { Key::Modifiers::None, 'b' }, repeated(select<SelectMode::Replace>(select_to_previous_word<Word>)) },
- { { Key::Modifiers::None, 'W' }, repeated(select<SelectMode::Extend>(select_to_next_word<Word>)) },
- { { Key::Modifiers::None, 'E' }, repeated(select<SelectMode::Extend>(select_to_next_word_end<Word>)) },
- { { Key::Modifiers::None, 'B' }, repeated(select<SelectMode::Extend>(select_to_previous_word<Word>)) },
-
- { { Key::Modifiers::Alt, 'w' }, repeated(select<SelectMode::Replace>(select_to_next_word<WORD>)) },
- { { Key::Modifiers::Alt, 'e' }, repeated(select<SelectMode::Replace>(select_to_next_word_end<WORD>)) },
- { { Key::Modifiers::Alt, 'b' }, repeated(select<SelectMode::Replace>(select_to_previous_word<WORD>)) },
- { { Key::Modifiers::Alt, 'W' }, repeated(select<SelectMode::Extend>(select_to_next_word<WORD>)) },
- { { Key::Modifiers::Alt, 'E' }, repeated(select<SelectMode::Extend>(select_to_next_word_end<WORD>)) },
- { { Key::Modifiers::Alt, 'B' }, repeated(select<SelectMode::Extend>(select_to_previous_word<WORD>)) },
-
- { { Key::Modifiers::Alt, 'l' }, repeated(select<SelectMode::Replace>(select_to_eol)) },
- { { Key::Modifiers::Alt, 'L' }, repeated(select<SelectMode::Extend>(select_to_eol)) },
- { { Key::Modifiers::Alt, 'h' }, repeated(select<SelectMode::Replace>(select_to_eol_reverse)) },
- { { Key::Modifiers::Alt, 'H' }, repeated(select<SelectMode::Extend>(select_to_eol_reverse)) },
-
- { { Key::Modifiers::None, 'x' }, repeated(select<SelectMode::Replace>(select_line)) },
- { { Key::Modifiers::None, 'X' }, repeated(select<SelectMode::Extend>(select_line)) },
- { { Key::Modifiers::Alt, 'x' }, select<SelectMode::Replace>(select_whole_lines) },
- { { Key::Modifiers::Alt, 'X' }, select<SelectMode::Replace>(trim_partial_lines) },
-
- { { Key::Modifiers::None, 'm' }, select<SelectMode::Replace>(select_matching) },
- { { Key::Modifiers::None, 'M' }, select<SelectMode::Extend>(select_matching) },
-
- { { Key::Modifiers::None, '/' }, search<SelectMode::Replace, Forward> },
- { { Key::Modifiers::None, '?' }, search<SelectMode::Extend, Forward> },
- { { Key::Modifiers::Alt, '/' }, search<SelectMode::Replace, Backward> },
- { { Key::Modifiers::Alt, '?' }, search<SelectMode::Extend, Backward> },
- { { Key::Modifiers::None, 'n' }, search_next<SelectMode::Replace, Forward> },
- { { Key::Modifiers::Alt, 'n' }, search_next<SelectMode::ReplaceMain, Forward> },
- { { Key::Modifiers::None, 'N' }, search_next<SelectMode::Append, Forward> },
- { { Key::Modifiers::None, '*' }, use_selection_as_search_pattern<true> },
- { { Key::Modifiers::Alt, '*' }, use_selection_as_search_pattern<false> },
-
- { { Key::Modifiers::None, 'u' }, repeated([](Context& context, int) { if (not context.editor().undo()) context.print_status({ "nothing left to undo", get_color("Information") }); }) },
- { { Key::Modifiers::None, 'U' }, repeated([](Context& context, int) { if (not context.editor().redo()) context.print_status({ "nothing left to redo", get_color("Information") }); }) },
-
- { { Key::Modifiers::Alt, 'i' }, select_object<ObjectFlags::ToBegin | ObjectFlags::ToEnd | ObjectFlags::Inner> },
- { { Key::Modifiers::Alt, 'a' }, select_object<ObjectFlags::ToBegin | ObjectFlags::ToEnd> },
- { { Key::Modifiers::None, ']' }, select_object<ObjectFlags::ToEnd> },
- { { Key::Modifiers::None, '[' }, select_object<ObjectFlags::ToBegin> },
- { { Key::Modifiers::None, '}' }, select_object<ObjectFlags::ToEnd, SelectMode::Extend> },
- { { Key::Modifiers::None, '{' }, select_object<ObjectFlags::ToBegin, SelectMode::Extend> },
-
- { { Key::Modifiers::Alt, 'j' }, join },
- { { Key::Modifiers::Alt, 'J' }, join_select_spaces },
-
- { { Key::Modifiers::Alt, 'k' }, keep<true> },
- { { Key::Modifiers::Alt, 'K' }, keep<false> },
-
- { { Key::Modifiers::None, '<' }, deindent },
- { { Key::Modifiers::None, '>' }, indent },
-
- { { Key::Modifiers::Control, 'i' }, jump<Forward> },
- { { Key::Modifiers::Control, 'o' }, jump<Backward> },
- { { Key::Modifiers::Control, 's' }, save_selections },
-
- { { Key::Modifiers::Alt, 'r' }, rotate_selections },
- { { Key::Modifiers::Alt, 'R' }, rotate_selections_content },
-
- { { Key::Modifiers::None, 'q' }, start_or_end_macro_recording },
- { { Key::Modifiers::None, 'Q' }, replay_macro },
-
- { { Key::Modifiers::None, '`' }, for_each_char<to_lower> },
- { { Key::Modifiers::None, '~' }, for_each_char<to_upper> },
- { { Key::Modifiers::Alt, '`' }, for_each_char<swap_case> },
-
- { { Key::Modifiers::None, '&' }, align<false> },
- { { Key::Modifiers::Alt, '&' }, align<true> },
+ { 'w', repeated(select<SelectMode::Replace>(select_to_next_word<Word>)) },
+ { 'e', repeated(select<SelectMode::Replace>(select_to_next_word_end<Word>)) },
+ { 'b', repeated(select<SelectMode::Replace>(select_to_previous_word<Word>)) },
+ { 'W', repeated(select<SelectMode::Extend>(select_to_next_word<Word>)) },
+ { 'E', repeated(select<SelectMode::Extend>(select_to_next_word_end<Word>)) },
+ { 'B', repeated(select<SelectMode::Extend>(select_to_previous_word<Word>)) },
+
+ { alt('w'), repeated(select<SelectMode::Replace>(select_to_next_word<WORD>)) },
+ { alt('e'), repeated(select<SelectMode::Replace>(select_to_next_word_end<WORD>)) },
+ { alt('b'), repeated(select<SelectMode::Replace>(select_to_previous_word<WORD>)) },
+ { alt('W'), repeated(select<SelectMode::Extend>(select_to_next_word<WORD>)) },
+ { alt('E'), repeated(select<SelectMode::Extend>(select_to_next_word_end<WORD>)) },
+ { alt('B'), repeated(select<SelectMode::Extend>(select_to_previous_word<WORD>)) },
+
+ { alt('l'), repeated(select<SelectMode::Replace>(select_to_eol)) },
+ { alt('L'), repeated(select<SelectMode::Extend>(select_to_eol)) },
+ { alt('h'), repeated(select<SelectMode::Replace>(select_to_eol_reverse)) },
+ { alt('H'), repeated(select<SelectMode::Extend>(select_to_eol_reverse)) },
+
+ { 'x', repeated(select<SelectMode::Replace>(select_line)) },
+ { 'X', repeated(select<SelectMode::Extend>(select_line)) },
+ { alt('x'), select<SelectMode::Replace>(select_whole_lines) },
+ { alt('X'), select<SelectMode::Replace>(trim_partial_lines) },
+
+ { 'm', select<SelectMode::Replace>(select_matching) },
+ { 'M', select<SelectMode::Extend>(select_matching) },
+
+ { '/', search<SelectMode::Replace, Forward> },
+ { '?', search<SelectMode::Extend, Forward> },
+ { alt('/'), search<SelectMode::Replace, Backward> },
+ { alt('?'), search<SelectMode::Extend, Backward> },
+ { 'n', search_next<SelectMode::Replace, Forward> },
+ { alt('n'), search_next<SelectMode::ReplaceMain, Forward> },
+ { 'N', search_next<SelectMode::Append, Forward> },
+ { '*', use_selection_as_search_pattern<true> },
+ { alt('*'), use_selection_as_search_pattern<false> },
+
+ { 'u', repeated([](Context& context, int) { if (not context.editor().undo()) context.print_status({ "nothing left to undo", get_color("Information") }); }) },
+ { 'U', repeated([](Context& context, int) { if (not context.editor().redo()) context.print_status({ "nothing left to redo", get_color("Information") }); }) },
+
+ { alt('i'), select_object<ObjectFlags::ToBegin | ObjectFlags::ToEnd | ObjectFlags::Inner> },
+ { alt('a'), select_object<ObjectFlags::ToBegin | ObjectFlags::ToEnd> },
+ { ']', select_object<ObjectFlags::ToEnd> },
+ { '[', select_object<ObjectFlags::ToBegin> },
+ { '}', select_object<ObjectFlags::ToEnd, SelectMode::Extend> },
+ { '{', select_object<ObjectFlags::ToBegin, SelectMode::Extend> },
+
+ { alt('j'), join },
+ { alt('J'), join_select_spaces },
+
+ { alt('k'), keep<true> },
+ { alt('K'), keep<false> },
+
+ { '<', deindent },
+ { '>', indent },
+
+ { ctrl('i'), jump<Forward> },
+ { ctrl('o'), jump<Backward> },
+ { ctrl('s'), save_selections },
+
+ { alt('r'), rotate_selections },
+ { alt('R'), rotate_selections_content },
+
+ { 'q', start_or_end_macro_recording },
+ { 'Q', replay_macro },
+
+ { '`', for_each_char<to_lower> },
+ { '~', for_each_char<to_upper> },
+ { alt('`'), for_each_char<swap_case> },
+
+ { '&', align<false> },
+ { alt('&'), align<true> },
{ Key::Left, move<CharCount, Backward> },
{ Key::Down, move<LineCount, Forward> },