Code

Tree view: make drawing more smooth by using the dirty flag
authorJonas Fonseca <fonseca@diku.dk>
Thu, 15 Jan 2009 14:56:11 +0000 (15:56 +0100)
committerJonas Fonseca <fonseca@diku.dk>
Thu, 15 Jan 2009 15:04:09 +0000 (16:04 +0100)
NEWS
tig.c

diff --git a/NEWS b/NEWS
index 4f41bd2ac00344c3da4b14a4c17a74a060119deb..2ac62caba5b82f9d6637ec2aab24d0b00f4bf714 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ Release notes
 tig master
 ----------
 
+Improvements:
+
+ - Tree view: avoid flickering when updating.
+
 Bug fixes:
 
  - Tree view: fix memory corruption bug when updating.
diff --git a/tig.c b/tig.c
index 68d33acfd75f7484478a366a816b4750267dcd0a..c1412883998d66df15ff7356443e6bdb0bb9d2c4 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -1021,6 +1021,7 @@ struct line {
        /* State flags */
        unsigned int selected:1;
        unsigned int dirty:1;
+       unsigned int cleareol:1;
 
        void *data;             /* User data */
 };
@@ -1983,18 +1984,18 @@ draw_view_line(struct view *view, unsigned int lineno)
        line = &view->line[view->offset + lineno];
 
        wmove(view->win, lineno, 0);
+       if (line->cleareol)
+               wclrtoeol(view->win);
        view->col = 0;
        view->curline = line;
        view->curtype = LINE_NONE;
        line->selected = FALSE;
-       line->dirty = 0;
+       line->dirty = line->cleareol = 0;
 
        if (selected) {
                set_view_attr(view, LINE_CURSOR);
                line->selected = TRUE;
                view->ops->select(view, line);
-       } else if (line->selected) {
-               wclrtoeol(view->win);
        }
 
        scrollok(view->win, FALSE);
@@ -2681,7 +2682,7 @@ update_view(struct view *view)
        char *line;
        /* Clear the view and redraw everything since the tree sorting
         * might have rearranged things. */
-       bool redraw = view == VIEW(REQ_VIEW_TREE);
+       bool redraw = FALSE;
        bool can_read = TRUE;
 
        if (!view->pipe)
@@ -3633,6 +3634,8 @@ tree_read(struct view *view, char *text)
 
                line->data = text;
                line->type = type;
+               for (; line <= entry; line++)
+                       line->dirty = line->cleareol = 1;
                return TRUE;
        }