commit 119f393c6dee24e60e9ec8d48289c6dd01256517 from: Omar Polo date: Tue Mar 16 07:50:54 2021 UTC some improvements for the tabline appearance commit - fea845b67d7f2de7ea93f9205cc1edd33d2e3230 commit + 119f393c6dee24e60e9ec8d48289c6dd01256517 blob - 4f63a78d591b54db3000c9f7f50a4fdee6c164e2 blob + 74c0cae630cc32d20e5181ae8e596a4b864df54c --- ui.c +++ ui.c @@ -1143,12 +1143,14 @@ static void 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; @@ -1156,15 +1158,33 @@ redraw_tabline(void) 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