diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-04-04 20:31:58 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-04-04 20:31:58 +0200 |
| commit | 4c316385d06858edcb9d107dde1996a25959164f (patch) | |
| tree | 59c2e637aaf33dbe9beffc2b0e545fe649f44e77 /main.c | |
| parent | 36e663f30e0bcd225164780022d04dc84bd7da13 (diff) | |
| download | vis-4c316385d06858edcb9d107dde1996a25959164f.tar.gz vis-4c316385d06858edcb9d107dde1996a25959164f.tar.xz | |
vis: let <C-c> remove the count cursor column
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -50,6 +50,8 @@ static const char *cursors_align_indent(Vis*, const char *keys, const Arg *arg); static const char *cursors_clear(Vis*, const char *keys, const Arg *arg); /* remove the least recently added cursor */ static const char *cursors_remove(Vis*, const char *keys, const Arg *arg); +/* remove count (or arg->i)-th cursor column */ +static const char *cursors_remove_column(Vis*, const char *keys, const Arg *arg); /* move to the previous (arg->i < 0) or next (arg->i > 0) cursor */ static const char *cursors_navigate(Vis*, const char *keys, const Arg *arg); /* select the word the cursor is currently over */ @@ -254,6 +256,7 @@ enum { VIS_ACTION_CURSORS_ALIGN_INDENT_RIGHT, VIS_ACTION_CURSORS_REMOVE_ALL, VIS_ACTION_CURSORS_REMOVE_LAST, + VIS_ACTION_CURSORS_REMOVE_COLUMN, VIS_ACTION_CURSORS_PREV, VIS_ACTION_CURSORS_NEXT, VIS_ACTION_SELECTIONS_ROTATE_LEFT, @@ -954,6 +957,11 @@ static const KeyAction vis_action[] = { "Remove least recently created cursor", cursors_remove, }, + [VIS_ACTION_CURSORS_REMOVE_COLUMN] = { + "cursors-remove-column", + "Remove count cursor column", + cursors_remove_column, { .i = 1 } + }, [VIS_ACTION_CURSORS_PREV] = { "cursors-prev", "Move to the previous cursor", @@ -1399,6 +1407,26 @@ static const char *cursors_remove(Vis *vis, const char *keys, const Arg *arg) { return keys; } +static const char *cursors_remove_column(Vis *vis, const char *keys, const Arg *arg) { + View *view = vis_view(vis); + int max = view_cursors_column_count(view); + int column = vis_count_get_default(vis, arg->i) - 1; + if (column >= max) + column = max - 1; + if (!view_cursors_multiple(view)) { + vis_mode_switch(vis, VIS_MODE_NORMAL); + return keys; + } + + for (Cursor *c = view_cursors_column(view, column), *next; c; c = next) { + next = view_cursors_column_next(c, column); + view_cursors_dispose(c); + } + + vis_count_set(vis, VIS_COUNT_UNKNOWN); + return keys; +} + static const char *cursors_navigate(Vis *vis, const char *keys, const Arg *arg) { View *view = vis_view(vis); if (!view_cursors_multiple(view)) { |
