From a281f89592cf5531ebf53863768fccd054de252c Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Sat, 11 Aug 2018 19:30:30 -0400 Subject: Rework UI code for multi-channel Tags are now permanently assigned (and I'm betting on never needing more than 256 of them) and the UI maps tags to a linked list of views for easy reordering and removal. Currently, views can only be added. Views don't have a topic window until they need one. All UI code wants to be functional reactive. Beeping is temporarily removed until message priorities (status, message, ping) can be added to the UI. At that point spawning notify-send should also be possible. Priorities will also help with unnecessary markers, which will not appear for status messages. The tab system is now used to send QUIT and NICK messages to all the relevant tags. Verbose output now goes to its own tag, and sending to it sends raw IRC. IRC colors are now listed in chat.h and handler functions for numeric replies have real names. The color algorithm now uses a real hash function for hopefully better results. QUIT, PART and KICK messages are scanned for URLs. --- irc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'irc.c') diff --git a/irc.c b/irc.c index 579f23b..0a131b2 100644 --- a/irc.c +++ b/irc.c @@ -106,15 +106,15 @@ void ircFmt(const char *format, ...) { int len = vasprintf(&buf, format, ap); va_end(ap); if (!buf) err(EX_OSERR, "vasprintf"); - if (self.verbose) uiFmt(tagFor("(irc)"), "\00314<<<\3 %.*s", len - 2, buf); + if (self.verbose) uiFmt(TAG_VERBOSE, "\3%d<<<\3 %.*s", IRC_WHITE, len - 2, buf); ircWrite(buf, len); free(buf); } -static char buf[4096]; -static size_t len; - void ircRead(void) { + static char buf[4096]; + static size_t len; + ssize_t read = tls_read(client, &buf[len], sizeof(buf) - len); if (read < 0) errx(EX_IOERR, "tls_read: %s", tls_error(client)); if (!read) { @@ -126,7 +126,7 @@ void ircRead(void) { char *crlf, *line = buf; while ((crlf = strnstr(line, "\r\n", &buf[len] - line))) { crlf[0] = '\0'; - if (self.verbose) uiFmt(tagFor("(irc)"), "\00314>>>\3 %s", line); + if (self.verbose) uiFmt(TAG_VERBOSE, "\3%d>>>\3 %s", IRC_GRAY, line); handle(line); line = &crlf[2]; } -- cgit 1.4.1