diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-03-27 23:25:30 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-03-28 12:25:06 +0200 |
| commit | 7a8633966797c524849fda6c69344ed3d4d58474 (patch) | |
| tree | 8a94cef513be2ff8e64cf43b5e7957c9b68cdda2 /main.c | |
| parent | 6331bf38783810a01a233ac73fa94ed028a0e965 (diff) | |
| download | vis-7a8633966797c524849fda6c69344ed3d4d58474.tar.gz vis-7a8633966797c524849fda6c69344ed3d4d58474.tar.xz | |
vis: let Meta-Ctrl-{j,k} create new cursor
on the line above/below the first/last existing cursor.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -237,7 +237,9 @@ enum { VIS_ACTION_PUT_BEFORE_END, VIS_ACTION_CURSOR_SELECT_WORD, VIS_ACTION_CURSORS_NEW_LINE_ABOVE, + VIS_ACTION_CURSORS_NEW_LINE_ABOVE_FIRST, VIS_ACTION_CURSORS_NEW_LINE_BELOW, + VIS_ACTION_CURSORS_NEW_LINE_BELOW_LAST, VIS_ACTION_CURSORS_NEW_LINES_BEGIN, VIS_ACTION_CURSORS_NEW_LINES_END, VIS_ACTION_CURSORS_NEW_MATCH_NEXT, @@ -888,11 +890,21 @@ static const KeyAction vis_action[] = { "Create a new cursor on the line above", cursors_new, { .i = -1 } }, + [VIS_ACTION_CURSORS_NEW_LINE_ABOVE_FIRST] = { + "cursors-new-lines-above-first", + "Create a new cursor on the line above the first cursor", + cursors_new, { .i = INT_MIN } + }, [VIS_ACTION_CURSORS_NEW_LINE_BELOW] = { "cursor-new-lines-below", "Create a new cursor on the line below", cursors_new, { .i = +1 } }, + [VIS_ACTION_CURSORS_NEW_LINE_BELOW_LAST] = { + "cursor-new-lines-below-last", + "Create a new cursor on the line below the last cursor", + cursors_new, { .i = INT_MAX } + }, [VIS_ACTION_CURSORS_NEW_LINES_BEGIN] = { "cursors-new-lines-begin", "Create a new cursor at the start of every line covered by selection", @@ -1190,7 +1202,22 @@ static const char *repeat(Vis *vis, const char *keys, const Arg *arg) { static const char *cursors_new(Vis *vis, const char *keys, const Arg *arg) { View *view = vis_view(vis); - Cursor *cursor = view_cursors_primary_get(view); + Cursor *cursor; + switch (arg->i) { + case -1: + case +1: + cursor = view_cursors_primary_get(view); + break; + case INT_MIN: + cursor = view_cursors(view); + break; + case INT_MAX: + for (Cursor *c = view_cursors(view); c; c = view_cursors_next(c)) + cursor = c; + break; + default: + return keys; + } size_t oldpos = view_cursors_pos(cursor); if (arg->i > 0) view_line_down(cursor); |
