diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-07-28 08:01:36 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-07-28 13:21:50 +0200 |
| commit | 3cc2390fed1cb4a626100e4bec428575a3e95f1a (patch) | |
| tree | da00ac9da3374db20a9a00838075251484b31aa8 /vis.c | |
| parent | ab5973aaca82c064dd54c30d2fd3db58e07947cc (diff) | |
| download | vis-3cc2390fed1cb4a626100e4bec428575a3e95f1a.tar.gz vis-3cc2390fed1cb4a626100e4bec428575a3e95f1a.tar.xz | |
vis: try to align cursors on the same column with CTRL-A
Diffstat (limited to 'vis.c')
| -rw-r--r-- | vis.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -322,6 +322,8 @@ static void totill_reverse(const Arg *arg); static void replace(const Arg *arg); /* create a new cursor on the previous (arg->i < 0) or next (arg->i > 0) line */ static void cursors_new(const Arg *arg); +/* try to align all cursors on the same column */ +static void cursors_align(const Arg *arg); /* remove all but the primary cursor and their selections */ static void cursors_clear(const Arg *arg); /* adjust action.count by arg->i */ @@ -842,6 +844,23 @@ static void cursors_new(const Arg *arg) { view_cursors_to(cursor, pos); } +static void cursors_align(const Arg *arg) { + View *view = vis->win->view; + Text *txt = vis->win->file->text; + int mincol = INT_MAX; + for (Cursor *c = view_cursors(view); c; c = view_cursors_next(c)) { + size_t pos = view_cursors_pos(c); + int col = text_line_char_get(txt, pos); + if (col < mincol) + mincol = col; + } + for (Cursor *c = view_cursors(view); c; c = view_cursors_next(c)) { + size_t pos = view_cursors_pos(c); + size_t col = text_line_char_set(txt, pos, mincol); + view_cursors_to(c, col); + } +} + static void cursors_clear(const Arg *arg) { View *view = vis->win->view; if (view_cursors_count(view) > 1) |
