commit - fea845b67d7f2de7ea93f9205cc1edd33d2e3230
commit + 119f393c6dee24e60e9ec8d48289c6dd01256517
blob - 4f63a78d591b54db3000c9f7f50a4fdee6c164e2
blob + 74c0cae630cc32d20e5181ae8e596a4b864df54c
--- ui.c
+++ ui.c
redraw_tabline(void)
{
struct tab *tab;
- int current;
+ int current, x, y;
const char *title;
+ char buf[25];
werase(tabline);
- wbkgd(tabline, A_REVERSE);
+ wattron(tabline, A_REVERSE);
+
wprintw(tabline, " ");
TAILQ_FOREACH(tab, &tabshead, tabs) {
current = tab->flags & TAB_CURRENT;
if (*(title = tab->page.title) == '\0')
title = tab->hist_cur->h;
- if (current)
- wattron(tabline, A_UNDERLINE);
-
- wprintw(tabline, "%s%d: %s",
- current ? "*" : " ", tab->id, title);
+ strlcpy(buf, " ", sizeof(buf));
+ if (strlcat(buf, title, sizeof(buf)) >= sizeof(buf)) {
+ /* truncation happens */
+ strlcpy(&buf[sizeof(buf)-4], "...", 4);
+ } else {
+ /* pad with spaces */
+ while (strlcat(buf, " ", sizeof(buf)) < sizeof(buf))
+ /* nop */ ;
+ }
if (current)
- wattroff(tabline, A_UNDERLINE);
+ wattroff(tabline, A_REVERSE);
+
+ wprintw(tabline, "%s", buf);
+
+ if (current)
+ wattron(tabline, A_REVERSE);
+
+ if (TAILQ_NEXT(tab, tabs) != NULL)
+ wprintw(tabline, " ");
}
+
+ /* non-upcased macro are ugly... */
+ getyx(tabline, y, x);
+
+ for (; x < COLS; ++x)
+ waddch(tabline, ' ');
}
static void