From a0087dd5e88eff34a7c816cce09a7aa070f1d978 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 11 Sep 2006 23:07:46 +0200 Subject: [PATCH] do_scroll_view: minor refactoring of the current line updating --- tig.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tig.c b/tig.c index 2f32941..7dba19d 100644 --- a/tig.c +++ b/tig.c @@ -1434,6 +1434,8 @@ update_display_cursor(void) static void do_scroll_view(struct view *view, int lines, bool redraw) { + bool redraw_current_line = FALSE; + assert(view_is_displayed(view)); /* The rendering expects the new offset. */ @@ -1442,6 +1444,17 @@ do_scroll_view(struct view *view, int lines, bool redraw) assert(0 <= view->offset && view->offset < view->lines); assert(lines); + /* Move current line into the view. */ + if (view->lineno < view->offset) { + view->lineno = view->offset; + redraw_current_line = TRUE; + } else if (view->lineno >= view->offset + view->height) { + view->lineno = view->offset + view->height - 1; + redraw_current_line = TRUE; + } + + assert(view->offset <= view->lineno && view->lineno < view->lines); + /* Redraw the whole screen if scrolling is pointless. */ if (view->height < ABS(lines)) { redraw_view(view); @@ -1456,20 +1469,11 @@ do_scroll_view(struct view *view, int lines, bool redraw) if (!draw_view_line(view, line)) break; } - } - - /* Move current line into the view. */ - if (view->lineno < view->offset) { - view->lineno = view->offset; - draw_view_line(view, 0); - } else if (view->lineno >= view->offset + view->height) { - view->lineno = view->offset + view->height - 1; - draw_view_line(view, view->lineno - view->offset); + if (redraw_current_line) + draw_view_line(view, view->lineno - view->offset); } - assert(view->offset <= view->lineno && view->lineno < view->lines); - if (!redraw) return; -- 2.30.2