aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-03-11 23:05:57 -0400
committerB. Watson <urchlay@slackware.uk>2026-03-11 23:05:57 -0400
commit4ac4aa49d77da3f471ca34a025074cf4a10be841 (patch)
treee08ecf73137f69a5573d1a76ecdd082704091e70 /src
parentb2178fd7a85d64c078f5d0231d2c5e5c86cf2c60 (diff)
downloadfujinet-chat-4ac4aa49d77da3f471ca34a025074cf4a10be841.tar.gz
Add a bunch of Start keystrokes (see ui_keys.txt)
Diffstat (limited to 'src')
-rw-r--r--src/cmd.c5
-rw-r--r--src/irc.c107
-rw-r--r--src/irc.h1
3 files changed, 108 insertions, 5 deletions
diff --git a/src/cmd.c b/src/cmd.c
index 219794f..0c6f1a6 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -269,6 +269,11 @@ static void do_ctcp_ping(void) {
send_ctcp();
}
+void cmd_ctcp_ping(char *nick) {
+ arg1 = nick;
+ do_ctcp_ping();
+}
+
static void do_ctcp_info(void) {
arg2 = "CLIENTINFO";
arg3 = 0;
diff --git a/src/irc.c b/src/irc.c
index 7a27d0c..9777392 100644
--- a/src/irc.c
+++ b/src/irc.c
@@ -64,8 +64,12 @@ static void do_pong(void) {
txbuf_send();
}
+static void bold(void) {
+ scr_print_active("\x02");
+}
+
static void hilite_bold(void) {
- if(hilite) scr_print_active("\x02");
+ if(hilite) bold();
}
static void do_chan_nick(void) {
@@ -699,6 +703,14 @@ static void hunt_screen(signed char dir) {
scr_display(s);
}
+static char cur_is_chan(void) {
+ return (scr_current > 2 && scr_names[scr_current][0] == '#');
+}
+
+static char cur_is_query(void) {
+ return (scr_current > 2 && !cur_is_chan());
+}
+
void switch_to_active() {
char i;
@@ -711,6 +723,74 @@ void switch_to_active() {
}
}
+void list_screens(void) {
+ char i;
+
+ scr_activate(scr_current);
+ for(i = 0; i < MAX_SCREENS; i++) {
+ if(scr_status[i] != SCR_UNUSED) {
+ bold();
+ scr_putc_active(i + '1');
+ bold();
+ scr_putc_active(':');
+ scr_print_active(scr_names[i]);
+ scr_eol_active();
+ }
+ }
+}
+
+void join_last_invite(void) {
+ // TODO!
+}
+
+/* TODO: factor out stuff into scr_is_channel(), scr_is_query() */
+void ui_whois_or_ping(char is_ping) {
+ char *nick;
+
+ if(scr_current == SCR_SERVER)
+ return;
+
+ if(cur_is_chan())
+ return;
+
+ if(scr_current == SCR_PRIV)
+ nick = last_pm_nick;
+ else
+ nick = scr_names[scr_current];
+
+ if(!nick[0]) return;
+
+ if(is_ping) {
+ cmd_ctcp_ping(nick);
+ } else {
+ txbuf_set_str2("WHOIS ", nick);
+ txbuf_send();
+ }
+}
+
+void ui_part(void) {
+ if(!cur_is_chan())
+ return;
+ txbuf_set_str2("PART ", scr_names[scr_current]);
+ txbuf_send();
+}
+
+void ui_names(void) {
+ char *chan;
+
+ if(scr_current == SCR_SERVER && *last_chan)
+ chan = last_chan;
+ else if(cur_is_chan())
+ chan = scr_names[scr_current];
+ else
+ return;
+
+ if(!chan[0]) return;
+
+ txbuf_set_str2("NAMES ", scr_names[scr_current]);
+ txbuf_send();
+}
+
static void start_keystroke(void) {
char i, s;
@@ -727,11 +807,14 @@ static void start_keystroke(void) {
return;
}
- switch(i) {
+ switch(tolower(i)) {
case CH_CURS_UP:
case '-':
scrollback();
return;
+ case 0x24: /* ^X */
+ ui_part();
+ /* fall thru */
case CH_ESC:
scr_prev = SCR_PRIV;
scr_destroy(scr_current);
@@ -752,21 +835,35 @@ static void start_keystroke(void) {
scr_prev = i;
return;
case 'q':
- case 'Q':
if(scr_current == SCR_PRIV && *last_pm_nick) {
+ scr_prev = scr_current;
scr_create(last_pm_nick, 1);
*last_pm_nick = 0;
} else if(scr_current == SCR_SERVER && *last_chan) {
+ scr_prev = scr_current;
scr_create(last_chan, 1);
*last_chan = 0;
}
return;
case 'a':
- case 'A':
switch_to_active();
return;
+ case 'l':
+ list_screens();
+ return;
+ case 'j':
+ join_last_invite();
+ return;
+ case 'w':
+ ui_whois_or_ping(0);
+ return;
+ case 'n':
+ ui_names();
+ return;
+ case 'p':
+ ui_whois_or_ping(1);
+ return;
case 's':
- case 'S':
edbox_hide();
/* fall thru */
default:
diff --git a/src/irc.h b/src/irc.h
index 7feeb24..d513604 100644
--- a/src/irc.h
+++ b/src/irc.h
@@ -63,4 +63,5 @@ void print_errnum(void);
void cmd_command(char *cmd);
void cmd_execute(void);
void cmd_rejoin_chans(void);
+void cmd_ctcp_ping(char *nick);
unsigned int read_rtclok(void); /* irc.c needs this one so it's not static */