Skip to content

Commit 5267727

Browse files
committed
added :Q command
1 parent c9a215d commit 5267727

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

README

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ FEATURES
1515
--------
1616

1717
- automatic host PING response.
18-
- automatic word wrapping based on default (or user defined) widths.
1918
- vi-like shortcuts:
2019

2120
:m <message> send a message to the current channel
2221
:M <nick|channel> <message> send a message to a specified nick or channel
2322
:n <message> send a message to NickServ
2423
:j <channel> join a specified channel
2524
:p <channel> leave a specified channel
26-
:q close the host connection and quit kirc
25+
:Q <message> send a message and close the host connection
26+
:q close the host connection
2727

28-
- Color scheme definition via ANSI 8-bit colors [1]. Therefore, one could
28+
- automatic word wrapping using the greedy algorithm.
29+
- color scheme definition via ANSI 8-bit colors [1]. Therefore, one could
2930
theoretically achieve uniform color definition across all shell applications
3031
and tools.
3132

kirc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ main(int argc, char **argv) {
194194
printf("%*s press <RETURN> key to exit", gutl, " ");
195195
}
196196
else {
197-
char usrin[cmax], v1[cmax], v2[20];
197+
char usrin[cmax], v1[cmax], v2[20], c1;
198198
struct termios tp, save;
199199

200200
tcgetattr(STDIN_FILENO, &tp);
@@ -210,12 +210,12 @@ main(int argc, char **argv) {
210210
fgets(usrin, cmax, stdin);
211211
tcsetattr(STDIN_FILENO, TCSANOW, &save);
212212

213-
if (usrin[0] == ':') {
214-
if (sscanf(usrin, ":%*[M] %s %[^\n]\n", v2, v1) != 3) {
215-
sscanf(usrin, ":%*[njpm] %[^\n]\n", v1);
216-
}
213+
if (sscanf(usrin, ":%[M] %s %[^\n]\n", &c1, v2, v1) == 3 ||
214+
sscanf(usrin, ":%[Qnjpm] %[^\n]\n", &c1, v1) == 2 ||
215+
sscanf(usrin, ":%[q]\n", &c1) == 1) {
217216
switch (usrin[1]) {
218217
case 'q': dprintf(fd[1], "quit\n"); break;
218+
case 'Q': dprintf(fd[1], "quit %s\n", v1); break;
219219
case 'j': dprintf(fd[1], "join %s\n", v1); break;
220220
case 'p': dprintf(fd[1], "part %s\n", v1); break;
221221
case 'm': dprintf(fd[1], "privmsg #%s :%s\n", chan, v1); break;

0 commit comments

Comments
 (0)