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

Add new options for completion, optional stop instead of cycling with words found

This commit is contained in:
Sebastien Helleu
2008-06-18 16:47:09 +02:00
parent 47c9c68b40
commit 66e8d703bd
38 changed files with 1190 additions and 517 deletions
+6 -4
View File
@@ -805,20 +805,22 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
*/
int
alias_completion_cb (void *data, const char *completion,
struct t_gui_buffer *buffer, struct t_weelist *list)
alias_completion_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
struct t_alias *ptr_alias;
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
(void) buffer;
for (ptr_alias = alias_list; ptr_alias;
ptr_alias = ptr_alias->next_alias)
{
weechat_list_add (list, ptr_alias->name, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, ptr_alias->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
+68 -50
View File
@@ -38,17 +38,21 @@
*/
int
irc_completion_server_cb (void *data, const char *completion,
struct t_gui_buffer *buffer, struct t_weelist *list)
irc_completion_server_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
IRC_GET_SERVER(buffer);
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
if (ptr_server)
weechat_list_add (list, ptr_server->name, WEECHAT_LIST_POS_SORT);
{
weechat_hook_completion_list_add (completion, ptr_server->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -59,9 +63,9 @@ irc_completion_server_cb (void *data, const char *completion,
*/
int
irc_completion_server_nicks_cb (void *data, const char *completion,
irc_completion_server_nicks_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list)
struct t_gui_completion *completion)
{
struct t_irc_channel *ptr_channel2;
struct t_irc_nick *ptr_nick;
@@ -70,7 +74,7 @@ irc_completion_server_nicks_cb (void *data, const char *completion,
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
(void) buffer;
if (ptr_server)
@@ -83,14 +87,15 @@ irc_completion_server_nicks_cb (void *data, const char *completion,
for (ptr_nick = ptr_channel2->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
weechat_list_add (list, ptr_nick->name,
WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, ptr_nick->name,
1, WEECHAT_LIST_POS_SORT);
}
}
}
/* add self nick at the end */
weechat_list_add (list, ptr_server->nick, WEECHAT_LIST_POS_END);
weechat_hook_completion_list_add (completion, ptr_server->nick,
1, WEECHAT_LIST_POS_END);
}
return WEECHAT_RC_OK;
@@ -101,20 +106,22 @@ irc_completion_server_nicks_cb (void *data, const char *completion,
*/
int
irc_completion_servers_cb (void *data, const char *completion,
struct t_gui_buffer *buffer, struct t_weelist *list)
irc_completion_servers_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
struct t_irc_server *ptr_server;
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
(void) buffer;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
weechat_list_add (list, ptr_server->name, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, ptr_server->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@@ -125,17 +132,21 @@ irc_completion_servers_cb (void *data, const char *completion,
*/
int
irc_completion_channel_cb (void *data, const char *completion,
struct t_gui_buffer *buffer, struct t_weelist *list)
irc_completion_channel_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
IRC_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
if (ptr_channel)
weechat_list_add (list, ptr_channel->name, WEECHAT_LIST_POS_SORT);
{
weechat_hook_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -146,9 +157,9 @@ irc_completion_channel_cb (void *data, const char *completion,
*/
int
irc_completion_channel_nicks_cb (void *data, const char *completion,
irc_completion_channel_nicks_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list)
struct t_gui_completion *completion)
{
struct t_irc_nick *ptr_nick;
char *nick;
@@ -158,7 +169,7 @@ irc_completion_channel_nicks_cb (void *data, const char *completion,
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
if (ptr_channel)
{
@@ -167,8 +178,8 @@ irc_completion_channel_nicks_cb (void *data, const char *completion,
for (ptr_nick = ptr_channel->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
weechat_list_add (list, ptr_nick->name,
WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, ptr_nick->name,
1, WEECHAT_LIST_POS_SORT);
}
/* add nicks speaking recently on this channel */
@@ -180,18 +191,20 @@ irc_completion_channel_nicks_cb (void *data, const char *completion,
nick = weechat_list_string (weechat_list_get (ptr_channel->nicks_speaking, i));
if (nick && irc_nick_search (ptr_channel, nick))
{
weechat_list_add (list, nick,
WEECHAT_LIST_POS_BEGINNING);
weechat_hook_completion_list_add (completion, nick,
1, WEECHAT_LIST_POS_BEGINNING);
}
}
}
/* add self nick at the end */
weechat_list_add (list, ptr_server->nick, WEECHAT_LIST_POS_END);
weechat_hook_completion_list_add (completion, ptr_server->nick,
1, WEECHAT_LIST_POS_END);
}
if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
{
weechat_list_add (list, ptr_channel->name, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_SORT);
}
ptr_channel->nick_completion_reset = 0;
@@ -206,9 +219,9 @@ irc_completion_channel_nicks_cb (void *data, const char *completion,
*/
int
irc_completion_channel_nicks_hosts_cb (void *data, const char *completion,
irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list)
struct t_gui_completion *completion)
{
struct t_irc_nick *ptr_nick;
char *buf;
@@ -218,7 +231,7 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion,
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
if (ptr_channel)
{
@@ -227,7 +240,8 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion,
for (ptr_nick = ptr_channel->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
weechat_list_add (list, ptr_nick->name, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, ptr_nick->name,
1, WEECHAT_LIST_POS_SORT);
if (ptr_nick->host)
{
length = strlen (ptr_nick->name) + 1 +
@@ -237,7 +251,8 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion,
{
snprintf (buf, length, "%s!%s",
ptr_nick->name, ptr_nick->host);
weechat_list_add (list, buf, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, buf,
0, WEECHAT_LIST_POS_SORT);
free (buf);
}
}
@@ -245,8 +260,8 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion,
}
if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
{
weechat_list_add (list, ptr_channel->name,
WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_SORT);
}
}
@@ -259,9 +274,9 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion,
*/
int
irc_completion_channel_topic_cb (void *data, const char *completion,
irc_completion_channel_topic_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list)
struct t_gui_completion *completion)
{
char *topic_color;
@@ -269,14 +284,14 @@ irc_completion_channel_topic_cb (void *data, const char *completion,
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
if (ptr_channel && ptr_channel->topic && ptr_channel->topic[0])
{
topic_color = irc_color_decode_for_user_entry (ptr_channel->topic);
weechat_list_add (list,
(topic_color) ? topic_color : ptr_channel->topic,
WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion,
(topic_color) ? topic_color : ptr_channel->topic,
0, WEECHAT_LIST_POS_SORT);
if (topic_color)
free (topic_color);
}
@@ -289,15 +304,16 @@ irc_completion_channel_topic_cb (void *data, const char *completion,
*/
int
irc_completion_channels_cb (void *data, const char *completion,
struct t_gui_buffer *buffer, struct t_weelist *list)
irc_completion_channels_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
(void) buffer;
for (ptr_server = irc_servers; ptr_server;
@@ -306,7 +322,8 @@ irc_completion_channels_cb (void *data, const char *completion,
for (ptr_channel = ptr_server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
weechat_list_add (list, ptr_channel->name, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_SORT);
}
}
@@ -318,20 +335,21 @@ irc_completion_channels_cb (void *data, const char *completion,
*/
int
irc_completion_msg_part_cb (void *data, const char *completion,
struct t_gui_buffer *buffer, struct t_weelist *list)
irc_completion_msg_part_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
(void) buffer;
if (weechat_config_string (irc_config_network_default_msg_part)
&& weechat_config_string (irc_config_network_default_msg_part)[0])
{
weechat_list_add (list,
weechat_config_string (irc_config_network_default_msg_part),
WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion,
weechat_config_string (irc_config_network_default_msg_part),
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
+1
View File
@@ -380,6 +380,7 @@ plugin_load (const char *filename)
new_plugin->hook_signal_send = &hook_signal_send;
new_plugin->hook_config = &hook_config;
new_plugin->hook_completion = &hook_completion;
new_plugin->hook_completion_list_add = &hook_completion_list_add;
new_plugin->hook_modifier = &hook_modifier;
new_plugin->hook_modifier_exec = &hook_modifier_exec;
new_plugin->unhook = &unhook;
+50 -4
View File
@@ -2882,9 +2882,9 @@ weechat_lua_api_hook_config (lua_State *L)
*/
int
weechat_lua_api_hook_completion_cb (void *data, const char *completion,
weechat_lua_api_hook_completion_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list)
struct t_gui_completion *completion)
{
struct t_script_callback *script_callback;
char *lua_argv[4];
@@ -2892,9 +2892,9 @@ weechat_lua_api_hook_completion_cb (void *data, const char *completion,
script_callback = (struct t_script_callback *)data;
lua_argv[0] = (char *)completion;
lua_argv[0] = (char *)completion_item;
lua_argv[1] = script_ptr2str (buffer);
lua_argv[2] = script_ptr2str (list);
lua_argv[2] = script_ptr2str (completion);
lua_argv[3] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
@@ -2960,6 +2960,51 @@ weechat_lua_api_hook_completion (lua_State *L)
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_hook_completion_list_add: add a word to list for a completion
*/
static int
weechat_lua_api_hook_completion_list_add (lua_State *L)
{
const char *completion, *word, *where;
int n, nick_completion;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add");
LUA_RETURN_ERROR;
}
completion = NULL;
word = NULL;
nick_completion = 0;
where = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 4)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add");
LUA_RETURN_ERROR;
}
completion = lua_tostring (lua_current_interpreter, -4);
word = lua_tostring (lua_current_interpreter, -3);
nick_completion = lua_tonumber (lua_current_interpreter, -2);
where = lua_tostring (lua_current_interpreter, -1);
weechat_hook_completion_list_add (script_str2ptr (completion),
word,
nick_completion,
where);
LUA_RETURN_OK;
}
/*
* weechat_lua_api_hook_modifier_cb: callback for modifier hooked
*/
@@ -4999,6 +5044,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "hook_signal_send", &weechat_lua_api_hook_signal_send },
{ "hook_config", &weechat_lua_api_hook_config },
{ "hook_completion", &weechat_lua_api_hook_completion },
{ "hook_completion_list_add", &weechat_lua_api_hook_completion_list_add },
{ "hook_modifier", &weechat_lua_api_hook_modifier },
{ "hook_modifier_exec", &weechat_lua_api_hook_modifier_exec },
{ "unhook", &weechat_lua_api_unhook },
+4 -4
View File
@@ -413,16 +413,16 @@ weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer,
*/
int
weechat_lua_completion_cb (void *data, const char *completion,
weechat_lua_completion_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list)
struct t_gui_completion *completion)
{
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
(void) buffer;
script_completion (weechat_lua_plugin, list, lua_scripts);
script_completion (weechat_lua_plugin, completion, lua_scripts);
return WEECHAT_RC_OK;
}
+41 -4
View File
@@ -2398,9 +2398,9 @@ static XS (XS_weechat_hook_config)
*/
int
weechat_perl_api_hook_completion_cb (void *data, const char *completion,
weechat_perl_api_hook_completion_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list)
struct t_gui_completion *completion)
{
struct t_script_callback *script_callback;
char *perl_argv[4];
@@ -2408,9 +2408,9 @@ weechat_perl_api_hook_completion_cb (void *data, const char *completion,
script_callback = (struct t_script_callback *)data;
perl_argv[0] = (char *)completion;
perl_argv[0] = (char *)completion_item;
perl_argv[1] = script_ptr2str (buffer);
perl_argv[2] = script_ptr2str (list);
perl_argv[2] = script_ptr2str (completion);
perl_argv[3] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
@@ -2468,6 +2468,42 @@ static XS (XS_weechat_hook_completion)
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::hook_completion_list_add: add a word to list for a completion
*/
static XS (XS_weechat_hook_completion_list_add)
{
char *completion, *word, *where;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add");
PERL_RETURN_ERROR;
}
if (items < 4)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add");
PERL_RETURN_ERROR;
}
completion = SvPV (ST (0), PL_na);
word = SvPV (ST (1), PL_na);
where = SvPV (ST (3), PL_na);
weechat_hook_completion_list_add (script_str2ptr (completion),
word,
SvIV (ST (2)), /* nick_completion */
where);
PERL_RETURN_OK;
}
/*
* weechat_perl_api_hook_modifier_cb: callback for modifier hooked
*/
@@ -3922,6 +3958,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::hook_signal_send", XS_weechat_hook_signal_send, "weechat");
newXS ("weechat::hook_config", XS_weechat_hook_config, "weechat");
newXS ("weechat::hook_completion", XS_weechat_hook_completion, "weechat");
newXS ("weechat::hook_completion_list_add", XS_weechat_hook_completion_list_add, "weechat");
newXS ("weechat::hook_modifier", XS_weechat_hook_modifier, "weechat");
newXS ("weechat::hook_modifier_exec", XS_weechat_hook_modifier_exec, "weechat");
newXS ("weechat::unhook", XS_weechat_unhook, "weechat");
+4 -4
View File
@@ -554,16 +554,16 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
*/
int
weechat_perl_completion_cb (void *data, const char *completion,
weechat_perl_completion_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list)
struct t_gui_completion *completion)
{
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
(void) buffer;
script_completion (weechat_perl_plugin, list, perl_scripts);
script_completion (weechat_perl_plugin, completion, perl_scripts);
return WEECHAT_RC_OK;
}
@@ -2552,9 +2552,9 @@ weechat_python_api_hook_config (PyObject *self, PyObject *args)
*/
int
weechat_python_api_hook_completion_cb (void *data, const char *completion,
weechat_python_api_hook_completion_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list)
struct t_gui_completion *completion)
{
struct t_script_callback *script_callback;
char *python_argv[4];
@@ -2562,9 +2562,9 @@ weechat_python_api_hook_completion_cb (void *data, const char *completion,
script_callback = (struct t_script_callback *)data;
python_argv[0] = (char *)completion;
python_argv[0] = (char *)completion_item;
python_argv[1] = script_ptr2str (buffer);
python_argv[2] = script_ptr2str (list);
python_argv[2] = script_ptr2str (completion);
python_argv[3] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
@@ -2624,6 +2624,45 @@ weechat_python_api_hook_completion (PyObject *self, PyObject *args)
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_hook_completion_list_add: add a word to list for a completion
*/
static PyObject *
weechat_python_api_hook_completion_list_add (PyObject *self, PyObject *args)
{
char *completion, *word, *where;
int nick_completion;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add");
PYTHON_RETURN_ERROR;
}
completion = NULL;
word = NULL;
nick_completion = 0;
where = NULL;
if (!PyArg_ParseTuple (args, "ssis", &completion, &word, &nick_completion,
&where))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add");
PYTHON_RETURN_ERROR;
}
weechat_hook_completion_list_add (script_str2ptr (completion),
word,
nick_completion,
where);
PYTHON_RETURN_OK;
}
/*
* weechat_python_api_hook_modifier_cb: callback for modifier hooked
*/
@@ -4169,6 +4208,7 @@ PyMethodDef weechat_python_funcs[] =
{ "hook_signal_send", &weechat_python_api_hook_signal_send, METH_VARARGS, "" },
{ "hook_config", &weechat_python_api_hook_config, METH_VARARGS, "" },
{ "hook_completion", &weechat_python_api_hook_completion, METH_VARARGS, "" },
{ "hook_completion_list_add", &weechat_python_api_hook_completion_list_add, METH_VARARGS, "" },
{ "hook_modifier", &weechat_python_api_hook_modifier, METH_VARARGS, "" },
{ "hook_modifier_exec", &weechat_python_api_hook_modifier_exec, METH_VARARGS, "" },
{ "unhook", &weechat_python_api_unhook, METH_VARARGS, "" },
+4 -4
View File
@@ -605,16 +605,16 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
*/
int
weechat_python_completion_cb (void *data, const char *completion,
weechat_python_completion_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list)
struct t_gui_completion *completion)
{
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
(void) buffer;
script_completion (weechat_python_plugin, list, python_scripts);
script_completion (weechat_python_plugin, completion, python_scripts);
return WEECHAT_RC_OK;
}
+56 -4
View File
@@ -2939,9 +2939,9 @@ weechat_ruby_api_hook_config (VALUE class, VALUE option, VALUE function)
*/
int
weechat_ruby_api_hook_completion_cb (void *data, const char *completion,
weechat_ruby_api_hook_completion_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list)
struct t_gui_completion *completion)
{
struct t_script_callback *script_callback;
char *ruby_argv[4];
@@ -2949,9 +2949,9 @@ weechat_ruby_api_hook_completion_cb (void *data, const char *completion,
script_callback = (struct t_script_callback *)data;
ruby_argv[0] = (char *)completion;
ruby_argv[0] = (char *)completion_item;
ruby_argv[1] = script_ptr2str (buffer);
ruby_argv[2] = script_ptr2str (list);
ruby_argv[2] = script_ptr2str (completion);
ruby_argv[3] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
@@ -3018,6 +3018,57 @@ weechat_ruby_api_hook_completion (VALUE class, VALUE completion,
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_hook_completion_list_add: add a word to list for a completion
*/
static VALUE
weechat_ruby_api_hook_completion_list_add (VALUE class, VALUE completion,
VALUE word, VALUE nick_completion,
VALUE where)
{
char *c_completion, *c_word, *c_where;
int c_nick_completion;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add");
RUBY_RETURN_ERROR;
}
c_completion = NULL;
c_word = NULL;
c_nick_completion = 0;
c_where = NULL;
if (NIL_P (completion) || NIL_P (word) || NIL_P (nick_completion)
|| NIL_P (where))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add");
RUBY_RETURN_ERROR;
}
Check_Type (completion, T_STRING);
Check_Type (word, T_STRING);
Check_Type (nick_completion, T_FIXNUM);
Check_Type (where, T_STRING);
c_completion = STR2CSTR (completion);
c_word = STR2CSTR (word);
c_nick_completion = FIX2INT (nick_completion);
c_where = STR2CSTR (where);
weechat_hook_completion_list_add (script_str2ptr (c_completion),
c_word,
c_nick_completion,
c_where);
RUBY_RETURN_OK;
}
/*
* weechat_ruby_api_hook_modifier_cb: callback for modifier hooked
*/
@@ -4800,6 +4851,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "hook_signal_send", &weechat_ruby_api_hook_signal_send, 3);
rb_define_module_function (ruby_mWeechat, "hook_config", &weechat_ruby_api_hook_config, 2);
rb_define_module_function (ruby_mWeechat, "hook_completion", &weechat_ruby_api_hook_completion, 2);
rb_define_module_function (ruby_mWeechat, "hook_completion_list_add", &weechat_ruby_api_hook_completion_list_add, 4);
rb_define_module_function (ruby_mWeechat, "hook_modifier", &weechat_ruby_api_hook_modifier, 2);
rb_define_module_function (ruby_mWeechat, "hook_modifier_exec", &weechat_ruby_api_hook_modifier_exec, 3);
rb_define_module_function (ruby_mWeechat, "unhook", &weechat_ruby_api_unhook, 1);
+4 -4
View File
@@ -589,16 +589,16 @@ weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer,
*/
int
weechat_ruby_completion_cb (void *data, const char *completion,
weechat_ruby_completion_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list)
struct t_gui_completion *completion)
{
/* make C compiler happy */
(void) data;
(void) completion;
(void) completion_item;
(void) buffer;
script_completion (weechat_ruby_plugin, list, ruby_scripts);
script_completion (weechat_ruby_plugin, completion, ruby_scripts);
return WEECHAT_RC_OK;
}
+3 -2
View File
@@ -832,9 +832,10 @@ struct t_hook *
script_api_hook_completion (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *completion,
int (*callback)(void *data, const char *completion,
int (*callback)(void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list),
struct t_gui_completion *completion),
const char *function)
{
struct t_script_callback *new_script_callback;
+2 -2
View File
@@ -142,9 +142,9 @@ extern struct t_hook *script_api_hook_completion (struct t_weechat_plugin *weech
struct t_plugin_script *script,
const char *completion,
int (*callback)(void *data,
const char *completion,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list),
struct t_gui_completion *completion),
const char *function);
extern struct t_hook *script_api_hook_modifier (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
+5 -4
View File
@@ -84,9 +84,9 @@ script_init (struct t_weechat_plugin *weechat_plugin,
struct t_gui_buffer *buffer,
int argc, char **argv,
char **argv_eol),
int (*callback_completion)(void *data, const char *completion,
int (*callback_completion)(void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list),
struct t_gui_completion *completion),
int (*callback_signal_debug_dump)(void *data, const char *signal,
const char *type_data,
void *signal_data),
@@ -525,7 +525,7 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
void
script_completion (struct t_weechat_plugin *weechat_plugin,
struct t_weelist *list,
struct t_gui_completion *completion,
struct t_plugin_script *scripts)
{
struct t_plugin_script *ptr_script;
@@ -533,7 +533,8 @@ script_completion (struct t_weechat_plugin *weechat_plugin,
for (ptr_script = scripts; ptr_script;
ptr_script = ptr_script->next_script)
{
weechat_list_add (list, ptr_script->name, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, ptr_script->name,
0, WEECHAT_LIST_POS_SORT);
}
}
+4 -3
View File
@@ -61,9 +61,10 @@ extern void script_init (struct t_weechat_plugin *weechat_plugin,
struct t_gui_buffer *buffer,
int argc, char **argv,
char **argv_eol),
int (*callback_completion)(void *data, const char *completion,
int (*callback_completion)(void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list),
struct t_gui_completion *completion),
int (*callback_signal_debug_dump)(void *data,
const char *signal,
const char *type_data,
@@ -94,7 +95,7 @@ extern void script_remove (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script **scripts,
struct t_plugin_script *script);
extern void script_completion (struct t_weechat_plugin *weechat_plugin,
struct t_weelist *list,
struct t_gui_completion *completion,
struct t_plugin_script *scripts);
extern void script_display_list (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts,
+12 -3
View File
@@ -27,6 +27,7 @@ struct t_gui_window;
struct t_gui_buffer;
struct t_gui_bar;
struct t_gui_bar_item;
struct t_gui_completion;
struct t_weelist;
/* macros for defining plugin infos */
@@ -349,12 +350,15 @@ struct t_weechat_plugin
const char *value),
void *callback_data);
struct t_hook *(*hook_completion) (struct t_weechat_plugin *plugin,
const char *completion,
const char *completion_item,
int (*callback)(void *data,
const char *completion,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_weelist *list),
struct t_gui_completion *completion),
void *callback_data);
void (*hook_completion_list_add) (struct t_gui_completion *completion,
const char *word, int nick_completion,
const char *where);
struct t_hook *(*hook_modifier) (struct t_weechat_plugin *plugin,
const char *modifier,
char *(*callback)(void *data,
@@ -781,6 +785,11 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
#define weechat_hook_completion(__completion, __callback, __data) \
weechat_plugin->hook_completion(weechat_plugin, __completion, \
__callback, __data)
#define weechat_hook_completion_list_add(__completion, __word, \
__nick_completion, __where) \
weechat_plugin->hook_completion_list_add(__completion, __word, \
__nick_completion, \
__where)
#define weechat_hook_modifier(__modifier, __callback, __data) \
weechat_plugin->hook_modifier(weechat_plugin, __modifier, \
__callback, __data)