diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd.c | 40 | ||||
| -rw-r--r-- | src/irc.c | 18 | ||||
| -rw-r--r-- | src/irc.h | 1 | ||||
| -rw-r--r-- | src/main.c | 10 | ||||
| -rw-r--r-- | src/screen.c | 9 | ||||
| -rw-r--r-- | src/screen.h | 2 |
6 files changed, 62 insertions, 18 deletions
@@ -7,34 +7,50 @@ /* A "command" is actually anything the user types, whether or not it starts with a /character. */ -void cmd_chan_text(const char *cmd) { +static char *target; +static const char *command; +static char slashcmd[10]; +static char *slasharg; + +static void cmd_chan_text(void) { char s; - s = scr_getbyname(channel); - scr_activate(s); + scr_activate(scr_current); /* 0x02 = ^B = enable bold */ - scr_print_active("\x02<"); + scr_print_active("<\x02"); scr_print_active(usernick); + scr_print_active("\x02"); if(!s) { scr_print_active("/"); - scr_print_active(channel); + scr_print_active(target); } - scr_print_active(">\x02 "); + scr_print_active(" "); + scr_print_active(command); + scr_print_active(">"); + scr_eol_active(); txbuf_set_str("PRIVMSG "); - txbuf_append_str(channel); + txbuf_append_str(target); txbuf_append_str(" :"); - txbuf_append_str(cmd); + txbuf_append_str(command); txbuf_send(); } +static void cmd_slash(void) { + txbuf_send_str(command + 1); +} + void cmd_command(const char *cmd) { + command = cmd; + + target = scr_get_cur_name(); + if(*cmd == '/') - txbuf_send_str(cmd + 1); - else if(channel[0]) - cmd_chan_text(cmd); - else scr_print_current("*** You are not on a channel\n"); + cmd_slash(); + else if(target) + cmd_chan_text(); + else scr_print_current("*** You are not in a channel\n"); } void cmd_execute(void) { @@ -22,12 +22,14 @@ static char msgbuf[MAX_MSG] = { 0 }; static char *msg; /* with source removed */ static int msgbuf_len = 0, msg_len = 0; -static char regged = 0; +static char regged = 0, hilite = 0; +/* static void join_channel(void) { txbuf_set_str2("JOIN ", channel); txbuf_send(); } +*/ static void print_reason(void) { if(msg_text) { @@ -43,15 +45,23 @@ static void do_pong(void) { txbuf_send(); } +static void hilite_bold(void) { + if(hilite) scr_print_active("\x02"); +} + static void do_chan_nick(void) { + hilite_bold(); scr_print_active("<"); + hilite_bold(); scr_print_active(msg_src); if(scr_active == SCR_SERVER) { /* if we don't have a window for it */ scr_print_active("/"); scr_print_active(msg_dest); } + hilite_bold(); scr_print_active("> "); + hilite_bold(); } static void do_priv_nick(void) { @@ -61,6 +71,12 @@ static void do_priv_nick(void) { } static void do_privmsg(void) { + /* TODO: this shouldn't be case-sensitive */ + if(strstr(msg_text, usernick)) + hilite = 1; + else + hilite = 0; + if(*msg_dest == '#') do_chan_nick(); else @@ -7,7 +7,6 @@ /**** main.c */ extern char url[256]; extern char usernick[32]; -extern char channel[32]; extern char *rx_buf; extern unsigned short rxbuflen; extern unsigned char err; @@ -30,7 +30,6 @@ bool old_enabled=false; // were interrupts enabled for old vector void* old_vprced; // old PROCEED vector, restored on exit. unsigned short rxbuflen; unsigned int txbuflen; // TX buffer length -char channel[32] = DEF_CHANNEL; /* TODO: user modes (default +iw), fg/bg color... */ @@ -44,11 +43,12 @@ void get_config(void) { edbox_readline(url, sizeof(url)); scr_print_current("Nick?\n"); edbox_readline(usernick, sizeof(usernick)); - scr_print_current("Channel?\n"); - edbox_readline(channel, sizeof(channel)); + /* scr_print_current("Are these settings OK [Y/n]?\n"); - if(tolower(cgetc()) != 'n') break; + if(tolower(cgetc()) != 'n') + */ + break; } } @@ -128,6 +128,8 @@ void fn_disconnect(void) { int main(void) { OS.shflok = 0; // turn off shift-lock. OS.soundr = 0; // Turn off SIO beeping sound + OS.color2 = 0xc0; /* darkest green background */ + OS.color1 = 0x0c; /* bright text */ scr_init(); diff --git a/src/screen.c b/src/screen.c index 8fd2309..e7f83b4 100644 --- a/src/screen.c +++ b/src/screen.c @@ -88,6 +88,7 @@ void scr_destroy(char s) { return; scr_status[s] = SCR_UNUSED; + scr_names[s][0] = 0; if(scr_current == s) scr_display(0); } @@ -267,3 +268,11 @@ void scr_activate(char s) { } scr_active = s; } + +char *scr_get_cur_name(void) { + char *r = scr_names[scr_current]; + if(*r) + return r; + else + return 0; +} diff --git a/src/screen.h b/src/screen.h index bb70999..a53530b 100644 --- a/src/screen.h +++ b/src/screen.h @@ -101,6 +101,8 @@ void scr_print_priv(const char *text); will have to call this. */ void scr_activate(char s); +char *scr_get_cur_name(void); + /* XXX: this really should be in a utils.c or common.c... */ void scr_waitvcount(u8 c); |
