1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-07 18:23:13 +02:00

Added auto completion with channels and filenames

This commit is contained in:
Sebastien Helleu
2006-11-29 08:28:26 +00:00
parent f1dbe04c20
commit 59a0d27668
6 changed files with 98 additions and 58 deletions
+2 -1
View File
@@ -1,10 +1,11 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2006-11-28
ChangeLog - 2006-11-29
Version 0.2.2 (under dev!):
* added auto completion with channels and filenames
* fixed memleak in keyboard input
* fixed refresh bug when changing config options if window is splited
* added space between chat and nicklist when position is "right" (bug #17852)
+46 -28
View File
@@ -1000,12 +1000,7 @@ completion_find_context (t_completion *completion, char *buffer, int size, int p
}
}
else
{
if (completion->channel)
completion->context = COMPLETION_NICK;
else
completion->context = COMPLETION_NULL;
}
completion->context = COMPLETION_AUTO;
/* look for word to complete (base word) */
completion->base_word_pos = 0;
@@ -1078,29 +1073,14 @@ completion_find_context (t_completion *completion, char *buffer, int size, int p
}
}
/* nick completion with nothing as base word is disabled,
/* auto completion with nothing as base word is disabled,
in order to prevent completion when pasting messages with [tab] inside */
if ((completion->context == COMPLETION_NICK)
if ((completion->context == COMPLETION_AUTO)
&& ((!completion->base_word) || (!completion->base_word[0])))
{
completion->context = COMPLETION_NULL;
return;
}
if (!completion->completion_list && completion->channel &&
((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_DCC_CHAT))
&& (completion->context == COMPLETION_NICK))
{
/* nick completion in private (only other nick and self) */
completion->context = COMPLETION_NICK;
weelist_add (&completion->completion_list,
&completion->last_completion,
((t_irc_channel *)(completion->channel))->name);
weelist_add (&completion->completion_list,
&completion->last_completion,
((t_irc_server *)(completion->server))->nick);
}
}
/*
@@ -1323,6 +1303,8 @@ completion_nick (t_completion *completion)
if (!completion->channel)
return;
completion->context = COMPLETION_NICK;
if ((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_DCC_CHAT))
{
@@ -1406,6 +1388,39 @@ completion_nick (t_completion *completion)
}
}
/*
* completion_auto: auto complete: nick, filename or channel
*/
void
completion_auto (t_completion *completion)
{
/* filename completion */
if ((completion->base_word[0] == '/')
|| (completion->base_word[0] == '~'))
{
if (!completion->completion_list)
completion_list_add_filename (completion);
completion_command_arg (completion, 0);
return;
}
/* channel completion */
if (string_is_channel (completion->base_word))
{
if (!completion->completion_list)
completion_list_add_server_channels (completion);
completion_command_arg (completion, 0);
return;
}
/* default: nick completion (if channel) */
if (completion->channel)
completion_nick (completion);
else
completion->context = COMPLETION_NULL;
}
/*
* completion_search: complete word according to context
*/
@@ -1433,10 +1448,7 @@ completion_search (t_completion *completion, int direction,
/* should never be executed */
return;
case COMPLETION_NICK:
if (completion->channel)
completion_nick (completion);
else
return;
completion_nick (completion);
break;
case COMPLETION_COMMAND:
completion_command (completion);
@@ -1445,7 +1457,13 @@ completion_search (t_completion *completion, int direction,
if (completion->completion_list)
completion_command_arg (completion, completion->arg_is_nick);
else
completion_nick (completion);
{
completion->context = COMPLETION_AUTO;
completion_auto (completion);
}
break;
case COMPLETION_AUTO:
completion_auto (completion);
break;
}
if (completion->word_found)
+1
View File
@@ -27,6 +27,7 @@
#define COMPLETION_NICK 1
#define COMPLETION_COMMAND 2
#define COMPLETION_COMMAND_ARG 3
#define COMPLETION_AUTO 4
typedef struct t_completion t_completion;
+2 -1
View File
@@ -1,10 +1,11 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2006-11-28
ChangeLog - 2006-11-29
Version 0.2.2 (under dev!):
* added auto completion with channels and filenames
* fixed memleak in keyboard input
* fixed refresh bug when changing config options if window is splited
* added space between chat and nicklist when position is "right" (bug #17852)
+46 -28
View File
@@ -1000,12 +1000,7 @@ completion_find_context (t_completion *completion, char *buffer, int size, int p
}
}
else
{
if (completion->channel)
completion->context = COMPLETION_NICK;
else
completion->context = COMPLETION_NULL;
}
completion->context = COMPLETION_AUTO;
/* look for word to complete (base word) */
completion->base_word_pos = 0;
@@ -1078,29 +1073,14 @@ completion_find_context (t_completion *completion, char *buffer, int size, int p
}
}
/* nick completion with nothing as base word is disabled,
/* auto completion with nothing as base word is disabled,
in order to prevent completion when pasting messages with [tab] inside */
if ((completion->context == COMPLETION_NICK)
if ((completion->context == COMPLETION_AUTO)
&& ((!completion->base_word) || (!completion->base_word[0])))
{
completion->context = COMPLETION_NULL;
return;
}
if (!completion->completion_list && completion->channel &&
((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_DCC_CHAT))
&& (completion->context == COMPLETION_NICK))
{
/* nick completion in private (only other nick and self) */
completion->context = COMPLETION_NICK;
weelist_add (&completion->completion_list,
&completion->last_completion,
((t_irc_channel *)(completion->channel))->name);
weelist_add (&completion->completion_list,
&completion->last_completion,
((t_irc_server *)(completion->server))->nick);
}
}
/*
@@ -1323,6 +1303,8 @@ completion_nick (t_completion *completion)
if (!completion->channel)
return;
completion->context = COMPLETION_NICK;
if ((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_DCC_CHAT))
{
@@ -1406,6 +1388,39 @@ completion_nick (t_completion *completion)
}
}
/*
* completion_auto: auto complete: nick, filename or channel
*/
void
completion_auto (t_completion *completion)
{
/* filename completion */
if ((completion->base_word[0] == '/')
|| (completion->base_word[0] == '~'))
{
if (!completion->completion_list)
completion_list_add_filename (completion);
completion_command_arg (completion, 0);
return;
}
/* channel completion */
if (string_is_channel (completion->base_word))
{
if (!completion->completion_list)
completion_list_add_server_channels (completion);
completion_command_arg (completion, 0);
return;
}
/* default: nick completion (if channel) */
if (completion->channel)
completion_nick (completion);
else
completion->context = COMPLETION_NULL;
}
/*
* completion_search: complete word according to context
*/
@@ -1433,10 +1448,7 @@ completion_search (t_completion *completion, int direction,
/* should never be executed */
return;
case COMPLETION_NICK:
if (completion->channel)
completion_nick (completion);
else
return;
completion_nick (completion);
break;
case COMPLETION_COMMAND:
completion_command (completion);
@@ -1445,7 +1457,13 @@ completion_search (t_completion *completion, int direction,
if (completion->completion_list)
completion_command_arg (completion, completion->arg_is_nick);
else
completion_nick (completion);
{
completion->context = COMPLETION_AUTO;
completion_auto (completion);
}
break;
case COMPLETION_AUTO:
completion_auto (completion);
break;
}
if (completion->word_found)
+1
View File
@@ -27,6 +27,7 @@
#define COMPLETION_NICK 1
#define COMPLETION_COMMAND 2
#define COMPLETION_COMMAND_ARG 3
#define COMPLETION_AUTO 4
typedef struct t_completion t_completion;