aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormcpcpc <michaelczigler@icloud.com>2020-08-18 05:27:15 -0400
committermcpcpc <michaelczigler@icloud.com>2020-08-18 05:27:15 -0400
commit526772742b1d5a3545d98f42194bbe696adfa020 (patch)
tree9f049b39a8be2876cd5c2ad8d0e8dc8a71efd5b9
parentcleaned up command option switch (diff)
downloadkirc-526772742b1d5a3545d98f42194bbe696adfa020.tar.gz
kirc-526772742b1d5a3545d98f42194bbe696adfa020.tar.bz2
kirc-526772742b1d5a3545d98f42194bbe696adfa020.tar.xz
kirc-526772742b1d5a3545d98f42194bbe696adfa020.tar.zst
kirc-526772742b1d5a3545d98f42194bbe696adfa020.zip
added :Q command
-rw-r--r--README7
-rw-r--r--kirc.c10
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 <message> send a message to the current channel
@@ -23,9 +22,11 @@ FEATURES
:n <message> send a message to NickServ
:j <channel> join a specified channel
:p <channel> leave a specified channel
- :q close the host connection and quit kirc
+ :Q <message> 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 <RETURN> 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;