diff options
| author | B. Watson <urchlay@slackware.uk> | 2026-03-18 01:00:56 -0400 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2026-03-18 01:00:56 -0400 |
| commit | 5fc2f41a80a1ef6f62b95dc96ee352564a5ff221 (patch) | |
| tree | 757bdbd08465eb812c2b713a0ad5bf7d273c8b05 | |
| parent | 11da121cabfab3830d46608262b5be47ce7861f6 (diff) | |
| download | fujinet-chat-5fc2f41a80a1ef6f62b95dc96ee352564a5ff221.tar.gz | |
Nick completion in channels
| -rw-r--r-- | TODO | 4 | ||||
| -rw-r--r-- | src/complete.c | 62 |
2 files changed, 61 insertions, 5 deletions
@@ -16,13 +16,13 @@ Other stuff: - *Thoroughly* test the nick and channel tab completion for the [private] and [server] screens. +- Fix the nick completion in channel screens. It works, but needs some + polishing up. - Ping the server periodically, and set a 30-sec timer. If no PONG within 30 sec, assume we're disconnected: close the connection and go into the reconnect loop. - More scrollback. Of course it needs more memory... see doc/scrollback.txt for my ideas on this. -- Status indicators # M J etc should disappear at some point. When - the user switches windows. Also maybe there should be a timer. - ^U works, but is slow (calls backspace() in a loop, which does a memmove() each time). - Server /ping command is iffy (see do_server_pong() in irc.c). diff --git a/src/complete.c b/src/complete.c index f7ec731..130a015 100644 --- a/src/complete.c +++ b/src/complete.c @@ -17,6 +17,7 @@ static char prefix[33]; char comp_pm_nicks[MAX_PM_NICKS][25]; char comp_pm_chans[MAX_PM_NICKS][25]; +char comp_chan_nicks[MAX_PM_NICKS][25]; char (*list)[25] = comp_pm_nicks; char (*add_to)[25] = comp_pm_nicks; @@ -61,6 +62,60 @@ char match(const char *p, const char *q) { return 1; } +void scrape_nick(char *p) { + char i; + + if(*p == '<' || *p == 0xbc) { + /* normal or inverse < in column 0 is a nick */ + p++; + } else if(*p == '*' && p[1] == ' ') { + p += 2; /* /me action, skip the "* " */ + } else { + return; + } + + if(*p & 0x80) /* skip highlighted own nick! */ + return; + + for(i = 0; i < 24; i++) { + switch(p[i]) { + case '>': + case 0xbe: /* inverse > */ + case ' ': + list[pm_nick_pos++][i] = 0; + return; /* found one, terminate and return */ + case 0: + list[pm_nick_pos][0] = 0; + return; /* if it ends with a null, it's not a nick */ + default: + list[pm_nick_pos][i] = p[i]; + break; + } + } + list[pm_nick_pos][0] = 0; +} + +void find_chan_nicks(void) { + signed char i; + char *p; + + add_to = comp_chan_nicks; + pm_nick_pos = 0; + + for(i = 22; i >= 0; i--) { + p = screen_bot_addrs[scr_current] + 40 * i; + scrape_nick(p); + if(pm_nick_pos == MAX_PM_NICKS) + return; + } + for(i = 24; i >= 0; i--) { + scrape_nick(p); + p = screen_top_addrs[scr_current] + 40 * i; + if(pm_nick_pos == MAX_PM_NICKS) + return; + } +} + void comp_complete_done(void) { in_progress = 0; } @@ -89,9 +144,10 @@ void comp_start(void) { } else if(scr_current == SCR_PRIV) { p = last_pm_nick; list = comp_pm_nicks; - } else { - /* channel screens not yet supported */ - return; + } else if(scr_names[scr_current][0] == '#') { + p = last_pm_nick; // XXX: there should be a last_hilite_nick! + find_chan_nicks(); + list = comp_chan_nicks; } /* just insert the last nick/chan if there's nothing to search for */ |
