vis

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

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

commit 840bfd1a681753594549f1cc5843ce3c9e5d3370
parent 17e5ec557f72152339c21b510688d6ff4b2853e4
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Fri, 27 Nov 2015 13:26:42 +0100

vis: improve creation of new cursors on line above/below

Use view cell matrix data to create the cursors on more appropriate
positions.

Closes #108

Diffstat:
Mmain.c | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/main.c b/main.c @@ -1110,15 +1110,15 @@ 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); - Text *txt = vis_text(vis); size_t pos = view_cursor_get(view); - if (arg->i > 0) - pos = text_line_down(txt, pos); - else if (arg->i < 0) - pos = text_line_up(txt, pos); Cursor *cursor = view_cursors_new(view); - if (cursor) + if (cursor) { view_cursors_to(cursor, pos); + if (arg->i > 0) + view_line_down(cursor); + else if (arg->i < 0) + view_line_up(cursor); + } return keys; }