summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/completion.c71
-rw-r--r--weechat/src/common/completion.c71
2 files changed, 90 insertions, 52 deletions
diff --git a/src/common/completion.c b/src/common/completion.c
index f96d16b27..e065b12fe 100644
--- a/src/common/completion.c
+++ b/src/common/completion.c
@@ -514,6 +514,19 @@ completion_find_context (t_completion *completion, void *channel, char *buffer,
completion_build_list (completion, channel);
}
}
+
+ if (!completion->completion_list && channel
+ && (((t_irc_channel *)channel)->type == CHAT_PRIVATE))
+ {
+ /* nick completion in private (only other nick and self) */
+ completion->context = COMPLETION_NICK;
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ ((t_irc_channel *)channel)->name);
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ SERVER(gui_current_window->buffer)->nick);
+ }
}
/*
@@ -564,32 +577,30 @@ completion_command (t_completion *completion)
}
/*
- * completion_nick: complete a nick
+ * completion_command_arg: complete a command argument
*/
void
-completion_nick (t_completion *completion, t_irc_channel *channel)
+completion_command_arg (t_completion *completion, t_irc_channel *channel)
{
int length, word_found_seen, other_completion;
- t_irc_nick *ptr_nick, *ptr_nick2;
-
- if (!channel)
- return;
+ t_weelist *ptr_weelist, *ptr_weelist2;
length = strlen (completion->base_word);
word_found_seen = 0;
other_completion = 0;
- for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
+ for (ptr_weelist = completion->completion_list; ptr_weelist;
+ ptr_weelist = ptr_weelist->next_weelist)
{
- if (strncasecmp (ptr_nick->nick, completion->base_word, length) == 0)
+ if (strncasecmp (ptr_weelist->data, completion->base_word, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
- completion->word_found = ptr_nick->nick;
- for (ptr_nick2 = ptr_nick->next_nick; ptr_nick2;
- ptr_nick2 = ptr_nick2->next_nick)
+ completion->word_found = ptr_weelist->data;
+ for (ptr_weelist2 = ptr_weelist->next_weelist; ptr_weelist2;
+ ptr_weelist2 = ptr_weelist2->next_weelist)
{
- if (strncasecmp (ptr_nick2->nick,
+ if (strncasecmp (ptr_weelist2->data,
completion->base_word, length) == 0)
other_completion++;
}
@@ -603,41 +614,49 @@ completion_nick (t_completion *completion, t_irc_channel *channel)
other_completion++;
}
if (completion->word_found &&
- (strcasecmp (ptr_nick->nick, completion->word_found) == 0))
+ (strcasecmp (ptr_weelist->data, completion->word_found) == 0))
word_found_seen = 1;
}
if (completion->word_found)
{
completion->word_found = NULL;
- completion_nick (completion, channel);
+ completion_command_arg (completion, channel);
}
}
/*
- * completion_command_arg: complete a command argument
+ * completion_nick: complete a nick
*/
void
-completion_command_arg (t_completion *completion, t_irc_channel *channel)
+completion_nick (t_completion *completion, t_irc_channel *channel)
{
int length, word_found_seen, other_completion;
- t_weelist *ptr_weelist, *ptr_weelist2;
+ t_irc_nick *ptr_nick, *ptr_nick2;
+
+ if (!channel)
+ return;
+
+ if (((t_irc_channel *)channel)->type == CHAT_PRIVATE)
+ {
+ completion_command_arg (completion, channel);
+ return;
+ }
length = strlen (completion->base_word);
word_found_seen = 0;
other_completion = 0;
- for (ptr_weelist = completion->completion_list; ptr_weelist;
- ptr_weelist = ptr_weelist->next_weelist)
+ for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
{
- if (strncasecmp (ptr_weelist->data, completion->base_word, length) == 0)
+ if (strncasecmp (ptr_nick->nick, completion->base_word, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
- completion->word_found = ptr_weelist->data;
- for (ptr_weelist2 = ptr_weelist->next_weelist; ptr_weelist2;
- ptr_weelist2 = ptr_weelist2->next_weelist)
+ completion->word_found = ptr_nick->nick;
+ for (ptr_nick2 = ptr_nick->next_nick; ptr_nick2;
+ ptr_nick2 = ptr_nick2->next_nick)
{
- if (strncasecmp (ptr_weelist2->data,
+ if (strncasecmp (ptr_nick2->nick,
completion->base_word, length) == 0)
other_completion++;
}
@@ -651,13 +670,13 @@ completion_command_arg (t_completion *completion, t_irc_channel *channel)
other_completion++;
}
if (completion->word_found &&
- (strcasecmp (ptr_weelist->data, completion->word_found) == 0))
+ (strcasecmp (ptr_nick->nick, completion->word_found) == 0))
word_found_seen = 1;
}
if (completion->word_found)
{
completion->word_found = NULL;
- completion_command_arg (completion, channel);
+ completion_nick (completion, channel);
}
}
diff --git a/weechat/src/common/completion.c b/weechat/src/common/completion.c
index f96d16b27..e065b12fe 100644
--- a/weechat/src/common/completion.c
+++ b/weechat/src/common/completion.c
@@ -514,6 +514,19 @@ completion_find_context (t_completion *completion, void *channel, char *buffer,
completion_build_list (completion, channel);
}
}
+
+ if (!completion->completion_list && channel
+ && (((t_irc_channel *)channel)->type == CHAT_PRIVATE))
+ {
+ /* nick completion in private (only other nick and self) */
+ completion->context = COMPLETION_NICK;
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ ((t_irc_channel *)channel)->name);
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ SERVER(gui_current_window->buffer)->nick);
+ }
}
/*
@@ -564,32 +577,30 @@ completion_command (t_completion *completion)
}
/*
- * completion_nick: complete a nick
+ * completion_command_arg: complete a command argument
*/
void
-completion_nick (t_completion *completion, t_irc_channel *channel)
+completion_command_arg (t_completion *completion, t_irc_channel *channel)
{
int length, word_found_seen, other_completion;
- t_irc_nick *ptr_nick, *ptr_nick2;
-
- if (!channel)
- return;
+ t_weelist *ptr_weelist, *ptr_weelist2;
length = strlen (completion->base_word);
word_found_seen = 0;
other_completion = 0;
- for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
+ for (ptr_weelist = completion->completion_list; ptr_weelist;
+ ptr_weelist = ptr_weelist->next_weelist)
{
- if (strncasecmp (ptr_nick->nick, completion->base_word, length) == 0)
+ if (strncasecmp (ptr_weelist->data, completion->base_word, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
- completion->word_found = ptr_nick->nick;
- for (ptr_nick2 = ptr_nick->next_nick; ptr_nick2;
- ptr_nick2 = ptr_nick2->next_nick)
+ completion->word_found = ptr_weelist->data;
+ for (ptr_weelist2 = ptr_weelist->next_weelist; ptr_weelist2;
+ ptr_weelist2 = ptr_weelist2->next_weelist)
{
- if (strncasecmp (ptr_nick2->nick,
+ if (strncasecmp (ptr_weelist2->data,
completion->base_word, length) == 0)
other_completion++;
}
@@ -603,41 +614,49 @@ completion_nick (t_completion *completion, t_irc_channel *channel)
other_completion++;
}
if (completion->word_found &&
- (strcasecmp (ptr_nick->nick, completion->word_found) == 0))
+ (strcasecmp (ptr_weelist->data, completion->word_found) == 0))
word_found_seen = 1;
}
if (completion->word_found)
{
completion->word_found = NULL;
- completion_nick (completion, channel);
+ completion_command_arg (completion, channel);
}
}
/*
- * completion_command_arg: complete a command argument
+ * completion_nick: complete a nick
*/
void
-completion_command_arg (t_completion *completion, t_irc_channel *channel)
+completion_nick (t_completion *completion, t_irc_channel *channel)
{
int length, word_found_seen, other_completion;
- t_weelist *ptr_weelist, *ptr_weelist2;
+ t_irc_nick *ptr_nick, *ptr_nick2;
+
+ if (!channel)
+ return;
+
+ if (((t_irc_channel *)channel)->type == CHAT_PRIVATE)
+ {
+ completion_command_arg (completion, channel);
+ return;
+ }
length = strlen (completion->base_word);
word_found_seen = 0;
other_completion = 0;
- for (ptr_weelist = completion->completion_list; ptr_weelist;
- ptr_weelist = ptr_weelist->next_weelist)
+ for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
{
- if (strncasecmp (ptr_weelist->data, completion->base_word, length) == 0)
+ if (strncasecmp (ptr_nick->nick, completion->base_word, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
- completion->word_found = ptr_weelist->data;
- for (ptr_weelist2 = ptr_weelist->next_weelist; ptr_weelist2;
- ptr_weelist2 = ptr_weelist2->next_weelist)
+ completion->word_found = ptr_nick->nick;
+ for (ptr_nick2 = ptr_nick->next_nick; ptr_nick2;
+ ptr_nick2 = ptr_nick2->next_nick)
{
- if (strncasecmp (ptr_weelist2->data,
+ if (strncasecmp (ptr_nick2->nick,
completion->base_word, length) == 0)
other_completion++;
}
@@ -651,13 +670,13 @@ completion_command_arg (t_completion *completion, t_irc_channel *channel)
other_completion++;
}
if (completion->word_found &&
- (strcasecmp (ptr_weelist->data, completion->word_found) == 0))
+ (strcasecmp (ptr_nick->nick, completion->word_found) == 0))
word_found_seen = 1;
}
if (completion->word_found)
{
completion->word_found = NULL;
- completion_command_arg (completion, channel);
+ completion_nick (completion, channel);
}
}