From dd7ce4af23a0bb68a8c735c7e9a4c0d9c50ae08b Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 28 Jun 2000 15:44:43 +0000 Subject: You can complete #channels, Irssi uses only the joined channels and channels in setup. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@386 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/irc/irc-completion.c | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/fe-common/irc') diff --git a/src/fe-common/irc/irc-completion.c b/src/fe-common/irc/irc-completion.c index 9243ac21..362dd84c 100644 --- a/src/fe-common/irc/irc-completion.c +++ b/src/fe-common/irc/irc-completion.c @@ -28,6 +28,7 @@ #include "irc.h" #include "server.h" #include "channels.h" +#include "channels-setup.h" #include "nicklist.h" #include "completion.h" @@ -40,6 +41,39 @@ typedef struct { char *nick; } NICK_COMPLETION_REC; +GList *completion_get_channels(IRC_SERVER_REC *server, const char *word) +{ + GList *list; + GSList *tmp; + int len; + + g_return_val_if_fail(word != NULL, NULL); + g_return_val_if_fail(*word != '\0', NULL); + + len = strlen(word); + list = NULL; + + /* first get the joined channels */ + tmp = server == NULL ? NULL : server->channels; + for (; tmp != NULL; tmp = tmp->next) { + CHANNEL_REC *rec = tmp->data; + + if (g_strncasecmp(rec->name, word, len) == 0) + list = g_list_append(list, g_strdup(rec->name)); + } + + /* get channels from setup */ + for (tmp = setupchannels; tmp != NULL; tmp = tmp->next) { + SETUP_CHANNEL_REC *rec = tmp->data; + + if (g_strncasecmp(rec->name, word, len) == 0) + list = g_list_append(list, g_strdup(rec->name)); + + } + + return list; +} + static void nick_completion_destroy(GSList **list, NICK_COMPLETION_REC *rec) { *list = g_slist_remove(*list, rec); @@ -316,6 +350,12 @@ static void sig_complete_word(GList **list, WINDOW_REC *window, g_return_if_fail(word != NULL); g_return_if_fail(linestart != NULL); + if (ischannel(*word)) { + /* probably completing a channel name */ + *list = completion_get_channels((IRC_SERVER_REC *) window->active_server, word); + return; + } + server = window->active_server; if (server == NULL || !server->connected) return; -- cgit v1.2.3