cio

a simple irc client
Download | Log | Files | Refs | README | LICENSE

commit 9b79f6014a1c1648cf877fd26177edcb5367ddef
parent 863a5e9c80be3cd18f4b257f7403359850833c50
Author: Andrew Kloet <andrew@kloet.net>
Date:   Mon, 20 Apr 2026 13:21:11 -0400

collapse switches, improve default command handler

The previous scmd default fall-through command handler was not
sufficient, it would only print the final argument. While it was fine
for MOTD messages; most arguments were dropped which would cause
commands like RPL_ISUPPORT (005), formatted as:

:server 005 <nick> <tokens> :are supported by this server

...to print useless messages like "are supported by this server".
Now by default we print the full body minus the numeric. Unhandled
non-numerics are are now dropped by default (subject to change).

Diffstat:
Mcio.c | 32++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/cio.c b/cio.c @@ -618,12 +618,18 @@ scmd(char *usr, char *cmd, int argc, char **argv) sndf("CAP END"); pushf(0, "-!- SASL auth %s", (type == SASL_OK ? "successful" : "failed")); break; - default: - if (isdigit(cmd[0])) - pushf(0, "%s: %s", cmd, GET_ARG(argc - 1)); - else - pushf(0, "%s: %s %s", cmd, GET_ARG(0), GET_ARG(1)); + default: { + if (!isdigit(cmd[0])) break; + char arg_buf[LineLen] = ""; + /* Numerics usually have the client nick at argv[0], so we skip it. */ + for (int i = 1; i < argc; i++) { + strlcat(arg_buf, argv[i], sizeof(arg_buf)); + if (i < argc - 1) + strlcat(arg_buf, " ", sizeof(arg_buf)); + } + pushf(0, "-!- %s", arg_buf); break; + } } } @@ -837,23 +843,17 @@ tgetch(void) c = wgetch(scr.iw); switch (c) { case CTRL('n'): - ch = (ch + 1) % nch; - chl[ch].high = chl[ch].new = 0; - tdrawbar(); - tredraw(); - return; - case CTRL('p'): - ch = (ch + nch - 1) % nch; + case CTRL('p'): { + int d = (c == CTRL('n')) ? 1 : -1; + ch = (ch + d + nch) % nch; chl[ch].high = chl[ch].new = 0; tdrawbar(); tredraw(); return; + } case KEY_PPAGE: - chl[ch].n += SCROLL; - tredraw(); - return; case KEY_NPAGE: - chl[ch].n -= SCROLL; + chl[ch].n += (c == KEY_PPAGE) ? SCROLL : -SCROLL; if (chl[ch].n < 0) chl[ch].n = 0; tredraw();