mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 07:16:37 +02:00
Add support of many templates for completion of command arguments, rename default completion items
This commit is contained in:
@@ -953,7 +953,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
"by user, and $* is replaced by all arguments.\n"
|
||||
"Variables $nick, $channel and $server are "
|
||||
"replaced by current nick/channel/server."),
|
||||
"%(alias) %h",
|
||||
"%(alias) %(commands)",
|
||||
&alias_command_cb, NULL);
|
||||
|
||||
weechat_hook_command ("unalias", N_("remove an alias"),
|
||||
@@ -962,7 +962,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
"%(alias)",
|
||||
&unalias_command_cb, NULL);
|
||||
|
||||
weechat_hook_completion ("alias", &alias_completion_cb, NULL);
|
||||
weechat_hook_completion ("alias", N_("list of alias"),
|
||||
&alias_completion_cb, NULL);
|
||||
|
||||
alias_info_init ();
|
||||
|
||||
|
||||
@@ -909,6 +909,31 @@ weechat_aspell_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_completion_langs_cb: completion with aspell langs
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_aspell_completion_langs_cb (void *data, const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
for (i = 0; langs_avail[i].code; i++)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, langs_avail[i].code,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_plugin_init : init aspell plugin
|
||||
*/
|
||||
@@ -941,8 +966,14 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
"\n"
|
||||
"Input line beginning with a '/' is not checked, "
|
||||
"except for some commands."),
|
||||
"dictlist|enable|disable|addword",
|
||||
"dictlist"
|
||||
" || enable %(aspell_langs)"
|
||||
" || disable"
|
||||
" || addword",
|
||||
&weechat_aspell_command_cb, NULL);
|
||||
weechat_hook_completion ("aspell_langs",
|
||||
N_("list of supported langs for aspell"),
|
||||
&weechat_aspell_completion_langs_cb, NULL);
|
||||
|
||||
/* callback for buffer_switch */
|
||||
weechat_hook_signal ("buffer_switch",
|
||||
|
||||
@@ -416,7 +416,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
"arguments: optional arguments for info\n\n"
|
||||
"Without argument, this command displays list "
|
||||
"of available infos"),
|
||||
"%i",
|
||||
"%(infos)",
|
||||
&demo_info_command_cb, NULL);
|
||||
|
||||
weechat_hook_command ("demo_infolist",
|
||||
@@ -426,7 +426,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
"arguments: optional arguments for infolist\n\n"
|
||||
"Without argument, this command displays list "
|
||||
"of available infolists"),
|
||||
"%I",
|
||||
"%(infolists)",
|
||||
&demo_infolist_command_cb, NULL);
|
||||
|
||||
weechat_hook_signal ("*", &demo_signal_cb, NULL);
|
||||
|
||||
@@ -3773,7 +3773,9 @@ irc_command_init ()
|
||||
"is 6667)\n"
|
||||
" ipv6: use IPv6 protocol\n"
|
||||
" ssl: use SSL protocol"),
|
||||
"%(irc_servers)|-all|-nojoin|%*", &irc_command_connect, NULL);
|
||||
"-all -nojoin"
|
||||
" || %(irc_servers)|%*",
|
||||
&irc_command_connect, NULL);
|
||||
weechat_hook_command ("ctcp",
|
||||
N_("send a CTCP message (Client-To-Client Protocol)"),
|
||||
N_("receiver type [arguments]"),
|
||||
@@ -3781,7 +3783,7 @@ irc_command_init ()
|
||||
" type: CTCP type (examples: \"version\", "
|
||||
"\"ping\", ..)\n"
|
||||
"arguments: arguments for CTCP"),
|
||||
"%(irc_channel)|%n action|ping|version",
|
||||
"%(irc_channel)|%(nicks) action|ping|version",
|
||||
&irc_command_ctcp, NULL);
|
||||
weechat_hook_command ("cycle",
|
||||
N_("leave and rejoin a channel"),
|
||||
@@ -3796,25 +3798,26 @@ irc_command_init ()
|
||||
N_(" action: 'send' (file) or 'chat'\n"
|
||||
"nickname: nickname to send file or chat\n"
|
||||
" file: filename (on local host)"),
|
||||
"chat|send %n %f",
|
||||
"chat %(nicks)"
|
||||
" || send %(nicks) %(filename)",
|
||||
&irc_command_dcc, NULL);
|
||||
weechat_hook_command ("dehalfop",
|
||||
N_("remove half channel operator status from "
|
||||
"nickname(s)"),
|
||||
N_("[nickname [nickname]]"),
|
||||
"",
|
||||
NULL, &irc_command_dehalfop, NULL);
|
||||
"%(nicks)", &irc_command_dehalfop, NULL);
|
||||
weechat_hook_command ("deop",
|
||||
N_("remove channel operator status from "
|
||||
"nickname(s)"),
|
||||
N_("[nickname [nickname]]"),
|
||||
"",
|
||||
NULL, &irc_command_deop, NULL);
|
||||
"%(nicks)|%*", &irc_command_deop, NULL);
|
||||
weechat_hook_command ("devoice",
|
||||
N_("remove voice from nickname(s)"),
|
||||
N_("[nickname [nickname]]"),
|
||||
"",
|
||||
NULL, &irc_command_devoice, NULL);
|
||||
"%(nicks)|%*", &irc_command_devoice, NULL);
|
||||
weechat_hook_command ("die",
|
||||
N_("shutdown the server"),
|
||||
"",
|
||||
@@ -3825,13 +3828,15 @@ irc_command_init ()
|
||||
N_("[-all | servername [servername ...]]"),
|
||||
N_(" -all: disconnect from all servers\n"
|
||||
"servername: server name to disconnect"),
|
||||
"%(irc_servers)|-all", &irc_command_disconnect, NULL);
|
||||
"-all"
|
||||
" || %(irc_servers)|%*",
|
||||
&irc_command_disconnect, NULL);
|
||||
weechat_hook_command ("halfop",
|
||||
N_("give half channel operator status to "
|
||||
"nickname(s)"),
|
||||
N_("[nickname [nickname]]"),
|
||||
"",
|
||||
NULL, &irc_command_halfop, NULL);
|
||||
"%(nicks)", &irc_command_halfop, NULL);
|
||||
weechat_hook_command ("ignore",
|
||||
N_("ignore nicks/hosts from servers or channels"),
|
||||
N_("[list] | [add [re:]nick/host [server [channel]]] | "
|
||||
@@ -3856,8 +3861,10 @@ irc_command_init ()
|
||||
" /ignore add toto@domain.com freenode\n"
|
||||
" ignore host \"toto*@*.domain.com\" on freenode/#weechat:\n"
|
||||
" /ignore add toto*@*.domain.com freenode #weechat"),
|
||||
"list|add|del %(irc_channel_nicks_hosts) "
|
||||
"%(irc_servers) %(irc_channels) ", &irc_command_ignore, NULL);
|
||||
"list"
|
||||
" || add %(irc_channel_nicks_hosts) %(irc_servers) %(irc_channels) %-"
|
||||
" || del -all|%(irc_ignores_numbers) %-",
|
||||
&irc_command_ignore, NULL);
|
||||
weechat_hook_command ("info",
|
||||
N_("get information describing the server"),
|
||||
N_("[target]"),
|
||||
@@ -3868,12 +3875,12 @@ irc_command_init ()
|
||||
N_("nickname channel"),
|
||||
N_("nickname: nick to invite\n"
|
||||
" channel: channel to invite"),
|
||||
"%n %(irc_channel)", &irc_command_invite, NULL);
|
||||
"%(nicks) %(irc_channel)", &irc_command_invite, NULL);
|
||||
weechat_hook_command ("ison",
|
||||
N_("check if a nickname is currently on IRC"),
|
||||
N_("nickname [nickname ...]"),
|
||||
N_("nickname: nickname"),
|
||||
NULL, &irc_command_ison, NULL);
|
||||
"%(nicks)|%*", &irc_command_ison, NULL);
|
||||
weechat_hook_command ("join",
|
||||
N_("join a channel"),
|
||||
N_("channel[,channel] [key[,key]]"),
|
||||
@@ -3886,7 +3893,7 @@ irc_command_init ()
|
||||
N_(" channel: channel where user is\n"
|
||||
"nickname: nickname to kick\n"
|
||||
" comment: comment for kick"),
|
||||
"%n %-", &irc_command_kick, NULL);
|
||||
"%(nicks) %-", &irc_command_kick, NULL);
|
||||
weechat_hook_command ("kickban",
|
||||
N_("kicks and bans a nick from a channel"),
|
||||
N_("[channel] nickname [comment]"),
|
||||
@@ -3899,7 +3906,7 @@ irc_command_init ()
|
||||
N_("nickname comment"),
|
||||
N_("nickname: nickname\n"
|
||||
" comment: comment for kill"),
|
||||
"%n %-", &irc_command_kill, NULL);
|
||||
"%(nicks) %-", &irc_command_kill, NULL);
|
||||
weechat_hook_command ("links",
|
||||
N_("list all servernames which are known by the "
|
||||
"server answering the query"),
|
||||
@@ -3969,31 +3976,35 @@ irc_command_init ()
|
||||
"receiver: nick or channel (may be mask, '*' = "
|
||||
"current channel)\n"
|
||||
" text: text to send"),
|
||||
NULL, &irc_command_msg, NULL);
|
||||
"-server %(irc_servers)"
|
||||
" || %(nicks) %-",
|
||||
&irc_command_msg, NULL);
|
||||
weechat_hook_command ("names",
|
||||
N_("list nicknames on channels"),
|
||||
N_("[channel[,channel]]"),
|
||||
N_("channel: channel name"),
|
||||
"%(irc_channels)|%*", &irc_command_names, NULL);
|
||||
"%(irc_channels)", &irc_command_names, NULL);
|
||||
weechat_hook_command ("nick",
|
||||
N_("change current nickname"),
|
||||
N_("[-all] nickname"),
|
||||
N_(" -all: set new nickname for all connected "
|
||||
"servers\n"
|
||||
"nickname: new nickname"),
|
||||
"-all", &irc_command_nick, NULL);
|
||||
"-all %(irc_server_nick)"
|
||||
" || %(irc_server_nick)",
|
||||
&irc_command_nick, NULL);
|
||||
weechat_hook_command ("notice",
|
||||
N_("send notice message to user"),
|
||||
N_("[-server server] nickname text"),
|
||||
N_(" server: send to this server (internal name)\n"
|
||||
"nickname: user to send notice to\n"
|
||||
" text: text to send"),
|
||||
"%n %-", &irc_command_notice, NULL);
|
||||
"%(nicks) %-", &irc_command_notice, NULL);
|
||||
weechat_hook_command ("op",
|
||||
N_("give channel operator status to nickname(s)"),
|
||||
N_("nickname [nickname]"),
|
||||
"",
|
||||
NULL, &irc_command_op, NULL);
|
||||
"%(nicks)|%*", &irc_command_op, NULL);
|
||||
weechat_hook_command ("oper",
|
||||
N_("get operator privileges"),
|
||||
N_("user password"),
|
||||
@@ -4026,7 +4037,7 @@ irc_command_init ()
|
||||
N_(" server: send to this server (internal name)\n"
|
||||
"nickname: nickname for private conversation\n"
|
||||
" text: text to send"),
|
||||
"%n %-", &irc_command_query, NULL);
|
||||
"%(nicks) %-", &irc_command_query, NULL);
|
||||
weechat_hook_command ("quote",
|
||||
N_("send raw data to server without parsing"),
|
||||
N_("[-server server] data"),
|
||||
@@ -4041,7 +4052,9 @@ irc_command_init ()
|
||||
"servername: server name to reconnect\n"
|
||||
" -nojoin: do not join any channel (even if "
|
||||
"autojoin is enabled on server)"),
|
||||
"%(irc_servers)|-all|-nojoin|%*", &irc_command_reconnect, NULL);
|
||||
"-all -nojoin"
|
||||
" || %(irc_servers)|-nojoin|%*",
|
||||
&irc_command_reconnect, NULL);
|
||||
weechat_hook_command ("rehash",
|
||||
N_("tell the server to reload its config file"),
|
||||
"",
|
||||
@@ -4171,7 +4184,7 @@ irc_command_init ()
|
||||
N_("return a list of information about nicknames"),
|
||||
N_("nickname [nickname ...]"),
|
||||
N_("nickname: nickname"),
|
||||
"%n", &irc_command_userhost, NULL);
|
||||
"%(nicks)", &irc_command_userhost, NULL);
|
||||
weechat_hook_command ("users",
|
||||
N_("list of users logged into the server"),
|
||||
N_("[target]"),
|
||||
@@ -4183,12 +4196,12 @@ irc_command_init ()
|
||||
N_("[server | nickname]"),
|
||||
N_(" server: server name\n"
|
||||
"nickname: nickname"),
|
||||
"%n", &irc_command_version, NULL);
|
||||
"%(nicks)", &irc_command_version, NULL);
|
||||
weechat_hook_command ("voice",
|
||||
N_("give voice to nickname(s)"),
|
||||
N_("[nickname [nickname]]"),
|
||||
"",
|
||||
NULL, &irc_command_voice, NULL);
|
||||
"%(nicks)|%*", &irc_command_voice, NULL);
|
||||
weechat_hook_command ("wallops",
|
||||
N_("send a message to all currently connected users "
|
||||
"who have set the 'w' user mode for themselves"),
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "irc-color.h"
|
||||
#include "irc-completion.h"
|
||||
#include "irc-config.h"
|
||||
#include "irc-ignore.h"
|
||||
#include "irc-server.h"
|
||||
#include "irc-channel.h"
|
||||
#include "irc-nick.h"
|
||||
@@ -424,6 +425,35 @@ irc_completion_msg_part_cb (void *data, const char *completion_item,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_completion_ignores_numbers_cb: callback for completion with ignores
|
||||
* numbers
|
||||
*/
|
||||
|
||||
int
|
||||
irc_completion_ignores_numbers_cb (void *data, const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
char str_number[32];
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
snprintf (str_number, sizeof (str_number), "%d", ptr_ignore->number);
|
||||
weechat_hook_completion_list_add (completion, str_number,
|
||||
0, WEECHAT_LIST_POS_END);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_completion_init: init completion for IRC plugin
|
||||
*/
|
||||
@@ -432,23 +462,36 @@ void
|
||||
irc_completion_init ()
|
||||
{
|
||||
weechat_hook_completion ("irc_server",
|
||||
N_("current IRC server"),
|
||||
&irc_completion_server_cb, NULL);
|
||||
weechat_hook_completion ("irc_server_nick",
|
||||
N_("nick on current IRC server"),
|
||||
&irc_completion_server_nick_cb, NULL);
|
||||
weechat_hook_completion ("irc_server_nicks",
|
||||
N_("nicks on all channels of current IRC server"),
|
||||
&irc_completion_server_nicks_cb, NULL);
|
||||
weechat_hook_completion ("irc_servers",
|
||||
N_("IRC servers (internal names)"),
|
||||
&irc_completion_servers_cb, NULL);
|
||||
weechat_hook_completion ("irc_channel",
|
||||
N_("current IRC channel"),
|
||||
&irc_completion_channel_cb, NULL);
|
||||
weechat_hook_completion ("nick",
|
||||
N_("nicks of current IRC channel"),
|
||||
&irc_completion_channel_nicks_cb, NULL);
|
||||
weechat_hook_completion ("irc_channel_nicks_hosts",
|
||||
N_("nicks and hostnames of current IRC channel"),
|
||||
&irc_completion_channel_nicks_hosts_cb, NULL);
|
||||
weechat_hook_completion ("irc_channel_topic",
|
||||
N_("topic of current IRC channel"),
|
||||
&irc_completion_channel_topic_cb, NULL);
|
||||
weechat_hook_completion ("irc_channels",
|
||||
N_("IRC channels (on all servers)"),
|
||||
&irc_completion_channels_cb, NULL);
|
||||
weechat_hook_completion ("irc_msg_part",
|
||||
N_("default part message for IRC channel"),
|
||||
&irc_completion_msg_part_cb, NULL);
|
||||
weechat_hook_completion ("irc_ignores_numbers",
|
||||
N_("numbers for defined ignores"),
|
||||
&irc_completion_ignores_numbers_cb, NULL);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
struct t_irc_server;
|
||||
|
||||
typedef int (t_irc_recv_func)(struct t_irc_server *server, const char *comand,
|
||||
typedef int (t_irc_recv_func)(struct t_irc_server *server, const char *command,
|
||||
int argc, char **argv, char **argv_eol);
|
||||
|
||||
struct t_irc_protocol_msg
|
||||
|
||||
@@ -819,7 +819,7 @@ jabber_command_init ()
|
||||
N_("buddy [text]"),
|
||||
N_("buddy: buddy name for chat\n"
|
||||
" text: text to send"),
|
||||
"%n %-", &jabber_command_jchat, NULL);
|
||||
"%(nicks) %-", &jabber_command_jchat, NULL);
|
||||
weechat_hook_command ("jconnect",
|
||||
N_("connect to Jabber server(s)"),
|
||||
N_("[-all [-nojoin] | servername [servername ...] "
|
||||
|
||||
@@ -435,24 +435,24 @@ jabber_completion_msg_part_cb (void *data, const char *completion_item,
|
||||
void
|
||||
jabber_completion_init ()
|
||||
{
|
||||
weechat_hook_completion ("jabber_server",
|
||||
weechat_hook_completion ("jabber_server", "",
|
||||
&jabber_completion_server_cb, NULL);
|
||||
weechat_hook_completion ("jabber_server_local_name",
|
||||
weechat_hook_completion ("jabber_server_local_name", "",
|
||||
&jabber_completion_server_local_name_cb, NULL);
|
||||
weechat_hook_completion ("jabber_server_buddies",
|
||||
weechat_hook_completion ("jabber_server_buddies", "",
|
||||
&jabber_completion_server_buddies_cb, NULL);
|
||||
weechat_hook_completion ("jabber_servers",
|
||||
weechat_hook_completion ("jabber_servers", "",
|
||||
&jabber_completion_servers_cb, NULL);
|
||||
weechat_hook_completion ("jabber_muc",
|
||||
weechat_hook_completion ("jabber_muc", "",
|
||||
&jabber_completion_muc_cb, NULL);
|
||||
weechat_hook_completion ("buddy",
|
||||
weechat_hook_completion ("buddy", "",
|
||||
&jabber_completion_muc_buddies_cb, NULL);
|
||||
weechat_hook_completion ("jabber_muc_buddies_hosts",
|
||||
weechat_hook_completion ("jabber_muc_buddies_hosts", "",
|
||||
&jabber_completion_muc_buddies_hosts_cb, NULL);
|
||||
weechat_hook_completion ("jabber_muc_topic",
|
||||
weechat_hook_completion ("jabber_muc_topic", "",
|
||||
&jabber_completion_muc_topic_cb, NULL);
|
||||
weechat_hook_completion ("jabber_mucs",
|
||||
weechat_hook_completion ("jabber_mucs", "",
|
||||
&jabber_completion_mucs_cb, NULL);
|
||||
weechat_hook_completion ("jabber_msg_part",
|
||||
weechat_hook_completion ("jabber_msg_part", "",
|
||||
&jabber_completion_msg_part_cb, NULL);
|
||||
}
|
||||
|
||||
@@ -1003,7 +1003,9 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
" 3: server message\n"
|
||||
" 4: join/part/quit\n"
|
||||
" 9: all other messages"),
|
||||
"list|set|disable",
|
||||
"list"
|
||||
" || set 1|2|3|4|5|6|7|8|9"
|
||||
" || disable",
|
||||
&logger_command_cb, NULL);
|
||||
|
||||
logger_start_buffer_all ();
|
||||
|
||||
@@ -3930,7 +3930,7 @@ weechat_lua_api_hook_completion_cb (void *data, const char *completion_item,
|
||||
static int
|
||||
weechat_lua_api_hook_completion (lua_State *L)
|
||||
{
|
||||
const char *completion, *function;
|
||||
const char *completion, *description, *function;
|
||||
char *result;
|
||||
int n;
|
||||
|
||||
@@ -3944,22 +3944,25 @@ weechat_lua_api_hook_completion (lua_State *L)
|
||||
}
|
||||
|
||||
completion = NULL;
|
||||
description = NULL;
|
||||
function = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
if (n < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
completion = lua_tostring (lua_current_interpreter, -2);
|
||||
completion = lua_tostring (lua_current_interpreter, -3);
|
||||
description = lua_tostring (lua_current_interpreter, -2);
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = script_ptr2str (script_api_hook_completion (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
completion,
|
||||
description,
|
||||
&weechat_lua_api_hook_completion_cb,
|
||||
function));
|
||||
|
||||
|
||||
@@ -3317,7 +3317,7 @@ weechat_perl_api_hook_completion_cb (void *data, const char *completion_item,
|
||||
|
||||
static XS (XS_weechat_api_hook_completion)
|
||||
{
|
||||
char *result, *completion, *function;
|
||||
char *result, *completion, *description, *function;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -3329,17 +3329,19 @@ static XS (XS_weechat_api_hook_completion)
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
completion = SvPV (ST (0), PL_na);
|
||||
function = SvPV (ST (1), PL_na);
|
||||
description = SvPV (ST (1), PL_na);
|
||||
function = SvPV (ST (2), PL_na);
|
||||
result = script_ptr2str (script_api_hook_completion (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
completion,
|
||||
description,
|
||||
&weechat_perl_api_hook_completion_cb,
|
||||
function));
|
||||
|
||||
|
||||
@@ -3527,7 +3527,7 @@ weechat_python_api_hook_completion_cb (void *data, const char *completion_item,
|
||||
static PyObject *
|
||||
weechat_python_api_hook_completion (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *completion, *function, *result;
|
||||
char *completion, *description, *function, *result;
|
||||
PyObject *object;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -3540,9 +3540,10 @@ weechat_python_api_hook_completion (PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
completion = NULL;
|
||||
description = NULL;
|
||||
function = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ss", &completion, &function))
|
||||
if (!PyArg_ParseTuple (args, "sss", &completion, &description, &function))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
@@ -3551,6 +3552,7 @@ weechat_python_api_hook_completion (PyObject *self, PyObject *args)
|
||||
result = script_ptr2str(script_api_hook_completion (weechat_python_plugin,
|
||||
python_current_script,
|
||||
completion,
|
||||
description,
|
||||
&weechat_python_api_hook_completion_cb,
|
||||
function));
|
||||
|
||||
|
||||
@@ -4020,9 +4020,9 @@ weechat_ruby_api_hook_completion_cb (void *data, const char *completion_item,
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hook_completion (VALUE class, VALUE completion,
|
||||
VALUE function)
|
||||
VALUE description, VALUE function)
|
||||
{
|
||||
char *c_completion, *c_function, *result;
|
||||
char *c_completion, *c_description, *c_function, *result;
|
||||
VALUE return_value;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -4035,23 +4035,27 @@ weechat_ruby_api_hook_completion (VALUE class, VALUE completion,
|
||||
}
|
||||
|
||||
c_completion = NULL;
|
||||
c_description = NULL;
|
||||
c_function = NULL;
|
||||
|
||||
if (NIL_P (completion) || NIL_P (function))
|
||||
if (NIL_P (completion) || NIL_P (description) || NIL_P (function))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (completion, T_STRING);
|
||||
Check_Type (description, T_STRING);
|
||||
Check_Type (function, T_STRING);
|
||||
|
||||
c_completion = STR2CSTR (completion);
|
||||
c_description = STR2CSTR (description);
|
||||
c_function = STR2CSTR (function);
|
||||
|
||||
result = script_ptr2str (script_api_hook_completion (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
c_completion,
|
||||
c_description,
|
||||
&weechat_ruby_api_hook_completion_cb,
|
||||
c_function));
|
||||
|
||||
@@ -6657,7 +6661,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_module_function (ruby_mWeechat, "hook_signal", &weechat_ruby_api_hook_signal, 2);
|
||||
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", &weechat_ruby_api_hook_completion, 3);
|
||||
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);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
#include "script.h"
|
||||
#include "script-api.h"
|
||||
#include "script-callback.h"
|
||||
|
||||
|
||||
@@ -1076,6 +1077,7 @@ struct t_hook *
|
||||
script_api_hook_completion (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *completion,
|
||||
const char *description,
|
||||
int (*callback)(void *data,
|
||||
const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
@@ -1089,7 +1091,8 @@ script_api_hook_completion (struct t_weechat_plugin *weechat_plugin,
|
||||
if (!new_script_callback)
|
||||
return NULL;
|
||||
|
||||
new_hook = weechat_hook_completion (completion, callback, new_script_callback);
|
||||
new_hook = weechat_hook_completion (completion, description,
|
||||
callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
script_callback_free_data (new_script_callback);
|
||||
|
||||
@@ -196,6 +196,7 @@ extern struct t_hook *script_api_hook_config (struct t_weechat_plugin *weechat_p
|
||||
extern struct t_hook *script_api_hook_completion (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *completion,
|
||||
const char *description,
|
||||
int (*callback)(void *data,
|
||||
const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
|
||||
@@ -105,7 +105,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
void *signal_data),
|
||||
void (*callback_load_file)(void *data, const char *filename))
|
||||
{
|
||||
char *string, *completion = "list|listfull|load|autoload|reload|unload %f";
|
||||
char *string, *completion = "list|listfull|load|autoload|reload|unload %(filename)";
|
||||
char infolist_description[512], signal_name[128];
|
||||
int length;
|
||||
|
||||
@@ -162,7 +162,8 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
if (string)
|
||||
{
|
||||
snprintf (string, length, "%s_script", weechat_plugin->name);
|
||||
weechat_hook_completion (string, callback_completion, NULL);
|
||||
weechat_hook_completion (string, N_("list of scripts"),
|
||||
callback_completion, NULL);
|
||||
snprintf (infolist_description, sizeof (infolist_description),
|
||||
/* TRANSLATORS: %s is language (for example "perl") */
|
||||
_("list of %s scripts"), weechat_plugin->name);
|
||||
|
||||
@@ -3765,7 +3765,7 @@ weechat_tcl_api_hook_completion (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *result, *completion, *function;
|
||||
char *result, *completion, *description, *function;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -3777,17 +3777,19 @@ weechat_tcl_api_hook_completion (ClientData clientData, Tcl_Interp *interp,
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 3)
|
||||
if (objc < 4)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
completion = Tcl_GetStringFromObj (objv[1], &i);
|
||||
function = Tcl_GetStringFromObj (objv[2], &i);
|
||||
description = Tcl_GetStringFromObj (objv[2], &i);
|
||||
function = Tcl_GetStringFromObj (objv[3], &i);
|
||||
result = script_ptr2str (script_api_hook_completion (weechat_tcl_plugin,
|
||||
tcl_current_script,
|
||||
completion,
|
||||
description,
|
||||
&weechat_tcl_api_hook_completion_cb,
|
||||
function));
|
||||
|
||||
|
||||
@@ -429,6 +429,7 @@ struct t_weechat_plugin
|
||||
void *callback_data);
|
||||
struct t_hook *(*hook_completion) (struct t_weechat_plugin *plugin,
|
||||
const char *completion_item,
|
||||
const char *description,
|
||||
int (*callback)(void *data,
|
||||
const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
@@ -972,9 +973,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
#define weechat_hook_config(__option, __callback, __data) \
|
||||
weechat_plugin->hook_config(weechat_plugin, __option, __callback, \
|
||||
__data)
|
||||
#define weechat_hook_completion(__completion, __callback, __data) \
|
||||
#define weechat_hook_completion(__completion, __description, \
|
||||
__callback, __data) \
|
||||
weechat_plugin->hook_completion(weechat_plugin, __completion, \
|
||||
__callback, __data)
|
||||
__description, __callback, __data)
|
||||
#define weechat_hook_completion_list_add(__completion, __word, \
|
||||
__nick_completion, __where) \
|
||||
weechat_plugin->hook_completion_list_add(__completion, __word, \
|
||||
|
||||
@@ -69,5 +69,6 @@ void
|
||||
xfer_completion_init ()
|
||||
{
|
||||
weechat_hook_completion ("nick",
|
||||
N_("nicks of DCC chat"),
|
||||
&xfer_completion_nick_cb, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user