Code

Improve title updating and remove flickering
authorJonas Fonseca <fonseca@diku.dk>
Tue, 23 May 2006 22:29:24 +0000 (00:29 +0200)
committerJonas Fonseca <fonseca@antimatter.localdomain>
Tue, 23 May 2006 22:30:42 +0000 (00:30 +0200)
 - Show line info even if no lines has been loaded, so less has to be
   redrawn.

 - Don't make the view window one line bigger causing the title window
   to be overwritten. This reinstates the bug in last line drawing.

tig.c

diff --git a/tig.c b/tig.c
index 05fb370e22a76722863623d88e85f7b94e5dc227..52abe0fda6cb031741ec9b721a0b7598a51e592f 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -807,12 +807,16 @@ update_view_title(struct view *view)
        else
                wprintw(view->title, "[%s]", view->name);
 
-       if (view->lines) {
+       if (view->lines || view->pipe) {
+               unsigned int lines = view->lines
+                                  ? (view->lineno + 1) * 100 / view->lines
+                                  : 0;
+
                wprintw(view->title, " - %s %d of %d (%d%%)",
                        view->ops->type,
                        view->lineno + 1,
                        view->lines,
-                       (view->lineno + 1) * 100 / view->lines);
+                       lines);
        }
 
        if (view->pipe) {
@@ -857,11 +861,8 @@ resize_display(void)
        offset = 0;
 
        foreach_view (view, i) {
-               /* Keep the height of all view->win windows one larger than is
-                * required so that the cursor can wrap-around on the last line
-                * without scrolling the window. */
                if (!view->win) {
-                       view->win = newwin(view->height + 1, 0, offset, 0);
+                       view->win = newwin(view->height, 0, offset, 0);
                        if (!view->win)
                                die("Failed to create %s view", view->name);
 
@@ -872,7 +873,7 @@ resize_display(void)
                                die("Failed to create title window");
 
                } else {
-                       wresize(view->win, view->height + 1, view->width);
+                       wresize(view->win, view->height, view->width);
                        mvwin(view->win,   offset, 0);
                        mvwin(view->title, offset + view->height, 0);
                        wrefresh(view->win);
@@ -2583,6 +2584,9 @@ main(int argc, char *argv[])
  *   outside the current view causing bad wrapping. Same goes
  *   for title and status windows.
  *
+ * - The cursor can wrap-around on the last line and cause the
+ *   window to scroll.
+ *
  * TODO
  * ----
  * Features that should be explored.