Skip to content

Commit

Permalink
update_view_title: use string_format_from instead of wprintw
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas authored and Jonas Fonseca committed Sep 16, 2006
1 parent 4887d44 commit 3c112a8
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions tig.c
Expand Up @@ -1315,42 +1315,43 @@ 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;
unsigned int lines = view->lines
? 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) {
time_t secs = time(NULL) - view->start_time;

/* 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);
}
Expand Down

0 comments on commit 3c112a8

Please sign in to comment.