diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-03-09 14:01:17 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-03-09 14:01:17 +0000 |
| commit | 7af8937bacaf2e9faddf366a9d8c9299357385b0 (patch) | |
| tree | 6011d2584d56f37c0d007c8dfdbfacf45944fb3c /src | |
| parent | d1f17228dd20fe42b88bcdf39d5316c7cfae74e2 (diff) | |
Extract remaining lambdas commands so that the cmds array can be compile time initialized
Diffstat (limited to 'src')
| -rw-r--r-- | src/normal.cc | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/normal.cc b/src/normal.cc index bfdfcf65..8893b8f5 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1350,6 +1350,31 @@ void move(Context& context, NormalParams params) selections.sort_and_merge_overlapping(); } +void select_whole_buffer(Context& context, NormalParams) +{ + select_buffer(context.selections()); +} + +void keep_selection(Context& context, NormalParams p) +{ + keep_selection(context.selections(), p.count ? p.count-1 : context.selections().main_index()); +} + +void remove_selection(Context& context, NormalParams p) +{ + remove_selection(context.selections(), p.count ? p.count-1 : context.selections().main_index()); +} + +void clear_selections(Context& context, NormalParams) +{ + clear_selections(context.selections()); +} + +void flip_selections(Context& context, NormalParams) +{ + flip_selections(context.selections()); +} + static NormalCmdDesc cmds[] = { { 'h', "move left", move<CharCount, Backward> }, @@ -1399,7 +1424,7 @@ static NormalCmdDesc cmds[] = { '.', "repeat last insert command", repeat_last_insert }, - { '%', "select whole buffer", [](Context& context, NormalParams) { select_buffer(context.selections()); } }, + { '%', "select whole buffer", select_whole_buffer }, { ':', "enter command prompt", command }, { '|', "pipe each selection through filter and replace with output", pipe<true> }, @@ -1407,10 +1432,10 @@ static NormalCmdDesc cmds[] = { '!', "insert command output", insert_output<InsertMode::Insert> }, { alt('!'), "append command output", insert_output<InsertMode::Append> }, - { ' ', "remove all selection except main", [](Context& context, NormalParams p) { keep_selection(context.selections(), p.count ? p.count-1 : context.selections().main_index()); } }, - { alt(' '), "remove main selection", [](Context& context, NormalParams p) { remove_selection(context.selections(), p.count ? p.count-1 : context.selections().main_index()); } }, - { ';', "reduce selections to their cursor", [](Context& context, NormalParams) { clear_selections(context.selections()); } }, - { alt(';'), "swap selections cursor and anchor", [](Context& context, NormalParams) { flip_selections(context.selections()); } }, + { ' ', "remove all selection except main", keep_selection }, + { alt(' '), "remove main selection", remove_selection }, + { ';', "reduce selections to their cursor", clear_selections }, + { alt(';'), "swap selections cursor and anchor", flip_selections }, { 'w', "select to next word start", repeated<&select<SelectMode::Replace, select_to_next_word<Word>>> }, { 'e', "select to next word end", repeated<select<SelectMode::Replace, select_to_next_word_end<Word>>> }, |
