vis

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

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

commit ff491de6adbfd7692a92c10ff8acb96a4eb0b77e
parent 59a16afadb8933f47cc95c495b5ba7c89535f7cc
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sat, 31 Oct 2015 14:26:33 +0100

view: make zb command more robust

The new approach first scrolls the window up such that the current
cursor line lies below the current visible area, then the viewport
is adjusted until the line is once again visible (at the bottom of
the window).

Closes #85

Diffstat:
Mview.c | 6++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/view.c b/view.c @@ -707,11 +707,9 @@ void view_redraw_bottom(View *view) { Line *line = view->cursor->line; if (line == view->lastline) return; - int linenr = 0; size_t pos = view->cursor->pos; - for (Line *cur = view->topline; cur && cur != line; cur = cur->next) - linenr++; - view_slide_down(view, view->height - linenr - 1); + view_viewport_up(view, view->height); + while (pos > view->end && view_viewport_down(view, 1)); view_cursor_to(view, pos); }