update_view_title: use string_format_from instead of wprintw
[tig] / tig.c
diff --git a/tig.c b/tig.c
index 711b9ad..ef3fe0d 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -1265,6 +1265,7 @@ draw_view_line(struct view *view, unsigned int lineno)
 {
        struct line *line;
        bool selected = (view->offset + lineno == view->lineno);
+       bool draw_ok;
 
        assert(view_is_displayed(view));
 
@@ -1282,7 +1283,11 @@ draw_view_line(struct view *view, unsigned int lineno)
                wclrtoeol(view->win);
        }
 
-       return view->ops->draw(view, line, lineno, selected);
+       scrollok(view->win, FALSE);
+       draw_ok = view->ops->draw(view, line, lineno, selected);
+       scrollok(view->win, TRUE);
+
+       return draw_ok;
 }
 
 static void
@@ -1310,20 +1315,14 @@ redraw_view(struct view *view)
 static void
 update_view_title(struct view *view)
 {
-       assert(view_is_displayed(view));
-
-       if (view == display[current_view])
-               wbkgdset(view->title, get_line_attr(LINE_TITLE_FOCUS));
-       else
-               wbkgdset(view->title, get_line_attr(LINE_TITLE_BLUR));
+       char buf[SIZEOF_STR];
+       size_t bufpos = 0;
 
-       werase(view->title);
-       wmove(view->title, 0, 0);
+       assert(view_is_displayed(view));
 
+       string_format_from(buf, &bufpos, "[%s]", view->name);
        if (*view->ref)
-               wprintw(view->title, "[%s] %s", view->name, view->ref);
-       else
-               wprintw(view->title, "[%s]", view->name);
+               string_format_from(buf, &bufpos, " %s", view->ref);
 
        if (view->lines || view->pipe) {
                unsigned int view_lines = view->offset + view->height;
@@ -1331,11 +1330,11 @@ update_view_title(struct view *view)
                                   ? MIN(view_lines, view->lines) * 100 / view->lines
                                   : 0;
 
-               wprintw(view->title, " - %s %d of %d (%d%%)",
-                       view->ops->type,
-                       view->lineno + 1,
-                       view->lines,
-                       lines);
+               string_format_from(buf, &bufpos, " - %s %d of %d (%d%%)",
+                                  view->ops->type,
+                                  view->lineno + 1,
+                                  view->lines,
+                                  lines);
        }
 
        if (view->pipe) {
@@ -1343,9 +1342,16 @@ update_view_title(struct view *view)
 
                /* Three git seconds are a long time ... */
                if (secs > 2)
-                       wprintw(view->title, " %lds", secs);
+                       string_format_from(buf, &bufpos, " %lds", secs);
        }
 
+       if (view == display[current_view])
+               wbkgdset(view->title, get_line_attr(LINE_TITLE_FOCUS));
+       else
+               wbkgdset(view->title, get_line_attr(LINE_TITLE_BLUR));
+
+       werase(view->title);
+       mvwaddnstr(view->title, 0, 0, buf, bufpos);
        wmove(view->title, 0, view->width - 1);
        wrefresh(view->title);
 }
@@ -1414,10 +1420,8 @@ redraw_display(void)
 }
 
 static void
-update_display_cursor(void)
+update_display_cursor(struct view *view)
 {
-       struct view *view = display[current_view];
-
        /* Move the cursor to the right-most column of the cursor line.
         *
         * XXX: This could turn out to be a bit expensive, but it ensures that
@@ -3132,7 +3136,7 @@ report(const char *msg, ...)
        }
 
        update_view_title(view);
-       update_display_cursor();
+       update_display_cursor(view);
 }
 
 /* Controls when nodelay should be in effect when polling user input. */