From e3ce65b0ed8f3e7342646f8272a0cf0c78d31f79 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sun, 24 Apr 2016 18:32:41 +0200 Subject: Add nickname and new message indicator. --- irc.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/irc.c b/irc.c index ad38d2a..fe86072 100644 --- a/irc.c +++ b/irc.c @@ -46,6 +46,8 @@ struct Chan { char *buf, *eol; int n; /* Scroll offset. */ size_t sz; /* size of buf. */ + char high; /* Nick highlight. */ + char new; /* New message. */ } chl[MaxChans]; int nch, ch; /* Current number of channels, and current channel. */ char outb[BufSz], *outp=outb; /* Output buffer. */ @@ -258,7 +260,7 @@ pushf(int cn, const char *fmt, ...) static void scmd(char *usr, char *cmd, char *par, char *data) { - int s; + int s, c; char *pm=strtok(par, " "); if (!usr) usr="?"; @@ -269,10 +271,16 @@ scmd(char *usr, char *cmd, char *par, char *data) } if (!strcmp(cmd, "PRIVMSG")) { if (!pm || !data) return; - if (strcasestr(data, nick)) - pushf(chfind(pm), PFMTHIGH, usr, data); - else - pushf(chfind(pm), PFMT, usr, data); + c=chfind(pm); + if (strcasestr(data, nick)) { + pushf(c, PFMTHIGH, usr, data); + chl[c].high |= ch != c; + } else + pushf(c, PFMT, usr, data); + if (ch != c) { + chl[c].new=1; + tdrawbar(); + } } else if (!strcmp(cmd, "PING")) { sndf("PONG :%s", data?data:"(null)"); } else if (!strcmp(cmd, "PART")) { @@ -466,6 +474,8 @@ tdrawbar(void) if (fst==ch) wattron(scr.sw, A_BOLD); waddch(scr.sw, '['), l++; + if (chl[fst].high) waddch(scr.sw, '>'), l++; + else if (chl[fst].new) waddch(scr.sw, '+'), l++; for (; *p && l