]> Pileus Git - ~andy/lamechat/commitdiff
Add channel topics
authorAndy Spencer <andy753421@gmail.com>
Mon, 23 Oct 2017 06:03:03 +0000 (06:03 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 23 Oct 2017 06:06:08 +0000 (06:06 +0000)
chat.h
irc.c
view.c
xmpp.c

diff --git a/chat.h b/chat.h
index 5492bff432f042729b1cc5c0bd951e5e68167254..a11731723b539bf2151547d943b42d2349c57a02 100644 (file)
--- 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 b9038961130102f2c130842623dabbee52f8a142..3fe171d8742ca695518251b245b50c9fbcd97d90 100644 (file)
--- 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 897e432e83efe354b3a2d92bdf6d1a20c80108c8..f8fff32ce9eabd239dcb17c107a369bb73c49c94 100644 (file)
--- 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 b606a540c116d7243291bc2121dd4b9b188903c1..a06cd5c97701fc1d6d7d1637ff20efa115bd060c 100644 (file)
--- 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);
                }