Commit Diff


commit - 24b3e15057ab3436f75bfcfceb1ed4c93f56fbd5
commit + a636f50e13c29857f48d1f52db8137dbf7d69660
blob - 74c0cae630cc32d20e5181ae8e596a4b864df54c
blob + 2401963071d77fb4c503940ab5d0f0cfa1d26a61
--- ui.c
+++ ui.c
@@ -1143,16 +1143,41 @@ static void
 redraw_tabline(void)
 {
 	struct tab	*tab;
-	int		 current, x, y;
+	size_t		 toskip;
+	int		 current, x, y, truncated;
 	const char	*title;
 	char		 buf[25];
 
-	werase(tabline);
+	toskip = 0;
+	x = 1;
+	TAILQ_FOREACH(tab, &tabshead, tabs) {
+		x += sizeof(buf) + 1;
+		toskip++;
+		if (tab->flags & TAB_CURRENT)
+			break;
+	}
+	if (x < COLS-2)
+		toskip = 0;
+	else
+		toskip--;
 
+	werase(tabline);
 	wattron(tabline, A_REVERSE);
-
-	wprintw(tabline, " ");
+	wprintw(tabline, toskip == 0 ? " " : "<");
+
+	truncated = 0;
 	TAILQ_FOREACH(tab, &tabshead, tabs) {
+		if (truncated)
+			break;
+		if (toskip != 0) {
+			toskip--;
+			continue;
+		}
+
+		getyx(tabline, y, x);
+		if (x + sizeof(buf)+2 >= (size_t)COLS)
+			truncated = 1;
+
 		current = tab->flags & TAB_CURRENT;
 
 		if (*(title = tab->page.title) == '\0')
@@ -1179,12 +1204,11 @@ redraw_tabline(void)
 		if (TAILQ_NEXT(tab, tabs) != NULL)
 			wprintw(tabline, " ");
 	}
-
-	/* non-upcased macro are ugly... */
-	getyx(tabline, y, x);
 
 	for (; x < COLS; ++x)
 		waddch(tabline, ' ');
+	if (truncated)
+		mvwprintw(tabline, 0, COLS-1, ">");
 }
 
 static void