diff --git a/README.md b/README.md index d393ca0..f13e950 100644 --- a/README.md +++ b/README.md @@ -148,8 +148,9 @@ Build yours by copying `irc9rc-example` to `irc9rc` next to the binary (or to The left column is a tree: each server and its windows (channels and private message windows). Channels appear before private message windows, with -uppercase names sorting before lowercase names in each group. An unread window shows `(n)` next to its name. `*` marks a -connected server. The selected server or window is shown bold and underlined. Highlights use the +uppercase names sorting before lowercase names in each group. An unread window +shows `(n)` next to its name. Each server shows its total unread count after +its name, including when folded. `*` marks a connected server. The selected server or window is shown bold and underlined. Highlights use the terminal's default background so transparency is preserved where supported. Channel topics wrap to the chat pane width and stay at the top while you scroll. On short terminals, the topic leaves room for at least one chat line when possible. diff --git a/irc9.c b/irc9.c index ee12651..025c416 100644 --- a/irc9.c +++ b/irc9.c @@ -2782,7 +2782,15 @@ static void draw_tree(void) fputs(w == curwin ? (terminal_color ? "\033[1;4m" : "\033[7m") : "\033[1m", stdout); putchar(s->connected ? '*' : ' '); if (s->tree_folded) putchar('+'); - terminal_text(s->name ? s->name : s->host, treew - 3 - s->tree_folded); + long long unread = 0; + for (Window *child = s->windows; child; child = child->next) + unread += child->unread; + int columns = treew - 3 - s->tree_folded; + char count[32] = ""; + int count_width = unread ? snprintf(count, sizeof count, " (%lld)", unread) : 0; + if (count_width > columns) count_width = 0; + terminal_text(s->name ? s->name : s->host, columns - count_width); + if (count_width) fputs(count, stdout); fputs("\033[0m", stdout); } continue;