mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05:00
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
This commit is contained in:
parent
c248de0eca
commit
dd7ce4af23
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user