diff options
Diffstat (limited to 'src/complete.c')
| -rw-r--r-- | src/complete.c | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/src/complete.c b/src/complete.c index 0ac00a7..f7ec731 100644 --- a/src/complete.c +++ b/src/complete.c @@ -16,26 +16,41 @@ static char search_pos = 0, in_progress = 0; static char prefix[33]; char comp_pm_nicks[MAX_PM_NICKS][25]; +char comp_pm_chans[MAX_PM_NICKS][25]; char (*list)[25] = comp_pm_nicks; +char (*add_to)[25] = comp_pm_nicks; static char pm_nick_pos = 0; /* insertion point for _add() */ -void comp_add_pm_nick(const char *n) { +static void add_list(const char *n) { int i; for(i = 0; i < 25; i++) - if(strncmp(n, comp_pm_nicks[i], 24) == 0) - return; + if(strncmp(n, add_to[i], 24) == 0) + return; /* we already got this one */ - strncpy(comp_pm_nicks[pm_nick_pos], n, 24); + strncpy(add_to[pm_nick_pos], n, 24); pm_nick_pos++; pm_nick_pos %= MAX_PM_NICKS; } +void comp_add_pm_nick(const char *n) { + add_to = comp_pm_nicks; + add_list(n); +} + +void comp_add_pm_chan(const char *n) { + add_to = comp_pm_chans; + add_list(n); +} + char match(const char *p, const char *q) { int len; - len = strlen(prefix); + while(*p == '#') p++; + while(*q == '#') q++; + + len = strlen(p); if(!len) return 0; while(len--) { @@ -55,27 +70,40 @@ void comp_continue(void) { while(search_pos < MAX_PM_NICKS) { if(match(prefix, list[search_pos])) { edbox_set(list[search_pos]); + edbox_space(); search_pos++; return; } search_pos++; } - edbox_set(prefix); + edbox_set(prefix); /* no space here */ comp_complete_done(); } void comp_start(void) { - if(scr_current != SCR_PRIV) + char *p; + + if(scr_current == SCR_SERVER) { + p = last_chan; + list = comp_pm_chans; + } else if(scr_current == SCR_PRIV) { + p = last_pm_nick; + list = comp_pm_nicks; + } else { + /* channel screens not yet supported */ return; + } - /* just insert the last nick if there's nothing to search for */ + /* just insert the last nick/chan if there's nothing to search for */ if(!edbox_len) { - if(*last_pm_nick) edbox_set(last_pm_nick); + if(*p) { + edbox_set(p); + edbox_space(); + } } else { in_progress = COMP_PM; search_pos = 0; strncpy(prefix, edit_box, 24); - list = comp_pm_nicks; comp_continue(); } } |
