diff options
author | Timo Sirainen <cras@irssi.org> | 2000-12-02 05:01:55 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-12-02 05:01:55 +0000 |
commit | fda66b542c0f56a5d4aadfde8d93afe2dde251a5 (patch) | |
tree | 236596efcdba2e29d68a7a684df8bcea0cff472f /src | |
parent | 9ab8b13fd801dfdf2fb5aad3842693ec26eb67b4 (diff) | |
download | irssi-fda66b542c0f56a5d4aadfde8d93afe2dde251a5.zip |
Nick completion now completes nicks from all channels in active window,
except when completing the first word in line only nicks in active
channel are completed.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@914 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-common/core/chat-completion.c | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/src/fe-common/core/chat-completion.c b/src/fe-common/core/chat-completion.c index b04d2dfb..99827f58 100644 --- a/src/fe-common/core/chat-completion.c +++ b/src/fe-common/core/chat-completion.c @@ -404,14 +404,50 @@ GList *completion_get_channels(SERVER_REC *server, const char *word) return list; } +static void complete_window_nicks(GList **list, WINDOW_REC *window, + const char *word, const char *linestart) +{ + CHANNEL_REC *channel; + GList *tmplist; + GSList *tmp; + const char *nickprefix; + + nickprefix = *linestart != '\0' ? NULL : + settings_get_str("completion_char"); + + channel = CHANNEL(window->active); + + /* first the active channel */ + if (channel != NULL) { + tmplist = completion_channel_nicks(channel, word, nickprefix); + *list = completion_joinlist(*list, tmplist); + } + + if (nickprefix != NULL) { + /* completing nick at the start of line - probably answering + to some other nick, don't even try to complete from + non-active channels */ + return; + } + + /* then the rest */ + for (tmp = window->items; tmp != NULL; tmp = tmp->next) { + channel = CHANNEL(tmp->data); + if (channel != NULL && tmp->data != window->active) { + tmplist = completion_channel_nicks(channel, word, + nickprefix); + *list = completion_joinlist(*list, tmplist); + } + } +} + static void sig_complete_word(GList **list, WINDOW_REC *window, const char *word, const char *linestart) { SERVER_REC *server; CHANNEL_REC *channel; QUERY_REC *query; - GList *tmplist; - const char *cmdchars, *nickprefix; + const char *cmdchars; char *prefix; g_return_if_fail(list != NULL); @@ -454,11 +490,7 @@ static void sig_complete_word(GList **list, WINDOW_REC *window, } else if (channel != NULL) { /* nick completion .. we could also be completing a nick after /MSG from nicks in channel */ - nickprefix = *linestart != '\0' ? NULL : - settings_get_str("completion_char"); - - tmplist = completion_channel_nicks(channel, word, nickprefix); - *list = completion_joinlist(*list, tmplist); + complete_window_nicks(list, window, word, linestart); } if (*list != NULL) signal_stop(); |