diff options
author | June McEnroe <june@causal.agency> | 2018-08-11 19:30:30 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-08-11 20:02:03 -0400 |
commit | a281f89592cf5531ebf53863768fccd054de252c (patch) | |
tree | 502042617c3909ed5143d3e51562a7314666b250 /input.c | |
parent | Add term.c for extra terminal features (diff) | |
download | catgirl-a281f89592cf5531ebf53863768fccd054de252c.tar.gz catgirl-a281f89592cf5531ebf53863768fccd054de252c.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | input.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/input.c b/input.c index f4e3106..cb7575f 100644 --- a/input.c +++ b/input.c @@ -24,7 +24,6 @@ #include "chat.h" static void privmsg(struct Tag tag, bool action, const char *mesg) { - if (tag.id == TAG_DEFAULT.id) return; char *line; int send; asprintf( @@ -50,7 +49,7 @@ static void inputNick(struct Tag tag, char *params) { if (nick) { ircFmt("NICK %s\r\n", nick); } else { - uiLog(TAG_DEFAULT, L"/nick requires a name"); + uiLog(TAG_STATUS, L"/nick requires a name"); } } @@ -60,7 +59,7 @@ static void inputJoin(struct Tag tag, char *params) { if (chan) { ircFmt("JOIN %s\r\n", chan); } else { - uiLog(TAG_DEFAULT, L"/join requires a channel"); + uiLog(TAG_STATUS, L"/join requires a channel"); } } @@ -104,9 +103,12 @@ static void inputOpen(struct Tag tag, char *params) { static void inputView(struct Tag tag, char *params) { char *view = strsep(¶ms, " "); if (!view) return; - size_t num = strtoul(view, &view, 0); - tag = (view[0] ? tagName(view) : tagNum(num)); - if (tag.name) uiFocus(tag); + int num = strtol(view, &view, 0); + if (view[0]) { + uiViewTag(tagFor(view)); + } else { + uiViewNum(num); + } } static const struct { @@ -128,7 +130,11 @@ static const size_t COMMANDS_LEN = sizeof(COMMANDS) / sizeof(COMMANDS[0]); void input(struct Tag tag, char *input) { if (input[0] != '/') { - privmsg(tag, false, input); + if (tag.id == TAG_VERBOSE.id) { + ircFmt("%s\r\n", input); + } else if (tag.id != TAG_STATUS.id) { + privmsg(tag, false, input); + } return; } char *command = strsep(&input, " "); @@ -138,11 +144,11 @@ void input(struct Tag tag, char *input) { COMMANDS[i].handler(tag, input); return; } - uiFmt(TAG_DEFAULT, "%s isn't a recognized command", command); + uiFmt(TAG_STATUS, "%s isn't a recognized command", command); } void inputTab(void) { for (size_t i = 0; i < COMMANDS_LEN; ++i) { - tabTouch(TAG_DEFAULT, COMMANDS[i].command); + tabTouch(TAG_NONE, COMMANDS[i].command); } } |