chiark
/
gitweb
/
~mdw
/
tig
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5becf24
)
Abbreviate the view reference in the view title for small widths
author
Jonas Fonseca
<fonseca@diku.dk>
Sat, 16 Sep 2006 00:37:49 +0000
(
02:37
+0200)
committer
Jonas Fonseca
<fonseca@antimatter.localdomain>
Sat, 16 Sep 2006 00:37:49 +0000
(
02:37
+0200)
tig.c
patch
|
blob
|
blame
|
history
diff --git
a/tig.c
b/tig.c
index 8a796fd25bebf140353037ec28871517025867fb..de85ca1652056c317615cbd95efb3ce6dedd5dc7 100644
(file)
--- a/
tig.c
+++ b/
tig.c
@@
-1316,21
+1316,18
@@
static void
update_view_title(struct view *view)
{
char buf[SIZEOF_STR];
update_view_title(struct view *view)
{
char buf[SIZEOF_STR];
- size_t bufpos = 0;
+ char state[SIZEOF_STR];
+ size_t bufpos = 0, statelen = 0;
assert(view_is_displayed(view));
assert(view_is_displayed(view));
- string_format_from(buf, &bufpos, "[%s]", view->name);
- if (*view->ref)
- 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;
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;
- string_format_from(
buf, &bufpos, "
- %s %d of %d (%d%%)",
+ string_format_from(
state, &statelen, "
- %s %d of %d (%d%%)",
view->ops->type,
view->lineno + 1,
view->lines,
view->ops->type,
view->lineno + 1,
view->lines,
@@
-1341,10
+1338,24
@@
update_view_title(struct view *view)
/* Three git seconds are a long time ... */
if (secs > 2)
/* Three git seconds are a long time ... */
if (secs > 2)
- string_format_from(
buf, &bufpos
, " %lds", secs);
+ string_format_from(
state, &statelen
, " %lds", secs);
}
}
}
}
+ string_format_from(buf, &bufpos, "[%s]", view->name);
+ if (*view->ref && bufpos < view->width) {
+ size_t refsize = strlen(view->ref);
+ size_t minsize = bufpos + 1 + /* abbrev= */ 7 + 1 + statelen;
+
+ if (minsize < view->width)
+ refsize = view->width - minsize + 7;
+ string_format_from(buf, &bufpos, " %.*s", refsize, view->ref);
+ }
+
+ if (statelen && bufpos < view->width) {
+ string_format_from(buf, &bufpos, " %s", state);
+ }
+
if (view == display[current_view])
wbkgdset(view->title, get_line_attr(LINE_TITLE_FOCUS));
else
if (view == display[current_view])
wbkgdset(view->title, get_line_attr(LINE_TITLE_FOCUS));
else