From 526772742b1d5a3545d98f42194bbe696adfa020 Mon Sep 17 00:00:00 2001 From: mcpcpc Date: Tue, 18 Aug 2020 05:27:15 -0400 Subject: added :Q command --- README | 7 ++++--- kirc.c | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README b/README index fb024ba..4abaab3 100644 --- a/README +++ b/README @@ -15,7 +15,6 @@ FEATURES -------- - automatic host PING response. -- automatic word wrapping based on default (or user defined) widths. - vi-like shortcuts: :m send a message to the current channel @@ -23,9 +22,11 @@ FEATURES :n send a message to NickServ :j join a specified channel :p leave a specified channel - :q close the host connection and quit kirc + :Q send a message and close the host connection + :q close the host connection -- Color scheme definition via ANSI 8-bit colors [1]. Therefore, one could +- automatic word wrapping using the greedy algorithm. +- color scheme definition via ANSI 8-bit colors [1]. Therefore, one could theoretically achieve uniform color definition across all shell applications and tools. diff --git a/kirc.c b/kirc.c index af5687c..5e48494 100644 --- a/kirc.c +++ b/kirc.c @@ -194,7 +194,7 @@ main(int argc, char **argv) { printf("%*s press key to exit", gutl, " "); } else { - char usrin[cmax], v1[cmax], v2[20]; + char usrin[cmax], v1[cmax], v2[20], c1; struct termios tp, save; tcgetattr(STDIN_FILENO, &tp); @@ -210,12 +210,12 @@ main(int argc, char **argv) { fgets(usrin, cmax, stdin); tcsetattr(STDIN_FILENO, TCSANOW, &save); - if (usrin[0] == ':') { - if (sscanf(usrin, ":%*[M] %s %[^\n]\n", v2, v1) != 3) { - sscanf(usrin, ":%*[njpm] %[^\n]\n", v1); - } + if (sscanf(usrin, ":%[M] %s %[^\n]\n", &c1, v2, v1) == 3 || + sscanf(usrin, ":%[Qnjpm] %[^\n]\n", &c1, v1) == 2 || + sscanf(usrin, ":%[q]\n", &c1) == 1) { switch (usrin[1]) { case 'q': dprintf(fd[1], "quit\n"); break; + case 'Q': dprintf(fd[1], "quit %s\n", v1); break; case 'j': dprintf(fd[1], "join %s\n", v1); break; case 'p': dprintf(fd[1], "part %s\n", v1); break; case 'm': dprintf(fd[1], "privmsg #%s :%s\n", chan, v1); break; -- cgit v1.2.3