aboutsummaryrefslogtreecommitdiff
path: root/src/irc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/irc.c')
-rw-r--r--src/irc.c110
1 files changed, 67 insertions, 43 deletions
diff --git a/src/irc.c b/src/irc.c
index e48ef6d..1f7aad3 100644
--- a/src/irc.c
+++ b/src/irc.c
@@ -95,16 +95,14 @@ static void do_privmsg(void) {
static void do_join(void) {
if(streq_i(usernick, msg_src)) {
- /* if our nick is the source, create the screen if needed. if a
- screen can't be created, no harm done. */
- if(scr_active == SCR_SERVER)
- scr_create(msg_dest, 1);
+ scr_print_active("You have ");
} else {
scr_print_active(msg_src);
- scr_print_active(" has joined ");
- scr_print_active(msg_dest);
- scr_eol_active();
+ scr_print_active(" has ");
}
+ scr_print_active("joined ");
+ scr_print_active(msg_dest);
+ scr_eol_active();
}
static void do_nick(void) {
@@ -115,7 +113,7 @@ static void do_nick(void) {
scr_print_active(msg_src);
scr_print_active(" is ");
}
- scr_print_active(" now known as ");
+ scr_print_active("now known as ");
scr_print_active(msg_dest);
scr_eol_active();
}
@@ -158,11 +156,14 @@ static void do_kick(void) {
static void do_mode(void) {
int i;
- scr_print_active(msg_src);
+ if(msg_src)
+ scr_print_active(msg_src);
+ else
+ scr_print_active("Server");
scr_print_active(" sets mode: ");
for(i = 0; i < msg_argcount; i++) {
- scr_print_active(" ");
scr_print_active(msg_args[i]);
+ scr_print_active(" ");
}
if(msg_text) scr_print_active(msg_text);
scr_eol_active();
@@ -227,16 +228,6 @@ static void do_numeric(void) {
break;
/*
- case RPL_NAMREPLY:
- "Users in ##channel", msg_text
-
- case RPL_TOPIC:
- case RPL_NOTOPIC:
- set the topic for the screen, if there is one
-
- case RPL_TOPICWHOTIME:
- "Topic was set by <nick>", don't try to parse the UNIX timestamp.
-
case RPL_WHOISCERTFP:
case RPL_WHOISREGNICK:
case RPL_WHOISUSER:
@@ -252,16 +243,8 @@ static void do_numeric(void) {
case RPL_WHOISSECURE:
case RPL_WHOWASUSER:
These always go to the server window.
-
- case RPL_ENDOFWHOIS:
- case RPL_ENDOFWHOWAS:
- Don't print.
*/
- case RPL_ENDOFNAMES:
- /* don't print, just noise */
- break;
-
case ERR_NICKNAMEINUSE:
do_catchall(0);
if(!regged) {
@@ -276,20 +259,29 @@ static void do_numeric(void) {
case ERR_NOMOTD:
break;
+ case RPL_NAMREPLY:
+ scr_print_active(msg_args[2]);
+ scr_print_active(" users: ");
+ scr_print_active(msg_text);
+ scr_print_active("\n");
+ break;
+
+ case RPL_ENDOFNAMES:
+ /* don't print, just noise */
+ break;
+
case RPL_TOPIC:
- s = scr_getbyname(msg_args[1]);
- scr_print(s, "Topic for ");
- scr_print(s, msg_args[1]);
- scr_print(s, ": ");
- scr_print(s, msg_text);
- scr_putc(s, '\n');
+ scr_print_active("Topic for ");
+ scr_print_active(msg_args[1]);
+ scr_print_active(": ");
+ scr_print_active(msg_text);
+ scr_print_active("\n");
break;
case RPL_TOPICWHOTIME:
- s = scr_getbyname(msg_args[1]);
- scr_print(s, "Topic set by: ");
- scr_print(s, msg_args[1]);
- scr_putc(s, '\n');
+ scr_print_active("Topic set by ");
+ scr_print_active(msg_args[2]);
+ scr_print_active("\n");
break;
default:
@@ -306,12 +298,19 @@ static void invalid_msg(char type) {
void select_screen(void) {
char s;
- if(!msg_src || !msg_dest) {
+ if(!msg_dest) {
s = SCR_SERVER;
- } else {
+ } else if(*msg_dest == '#') {
s = scr_getbyname(msg_dest);
- if(!s && msg_dest[0] != '#')
- s = SCR_PRIV;
+ if(!s) s = SCR_SERVER;
+ } else {
+ s = scr_getbyname(msg_src);
+ if(!s) {
+ if(streq_i(msg_cmd, "PRIVMSG")) /* or maybe NOTICE? */
+ s = SCR_PRIV;
+ else
+ s = SCR_SERVER;
+ }
}
scr_activate(s);
}
@@ -355,6 +354,12 @@ static void parse_msg(void) {
/* ignore empty message */
if(!*msg) return;
+ /*
+ scr_print_active("RAW: ");
+ scr_print_active(msg);
+ scr_print_active("\n");
+ */
+
/* if there's a final multiword arg... */
/* FIXME: channel names can have colons, which breaks this... */
p = strstr(msg + 1, " :"); /* +1 to skip leading colon in msg source */
@@ -394,12 +399,29 @@ static void parse_msg(void) {
p = strtok(0, " ");
if(p) {
msg_args[msg_argcount] = p;
+ /* if any arg is a channel name, use it for the dest */
+ if(*p == '#')
+ msg_dest = p;
} else {
break;
}
}
}
- if(msg_argcount) msg_dest = msg_args[0];
+
+ /*
+ if(msg_dest) {
+ scr_print_current("got here, msg_dest is: ");
+ scr_print_current(msg_dest);
+ scr_print_current("\n");
+ }
+ */
+
+ if(!msg_dest) {
+ if(msg_argcount)
+ msg_dest = msg_args[0];
+ else if(msg_text)
+ msg_dest = msg_text;
+ }
if(msg_src) {
if((p = strstr(msg_src, "!"))) {
@@ -517,6 +539,8 @@ static void start_keystroke(void) {
scr_display(s);
} else if(i == CH_CURS_UP || i == '-') {
scrollback();
+ } else if(i == 0x1b) { /* escape */
+ scr_destroy(scr_current);
}
}