Code

do_scroll_view: minor refactoring of the current line updating
authorJonas Fonseca <fonseca@diku.dk>
Mon, 11 Sep 2006 21:07:46 +0000 (23:07 +0200)
committerJonas Fonseca <fonseca@antimatter.localdomain>
Mon, 11 Sep 2006 21:07:46 +0000 (23:07 +0200)
tig.c

diff --git a/tig.c b/tig.c
index 2f32941b900d759539a9d59d8cd8659a8219ac6b..7dba19d2f9fe88c4f707ed1702734f425ce6cb55 100644 (file)
--- 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;