From ffb30e1a5d87f7daf66ba822cc938979ab4878df Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Mon, 23 Oct 2017 06:03:03 +0000 Subject: [PATCH] Add channel topics --- chat.h | 1 + irc.c | 4 +++- view.c | 10 ++++++---- xmpp.c | 3 +++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/chat.h b/chat.h index 5492bff..a117317 100644 --- a/chat.h +++ b/chat.h @@ -35,6 +35,7 @@ typedef struct server_t { typedef struct channel_t { server_t *server; char *name; + char *topic; FILE *log; int seen; channel_t *next; diff --git a/irc.c b/irc.c index b903896..3fe171d 100644 --- a/irc.c +++ b/irc.c @@ -394,10 +394,12 @@ static void irc_run(irc_server_t *srv, const char *line) if (match(cmd, "TOPIC")) { chan = find_dest(srv, arg, 1); chan_notice(chan, "Topic changed to %s", msg); + strset(&chan->channel.topic, msg); } - if (match(cmd, "331") || match(cmd, "322")) { + if (match(cmd, "331") || match(cmd, "332")) { chan = find_dest(srv, arg, 1); chan_notice(chan, "Topic: %s", msg); + strset(&chan->channel.topic, msg); } if (match(cmd, "353") && prefix(arg, "@", &arg)) { chan = find_dest(srv, arg, 1); diff --git a/view.c b/view.c index 897e432..f8fff32 100644 --- a/view.c +++ b/view.c @@ -442,10 +442,12 @@ static int send_command(const char *text) /* Drawing functions */ void draw_header(void) { + const char *topic = "No Topic"; + if (focus && focus->channel && focus->channel->topic) + topic = focus->channel->topic; attron(color_title); - move(0, 0); - clrtoeol(); - printw("%-*s", COLS, "Header Bar"); + mvhline(0, 0, ' ', COLS); + mvprintw(0, 0, " %s", topic); attroff(color_title); } @@ -558,7 +560,7 @@ void draw_status(void) attron(color_title); mvhline(LINES-2, 0, ' ', COLS); move(LINES-2, 0); - printw("Windows:"); + printw(" Windows:"); if (!windows) printw(" none"); for (window_t *cur = windows; cur; cur = cur->next) { diff --git a/xmpp.c b/xmpp.c index b606a54..a06cd5c 100644 --- a/xmpp.c +++ b/xmpp.c @@ -547,6 +547,9 @@ static void xmpp_run(xmpp_server_t *srv, int idle, srv->stamp = timegm(&tm); } } + if (match(end, "subject") && chan) { + strset(&chan->channel.topic, data); + } if (match(end, "body")) { strset(&srv->body, data); } -- 2.43.2