Show heat and other unread in title

weechat-hashes
C. McEnroe 2020-02-10 17:54:16 -05:00
parent c8a6564670
commit 65603d5138
1 changed files with 21 additions and 14 deletions

35
ui.c
View File

@ -359,38 +359,45 @@ static void statusAdd(const char *str) {
} }
static void statusUpdate(void) { static void statusUpdate(void) {
int otherUnread = 0;
enum Heat otherHeat = Cold;
wmove(status, 0, 0); wmove(status, 0, 0);
int num; int num;
const struct Window *window; const struct Window *window;
for (num = 0, window = windows.head; window; ++num, window = window->next) { for (num = 0, window = windows.head; window; ++num, window = window->next) {
if (!window->heat && window != windows.active) continue; if (!window->heat && window != windows.active) continue;
int unread; if (window != windows.active) {
otherUnread += window->unreadCount;
if (window->heat > otherHeat) otherHeat = window->heat;
}
int trunc;
char buf[256]; char buf[256];
snprintf( snprintf(
buf, sizeof(buf), "\3%d%s %d %s %n(\3%02d%d\3%d) ", buf, sizeof(buf), "\3%d%s %d %s %n(\3%02d%d\3%d) ",
idColors[window->id], (window == windows.active ? "\26" : ""), idColors[window->id], (window == windows.active ? "\26" : ""),
num, idNames[window->id], num, idNames[window->id],
&unread, (window->heat > Warm ? White : idColors[window->id]), &trunc, (window->heat > Warm ? White : idColors[window->id]),
window->unreadCount, window->unreadCount,
idColors[window->id] idColors[window->id]
); );
if (!window->mark || !window->unreadCount) buf[unread] = '\0'; if (!window->mark || !window->unreadCount) buf[trunc] = '\0';
statusAdd(buf); statusAdd(buf);
} }
wclrtoeol(status); wclrtoeol(status);
if (!to_status_line) return;
int unread; window = windows.active;
char buf[256];
snprintf(
buf, sizeof(buf), "%s %s%n (%d)",
self.network, idNames[windows.active->id],
&unread, windows.active->unreadCount
);
if (!windows.active->mark || !windows.active->unreadCount) {
buf[unread] = '\0';
}
putp(to_status_line); putp(to_status_line);
putp(buf); printf("%s %s", self.network, idNames[window->id]);
if (window->mark && window->unreadCount) {
printf(
" (%d%s)", window->unreadCount, (window->heat > Warm ? "!" : "")
);
}
if (otherUnread) {
printf(" (+%d%s)", otherUnread, (otherHeat > Warm ? "!" : ""));
}
putp(from_status_line); putp(from_status_line);
fflush(stdout); fflush(stdout);
} }