vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 2f7ce389456ac86f72b1682785c31b0ae891f33b
parent 3f3c568016d98ca50e9db66eb7079fa9b5ffc73d
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Mon, 28 Mar 2016 12:40:35 +0200

sam: adapt to changes in multiple cursors API

Diffstat:
Msam.c | 17+++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/sam.c b/sam.c @@ -728,7 +728,7 @@ static bool cmd_select(Vis *vis, Win *win, Command *cmd, Filerange *range) { bool ret = true; View *view = win->view; Text *txt = win->file->text; - bool multiple_cursors = view_cursors_count(view) > 1; + bool multiple_cursors = view_cursors_multiple(view); for (Cursor *c = view_cursors(view), *next; c; c = next) { next = view_cursors_next(c); Filerange sel; @@ -754,15 +754,12 @@ static bool cmd_print(Vis *vis, Win *win, Command *cmd, Filerange *range) { return false; View *view = win->view; Text *txt = win->file->text; - Cursor *cursor = view_cursors_new(view); - if (cursor) { - if (range->start != range->end) { - view_cursors_selection_set(cursor, range); - view_cursors_to(cursor, text_char_prev(txt, range->end)); - } else { - view_cursors_to(cursor, range->end); - } - } + size_t pos = range->end; + if (range->start != range->end) + pos = text_char_prev(txt, pos); + Cursor *cursor = view_cursors_new(view, pos); + if (cursor && range->start != range->end) + view_cursors_selection_set(cursor, range); return cursor != NULL; }