mirror of
https://github.com/weechat/weechat.git
synced 2026-07-07 18:23:13 +02:00
Add support of many templates for completion of command arguments, rename default completion items
This commit is contained in:
+123
-86
@@ -1753,6 +1753,69 @@ command_key (void *data, struct t_gui_buffer *buffer,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* bind a key (or display binding) */
|
||||
if (string_strcasecmp (argv[1], "bind") == 0)
|
||||
{
|
||||
if (argc == 3)
|
||||
{
|
||||
ptr_key = NULL;
|
||||
internal_code = gui_keyboard_get_internal_code (argv[2]);
|
||||
if (internal_code)
|
||||
ptr_key = gui_keyboard_search (NULL, internal_code);
|
||||
if (ptr_key)
|
||||
{
|
||||
gui_chat_printf (NULL, "");
|
||||
gui_chat_printf (NULL, _("Key:"));
|
||||
command_key_display (ptr_key);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("No key found"));
|
||||
}
|
||||
if (internal_code)
|
||||
free (internal_code);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* bind new key */
|
||||
gui_keyboard_verbose = 1;
|
||||
ptr_key = gui_keyboard_bind (NULL, argv[2], argv_eol[3]);
|
||||
gui_keyboard_verbose = 0;
|
||||
if (!ptr_key)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("%sError: unable to bind key \"%s\""),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
argv[2]);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* unbind a key */
|
||||
if (string_strcasecmp (argv[1], "unbind") == 0)
|
||||
{
|
||||
if (argc >= 3)
|
||||
{
|
||||
if (gui_keyboard_unbind (NULL, argv[2]))
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("Key \"%s\" unbound"),
|
||||
argv[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("%sError: unable to unbind key \"%s\""),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
argv[2]);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* reset keys (only with "-yes", for security reason) */
|
||||
if (string_strcasecmp (argv[1], "reset") == 0)
|
||||
{
|
||||
@@ -1789,65 +1852,6 @@ command_key (void *data, struct t_gui_buffer *buffer,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* unbind a key */
|
||||
if (string_strcasecmp (argv[1], "unbind") == 0)
|
||||
{
|
||||
if (argc >= 3)
|
||||
{
|
||||
if (gui_keyboard_unbind (NULL, argv[2]))
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("Key \"%s\" unbound"),
|
||||
argv[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("%sError: unable to unbind key \"%s\""),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
argv[2]);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* display a key */
|
||||
if (argc == 2)
|
||||
{
|
||||
ptr_key = NULL;
|
||||
internal_code = gui_keyboard_get_internal_code (argv[1]);
|
||||
if (internal_code)
|
||||
ptr_key = gui_keyboard_search (NULL, internal_code);
|
||||
if (ptr_key)
|
||||
{
|
||||
gui_chat_printf (NULL, "");
|
||||
gui_chat_printf (NULL, _("Key:"));
|
||||
command_key_display (ptr_key);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("No key found"));
|
||||
}
|
||||
if (internal_code)
|
||||
free (internal_code);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* bind new key */
|
||||
gui_keyboard_verbose = 1;
|
||||
ptr_key = gui_keyboard_bind (NULL, argv[1], argv_eol[2]);
|
||||
gui_keyboard_verbose = 0;
|
||||
if (!ptr_key)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("%sError: unable to bind key \"%s\""),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
argv[1]);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -3658,10 +3662,17 @@ command_init ()
|
||||
" /bar scroll nicklist #weechat y-100%\n"
|
||||
" scroll to end of nicklist on current buffer:\n"
|
||||
" /bar scroll nicklist * ye"),
|
||||
"add|default|del|set|hide|show|toggle|scroll|list|listfull|"
|
||||
"listitems %r name|hidden|priority|conditions|position|"
|
||||
"filling_top_bottom|filling_left_right|size|size_max|"
|
||||
"color_fg|color_delim|color_bg|separator|items",
|
||||
"add %(bars_names) root|window bottom|top|left|right"
|
||||
" || default"
|
||||
" || del %(bars_names)|-all"
|
||||
" || set %(bars_names) %(bars_options)"
|
||||
" || hide %(bars_names)"
|
||||
" || show %(bars_names)"
|
||||
" || toggle %(bars_names)"
|
||||
" || scroll %(bars_names) %(buffers_plugins_names)|*"
|
||||
" || list"
|
||||
" || listfull"
|
||||
" || listitems",
|
||||
&command_bar, NULL);
|
||||
hook_command (NULL, "buffer",
|
||||
N_("manage buffers"),
|
||||
@@ -3686,7 +3697,15 @@ command_init ()
|
||||
" close buffer: /buffer close\n"
|
||||
" jump to #weechat: /buffer #weechat\n"
|
||||
" jump to next buffer: /buffer +1"),
|
||||
"clear|move|close|list|notify|localvar|set|%b %b",
|
||||
"clear -all|%(buffers_numbers)"
|
||||
" || move %(buffers_numbers)"
|
||||
" || close"
|
||||
" || list"
|
||||
" || notify"
|
||||
" || localvar"
|
||||
" || set"
|
||||
" || %(buffers_names)"
|
||||
" || %(buffers_numbers)",
|
||||
&command_buffer, NULL);
|
||||
hook_command (NULL, "command",
|
||||
N_("launch explicit WeeChat or plugin command"),
|
||||
@@ -3695,7 +3714,7 @@ command_init ()
|
||||
"command)\n"
|
||||
"command: command to execute (a '/' is automatically "
|
||||
"added if not found at beginning of command)"),
|
||||
"%p|" PLUGIN_CORE " %P",
|
||||
"%(plugins_names)|" PLUGIN_CORE " %(plugins_commands)",
|
||||
&command_command, NULL);
|
||||
hook_command (NULL, "debug",
|
||||
N_("control debug for core/plugins"),
|
||||
@@ -3709,7 +3728,7 @@ command_init ()
|
||||
"windows: display windows tree\n"
|
||||
" text: send \"debug\" signal with \"text\" as "
|
||||
"argument"),
|
||||
"%p|core|list|dump|buffer|windows",
|
||||
"%(plugins_names)|core|list|dump|buffer|windows",
|
||||
&command_debug, NULL);
|
||||
hook_command (NULL, "filter",
|
||||
N_("filter messages in buffers, to hide/show them according "
|
||||
@@ -3745,14 +3764,19 @@ command_init ()
|
||||
" filter lines containing \"weechat sucks\" on IRC "
|
||||
"channel #weechat:\n"
|
||||
" /filter add sucks irc.freenode.#weechat * weechat sucks"),
|
||||
"list|enable|disable|toggle|add|rename|del %F %B",
|
||||
"list"
|
||||
" || enable %(filters_names)"
|
||||
" || disable %(filters_names)"
|
||||
" || toggle %(filters_names)"
|
||||
" || add %(filters_names) %(buffers_plugins_names)|*"
|
||||
" || del %(filters_names)|-all",
|
||||
&command_filter, NULL);
|
||||
hook_command (NULL, "help",
|
||||
N_("display help about commands and options"),
|
||||
N_("[command | option]"),
|
||||
N_("command: a command name\n"
|
||||
" option: an option name (use /set to see list)"),
|
||||
"%h|%o",
|
||||
"%(commands)|%(config_options)",
|
||||
&command_help, NULL);
|
||||
hook_command (NULL, "history",
|
||||
N_("show buffer command history"),
|
||||
@@ -3791,14 +3815,18 @@ command_init ()
|
||||
&command_input, NULL);
|
||||
hook_command (NULL, "key",
|
||||
N_("bind/unbind keys"),
|
||||
N_("[key [command [args]]] | [unbind key] | [reset -yes] | "
|
||||
"[missing]"),
|
||||
N_(" key: display or bind this key to a command\n"
|
||||
" unbind: unbind a key\n"
|
||||
" reset: restore bindings to the default values and "
|
||||
N_("[bind key [command [args]]] | [unbind key] | "
|
||||
"[reset -yes] | [missing]"),
|
||||
N_(" bind: bind a command to a key or display command "
|
||||
"bound to key\n"
|
||||
" unbind: remove a key binding\n"
|
||||
" reset: restore bindings to the default values and "
|
||||
"delete ALL personal bindings (use carefully!)\n"
|
||||
" missing: add missing keys (using default bindings)"),
|
||||
"unbind|reset|missing",
|
||||
"missing: add missing keys (using default bindings)"),
|
||||
"bind %(keys_codes) %(commands)"
|
||||
" || unbind %(key_codes)"
|
||||
" || reset"
|
||||
" || missing",
|
||||
&command_key, NULL);
|
||||
hook_command (NULL, "layout",
|
||||
N_("save/apply/reset layout for buffers and windows"),
|
||||
@@ -3824,7 +3852,12 @@ command_init ()
|
||||
"all plugins, then autoload plugins)\n"
|
||||
" unload: unload one or all plugins\n\n"
|
||||
"Without argument, this command lists loaded plugins."),
|
||||
"list|listfull|load|autoload|reload|unload %f|%p",
|
||||
"list %(plugins_names)"
|
||||
" || listfull %(plugins_names)"
|
||||
" || load %(filename)"
|
||||
" || autoload"
|
||||
" || reload %(plugins_names)"
|
||||
" || unload %(plugins_names)",
|
||||
&command_plugin, NULL);
|
||||
hook_command (NULL, "proxy",
|
||||
N_("manage proxies"),
|
||||
@@ -3854,7 +3887,10 @@ command_init ()
|
||||
" /proxy add myproxy socks5 sample.host.org 3128 myuser mypass\n"
|
||||
" delete a proxy:\n"
|
||||
" /proxy del myproxy"),
|
||||
"add|del|set|list %y name|type|ipv6|address|port|username|password",
|
||||
"add %(proxies_names) http|socks4|socks5"
|
||||
" || del %(proxies_names)"
|
||||
" || set %(proxies_names) %(proxies_options)"
|
||||
" || list ",
|
||||
&command_proxy, NULL);
|
||||
hook_command (NULL, "quit",
|
||||
N_("quit WeeChat"),
|
||||
@@ -3867,7 +3903,7 @@ command_init ()
|
||||
N_("file: configuration file to reload\n\n"
|
||||
"Without argument, all files (WeeChat and plugins) are "
|
||||
"reloaded."),
|
||||
"%c|%*",
|
||||
"%(config_files)|%*",
|
||||
&command_reload, NULL);
|
||||
hook_command (NULL, "save",
|
||||
N_("save configuration files to disk"),
|
||||
@@ -3875,7 +3911,7 @@ command_init ()
|
||||
N_("file: configuration file to save\n\n"
|
||||
"Without argument, all files (WeeChat and plugins) are "
|
||||
"saved."),
|
||||
"%c|%*",
|
||||
"%(config_files)|%*",
|
||||
&command_save, NULL);
|
||||
hook_command (NULL, "set",
|
||||
N_("set config options"),
|
||||
@@ -3890,7 +3926,7 @@ command_init ()
|
||||
"For all types, you can use null to remove "
|
||||
"option value (undefined value). This works only "
|
||||
"for some special plugin variables."),
|
||||
"%o %v",
|
||||
"%(config_options) %(config_option_values)",
|
||||
&command_set, NULL);
|
||||
hook_command (NULL, "unset",
|
||||
N_("unset/reset config options"),
|
||||
@@ -3899,7 +3935,7 @@ command_init ()
|
||||
"to mass-reset options, use carefully!)\n\n"
|
||||
"According to option, it's reset (for standard options) "
|
||||
"or removed (for optional settings, like server values)."),
|
||||
"%o",
|
||||
"%(config_options)",
|
||||
&command_unset, NULL);
|
||||
hook_command (NULL, "upgrade",
|
||||
N_("upgrade WeeChat without disconnecting from servers"),
|
||||
@@ -3909,7 +3945,7 @@ command_init ()
|
||||
"This command run again a WeeChat binary, so it should "
|
||||
"have been compiled or installed with a package manager "
|
||||
"before running this command."),
|
||||
"%f",
|
||||
"%(filename)",
|
||||
&command_upgrade, NULL);
|
||||
hook_command (NULL, "uptime",
|
||||
N_("show WeeChat uptime"),
|
||||
@@ -3967,10 +4003,11 @@ command_init ()
|
||||
" scroll 2 lines up: /window scroll -2\n"
|
||||
" scroll 2 days up: /window scroll -2d\n"
|
||||
" scroll to beginning of current day: /window scroll -d"),
|
||||
"list|-1|+1|up|down|left|right|splith|splitv|resize|merge|"
|
||||
"page_up|page_down|refresh|scroll_up|scroll|scroll_down|"
|
||||
"scroll_top|scroll_bottom|scroll_previous_highlight|"
|
||||
"scroll_next_highlight|zoom all",
|
||||
"list|-1|+1|up|down|left|right|splith|splitv|resize|page_up|"
|
||||
"page_down|refresh|scroll_up|scroll|scroll_down|scroll_top|"
|
||||
"scroll_bottom|scroll_previous_highlight|"
|
||||
"scroll_next_highlight|zoom"
|
||||
" || merge all",
|
||||
&command_window, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -1606,7 +1606,7 @@ config_weechat_init_options ()
|
||||
"default_template", "string",
|
||||
N_("default completion template (please see documentation for template "
|
||||
"codes and values)"),
|
||||
NULL, 0, 0, "%n|%(irc_channels)", NULL, 0,
|
||||
NULL, 0, 0, "%(nicks)|%(irc_channels)", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
config_completion_nick_add_space = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
|
||||
+289
-69
@@ -35,9 +35,11 @@
|
||||
#include "weechat.h"
|
||||
#include "wee-hook.h"
|
||||
#include "wee-infolist.h"
|
||||
#include "wee-list.h"
|
||||
#include "wee-log.h"
|
||||
#include "wee-network.h"
|
||||
#include "wee-string.h"
|
||||
#include "wee-utf8.h"
|
||||
#include "wee-util.h"
|
||||
#include "../gui/gui-buffer.h"
|
||||
#include "../gui/gui-chat.h"
|
||||
@@ -321,6 +323,164 @@ hook_search_command (struct t_weechat_plugin *plugin, const char *command)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* hook_command_build_completion: build variables/arrays that will be used for
|
||||
* completion of commands arguments
|
||||
*/
|
||||
|
||||
void
|
||||
hook_command_build_completion (struct t_hook_command *hook_command)
|
||||
{
|
||||
int i, j, k, length, num_items;
|
||||
struct t_weelist *list;
|
||||
char *pos_completion, *pos_double_pipe, *pos_start, *pos_end;
|
||||
char **items, *last_space, *ptr_template;
|
||||
|
||||
/* split templates using "||" as separator */
|
||||
hook_command->cplt_num_templates = 1;
|
||||
pos_completion = hook_command->completion;
|
||||
while ((pos_double_pipe = strstr (pos_completion, "||")) != NULL)
|
||||
{
|
||||
hook_command->cplt_num_templates++;
|
||||
pos_completion = pos_double_pipe + 2;
|
||||
}
|
||||
hook_command->cplt_templates = malloc (hook_command->cplt_num_templates *
|
||||
sizeof (*hook_command->cplt_templates));
|
||||
for (i = 0; i < hook_command->cplt_num_templates; i++)
|
||||
{
|
||||
hook_command->cplt_templates[i] = NULL;
|
||||
}
|
||||
pos_completion = hook_command->completion;
|
||||
i = 0;
|
||||
while (pos_completion)
|
||||
{
|
||||
pos_double_pipe = strstr (pos_completion, "||");
|
||||
if (!pos_double_pipe)
|
||||
pos_double_pipe = pos_completion + strlen (pos_completion);
|
||||
pos_start = pos_completion;
|
||||
pos_end = pos_double_pipe - 1;
|
||||
if (pos_end < pos_start)
|
||||
{
|
||||
hook_command->cplt_templates[i] = strdup ("");
|
||||
}
|
||||
else
|
||||
{
|
||||
while (pos_start[0] == ' ')
|
||||
{
|
||||
pos_start++;
|
||||
}
|
||||
pos_end = pos_double_pipe - 1;
|
||||
while ((pos_end > pos_start) && (pos_end[0] == ' '))
|
||||
{
|
||||
pos_end--;
|
||||
}
|
||||
hook_command->cplt_templates[i] = string_strndup (pos_start,
|
||||
pos_end - pos_start + 1);
|
||||
}
|
||||
i++;
|
||||
if (!pos_double_pipe[0])
|
||||
pos_completion = NULL;
|
||||
else
|
||||
pos_completion = pos_double_pipe + 2;
|
||||
}
|
||||
|
||||
/* for each template, split/count args */
|
||||
hook_command->cplt_templates_static = malloc (hook_command->cplt_num_templates *
|
||||
sizeof (*hook_command->cplt_templates_static));
|
||||
hook_command->cplt_template_num_args = malloc (hook_command->cplt_num_templates *
|
||||
sizeof (*hook_command->cplt_template_num_args));
|
||||
hook_command->cplt_template_args = malloc (hook_command->cplt_num_templates *
|
||||
sizeof (*hook_command->cplt_template_args));
|
||||
hook_command->cplt_template_num_args_concat = 0;
|
||||
for (i = 0; i < hook_command->cplt_num_templates; i++)
|
||||
{
|
||||
/* build static part of template: it's first argument(s) which does not
|
||||
contain "%" or "|" */
|
||||
last_space = NULL;
|
||||
ptr_template = hook_command->cplt_templates[i];
|
||||
while (ptr_template && ptr_template[0])
|
||||
{
|
||||
if (ptr_template[0] == ' ')
|
||||
last_space = ptr_template;
|
||||
else if ((ptr_template[0] == '%') || (ptr_template[0] == '|'))
|
||||
break;
|
||||
ptr_template = utf8_next_char (ptr_template);
|
||||
}
|
||||
if (last_space)
|
||||
{
|
||||
last_space--;
|
||||
while (last_space > hook_command->cplt_templates[i])
|
||||
{
|
||||
if (last_space[0] != ' ')
|
||||
break;
|
||||
}
|
||||
if (last_space < hook_command->cplt_templates[i])
|
||||
last_space = NULL;
|
||||
else
|
||||
last_space++;
|
||||
}
|
||||
if (last_space)
|
||||
hook_command->cplt_templates_static[i] = string_strndup (hook_command->cplt_templates[i],
|
||||
last_space - hook_command->cplt_templates[i]);
|
||||
else
|
||||
hook_command->cplt_templates_static[i] = strdup (hook_command->cplt_templates[i]);
|
||||
|
||||
/* build arguments for each template */
|
||||
hook_command->cplt_template_args[i] = string_explode (hook_command->cplt_templates[i],
|
||||
" ", 0, 0,
|
||||
&(hook_command->cplt_template_num_args[i]));
|
||||
if (hook_command->cplt_template_num_args[i] > hook_command->cplt_template_num_args_concat)
|
||||
hook_command->cplt_template_num_args_concat = hook_command->cplt_template_num_args[i];
|
||||
}
|
||||
|
||||
/* build strings with concatentaion of items from different templates
|
||||
for each argument: these strings will be used when completing argument
|
||||
if we can't find which template to use (for example for first argument)
|
||||
*/
|
||||
hook_command->cplt_template_args_concat = malloc (hook_command->cplt_template_num_args_concat *
|
||||
sizeof (*hook_command->cplt_template_args_concat));
|
||||
list = weelist_new ();
|
||||
for (i = 0; i < hook_command->cplt_template_num_args_concat; i++)
|
||||
{
|
||||
/* first compute length */
|
||||
length = 1;
|
||||
for (j = 0; j < hook_command->cplt_num_templates; j++)
|
||||
{
|
||||
if (i < hook_command->cplt_template_num_args[j])
|
||||
length += strlen (hook_command->cplt_template_args[j][i]) + 1;
|
||||
}
|
||||
/* alloc memory */
|
||||
hook_command->cplt_template_args_concat[i] = malloc (length);
|
||||
if (hook_command->cplt_template_args_concat[i])
|
||||
{
|
||||
/* concatene items with "|" as separator */
|
||||
weelist_remove_all (list);
|
||||
hook_command->cplt_template_args_concat[i][0] = '\0';
|
||||
for (j = 0; j < hook_command->cplt_num_templates; j++)
|
||||
{
|
||||
if (i < hook_command->cplt_template_num_args[j])
|
||||
{
|
||||
items = string_explode (hook_command->cplt_template_args[j][i],
|
||||
"|", 0, 0, &num_items);
|
||||
for (k = 0; k < num_items; k++)
|
||||
{
|
||||
if (!weelist_search (list, items[k]))
|
||||
{
|
||||
if (hook_command->cplt_template_args_concat[i][0])
|
||||
strcat (hook_command->cplt_template_args_concat[i], "|");
|
||||
strcat (hook_command->cplt_template_args_concat[i],
|
||||
items[k]);
|
||||
weelist_add (list, items[k], WEECHAT_LIST_POS_END,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
string_free_exploded (items);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* hook_command: hook a command
|
||||
*/
|
||||
@@ -374,6 +534,16 @@ hook_command (struct t_weechat_plugin *plugin, const char *command,
|
||||
new_hook_command->completion = (completion) ?
|
||||
strdup (completion) : strdup ("");
|
||||
|
||||
/* build completion variables for command */
|
||||
new_hook_command->cplt_num_templates = 0;
|
||||
new_hook_command->cplt_templates = NULL;
|
||||
new_hook_command->cplt_templates_static = NULL;
|
||||
new_hook_command->cplt_template_num_args = NULL;
|
||||
new_hook_command->cplt_template_args = NULL;
|
||||
new_hook_command->cplt_template_num_args_concat = 0;
|
||||
new_hook_command->cplt_template_args_concat = NULL;
|
||||
hook_command_build_completion (new_hook_command);
|
||||
|
||||
hook_add_to_list (new_hook);
|
||||
|
||||
return new_hook;
|
||||
@@ -1593,6 +1763,7 @@ hook_config_exec (const char *option, const char *value)
|
||||
|
||||
struct t_hook *
|
||||
hook_completion (struct t_weechat_plugin *plugin, const char *completion_item,
|
||||
const char *description,
|
||||
t_hook_callback_completion *callback, void *callback_data)
|
||||
{
|
||||
struct t_hook *new_hook;
|
||||
@@ -1617,6 +1788,8 @@ hook_completion (struct t_weechat_plugin *plugin, const char *completion_item,
|
||||
new_hook->hook_data = new_hook_completion;
|
||||
new_hook_completion->callback = callback;
|
||||
new_hook_completion->completion_item = strdup (completion_item);
|
||||
new_hook_completion->description =
|
||||
(description) ? strdup (description) : strdup ("");
|
||||
|
||||
hook_add_to_list (new_hook);
|
||||
|
||||
@@ -1950,6 +2123,8 @@ hook_infolist_get (struct t_weechat_plugin *plugin, const char *infolist_name,
|
||||
void
|
||||
unhook (struct t_hook *hook)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* invalid hook? */
|
||||
if (!hook_valid (hook))
|
||||
return;
|
||||
@@ -1982,6 +2157,20 @@ unhook (struct t_hook *hook)
|
||||
free (HOOK_COMMAND(hook, args_description));
|
||||
if (HOOK_COMMAND(hook, completion))
|
||||
free (HOOK_COMMAND(hook, completion));
|
||||
if (HOOK_COMMAND(hook, cplt_templates))
|
||||
{
|
||||
for (i = 0; i < HOOK_COMMAND(hook, cplt_num_templates); i++)
|
||||
{
|
||||
if (HOOK_COMMAND(hook, cplt_templates)[i])
|
||||
free (HOOK_COMMAND(hook, cplt_templates)[i]);
|
||||
if (HOOK_COMMAND(hook, cplt_templates_static)[i])
|
||||
free (HOOK_COMMAND(hook, cplt_templates_static)[i]);
|
||||
string_free_exploded (HOOK_COMMAND(hook, cplt_template_args)[i]);
|
||||
}
|
||||
free (HOOK_COMMAND(hook, cplt_templates));
|
||||
}
|
||||
if (HOOK_COMMAND(hook, cplt_template_num_args))
|
||||
free (HOOK_COMMAND(hook, cplt_template_num_args));
|
||||
break;
|
||||
case HOOK_TYPE_COMMAND_RUN:
|
||||
if (HOOK_COMMAND_RUN(hook, command))
|
||||
@@ -2048,6 +2237,8 @@ unhook (struct t_hook *hook)
|
||||
case HOOK_TYPE_COMPLETION:
|
||||
if (HOOK_COMPLETION(hook, completion_item))
|
||||
free (HOOK_COMPLETION(hook, completion_item));
|
||||
if (HOOK_COMPLETION(hook, description))
|
||||
free (HOOK_COMPLETION(hook, description));
|
||||
break;
|
||||
case HOOK_TYPE_MODIFIER:
|
||||
if (HOOK_MODIFIER(hook, modifier))
|
||||
@@ -2343,6 +2534,13 @@ hook_add_to_infolist_type (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "completion_item", HOOK_COMPLETION(ptr_hook, completion_item)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description", HOOK_COMPLETION(ptr_hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_COMPLETION(ptr_hook, description)
|
||||
&& HOOK_COMPLETION(ptr_hook, description)[0]) ?
|
||||
_(HOOK_COMPLETION(ptr_hook, description)) : ""))
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_MODIFIER:
|
||||
@@ -2429,7 +2627,7 @@ hook_add_to_infolist (struct t_infolist *infolist,
|
||||
void
|
||||
hook_print_log ()
|
||||
{
|
||||
int type;
|
||||
int type, i, j;
|
||||
struct t_hook *ptr_hook;
|
||||
struct tm *local_time;
|
||||
char text_time[1024];
|
||||
@@ -2441,164 +2639,186 @@ hook_print_log ()
|
||||
{
|
||||
log_printf ("");
|
||||
log_printf ("[hook (addr:0x%lx)]", ptr_hook);
|
||||
log_printf (" plugin . . . . . . . . : 0x%lx ('%s')",
|
||||
log_printf (" plugin. . . . . . . . . : 0x%lx ('%s')",
|
||||
ptr_hook->plugin, plugin_get_name (ptr_hook->plugin));
|
||||
log_printf (" deleted. . . . . . . . : %d", ptr_hook->deleted);
|
||||
log_printf (" running. . . . . . . . : %d", ptr_hook->running);
|
||||
log_printf (" type . . . . . . . . . : %d (%s)",
|
||||
log_printf (" deleted . . . . . . . . : %d", ptr_hook->deleted);
|
||||
log_printf (" running . . . . . . . . : %d", ptr_hook->running);
|
||||
log_printf (" type. . . . . . . . . . : %d (%s)",
|
||||
ptr_hook->type, hook_type_string[ptr_hook->type]);
|
||||
log_printf (" callback_data. . . . . : 0x%lx", ptr_hook->callback_data);
|
||||
log_printf (" callback_data . . . . . : 0x%lx", ptr_hook->callback_data);
|
||||
switch (ptr_hook->type)
|
||||
{
|
||||
case HOOK_TYPE_COMMAND:
|
||||
if (!ptr_hook->deleted)
|
||||
{
|
||||
log_printf (" command data:");
|
||||
log_printf (" callback . . . . . . : 0x%lx", HOOK_COMMAND(ptr_hook, callback));
|
||||
log_printf (" command. . . . . . . : '%s'", HOOK_COMMAND(ptr_hook, command));
|
||||
log_printf (" description. . . . . : '%s'", HOOK_COMMAND(ptr_hook, description));
|
||||
log_printf (" args . . . . . . . . : '%s'", HOOK_COMMAND(ptr_hook, args));
|
||||
log_printf (" args_description . . : '%s'", HOOK_COMMAND(ptr_hook, args_description));
|
||||
log_printf (" completion . . . . . : '%s'", HOOK_COMMAND(ptr_hook, completion));
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_COMMAND(ptr_hook, callback));
|
||||
log_printf (" command . . . . . . . : '%s'", HOOK_COMMAND(ptr_hook, command));
|
||||
log_printf (" description . . . . . : '%s'", HOOK_COMMAND(ptr_hook, description));
|
||||
log_printf (" args. . . . . . . . . : '%s'", HOOK_COMMAND(ptr_hook, args));
|
||||
log_printf (" args_description. . . : '%s'", HOOK_COMMAND(ptr_hook, args_description));
|
||||
log_printf (" completion. . . . . . : '%s'", HOOK_COMMAND(ptr_hook, completion));
|
||||
log_printf (" cplt_num_templates. . : %d", HOOK_COMMAND(ptr_hook, cplt_num_templates));
|
||||
for (i = 0; i < HOOK_COMMAND(ptr_hook, cplt_num_templates); i++)
|
||||
{
|
||||
log_printf (" cplt_templates[%04d] . . . : '%s'",
|
||||
i, HOOK_COMMAND(ptr_hook, cplt_templates)[i]);
|
||||
log_printf (" cplt_templates_static[%04d]: '%s'",
|
||||
i, HOOK_COMMAND(ptr_hook, cplt_templates_static)[i]);
|
||||
log_printf (" num_args. . . . . . : %d",
|
||||
HOOK_COMMAND(ptr_hook, cplt_template_num_args)[i]);
|
||||
for (j = 0; j < HOOK_COMMAND(ptr_hook, cplt_template_num_args)[i]; j++)
|
||||
{
|
||||
log_printf (" args[%04d]. . . . . : '%s'",
|
||||
j, HOOK_COMMAND(ptr_hook, cplt_template_args)[i][j]);
|
||||
}
|
||||
}
|
||||
log_printf (" num_args_concat . . . : %d", HOOK_COMMAND(ptr_hook, cplt_template_num_args_concat));
|
||||
for (i = 0; i < HOOK_COMMAND(ptr_hook, cplt_template_num_args_concat); i++)
|
||||
{
|
||||
log_printf (" args_concat[%04d] . . : '%s'",
|
||||
i, HOOK_COMMAND(ptr_hook, cplt_template_args_concat)[i]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_COMMAND_RUN:
|
||||
if (!ptr_hook->deleted)
|
||||
{
|
||||
log_printf (" command_run data:");
|
||||
log_printf (" callback . . . . . . : 0x%lx", HOOK_COMMAND_RUN(ptr_hook, callback));
|
||||
log_printf (" command. . . . . . . : '%s'", HOOK_COMMAND_RUN(ptr_hook, command));
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_COMMAND_RUN(ptr_hook, callback));
|
||||
log_printf (" command . . . . . . . : '%s'", HOOK_COMMAND_RUN(ptr_hook, command));
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_TIMER:
|
||||
if (!ptr_hook->deleted)
|
||||
{
|
||||
log_printf (" timer data:");
|
||||
log_printf (" callback . . . . . . : 0x%lx", HOOK_TIMER(ptr_hook, callback));
|
||||
log_printf (" interval . . . . . . : %ld", HOOK_TIMER(ptr_hook, interval));
|
||||
log_printf (" align_second . . . . : %d", HOOK_TIMER(ptr_hook, align_second));
|
||||
log_printf (" remaining_calls. . . : %d", HOOK_TIMER(ptr_hook, remaining_calls));
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_TIMER(ptr_hook, callback));
|
||||
log_printf (" interval. . . . . . . : %ld", HOOK_TIMER(ptr_hook, interval));
|
||||
log_printf (" align_second. . . . . : %d", HOOK_TIMER(ptr_hook, align_second));
|
||||
log_printf (" remaining_calls . . . : %d", HOOK_TIMER(ptr_hook, remaining_calls));
|
||||
local_time = localtime (&HOOK_TIMER(ptr_hook, last_exec).tv_sec);
|
||||
strftime (text_time, sizeof (text_time),
|
||||
"%d/%m/%Y %H:%M:%S", local_time);
|
||||
log_printf (" last_exec.tv_sec . . : %ld (%s)",
|
||||
log_printf (" last_exec.tv_sec. . . : %ld (%s)",
|
||||
HOOK_TIMER(ptr_hook, last_exec.tv_sec),
|
||||
text_time);
|
||||
log_printf (" last_exec.tv_usec. . : %ld", HOOK_TIMER(ptr_hook, last_exec.tv_usec));
|
||||
log_printf (" last_exec.tv_usec . . : %ld", HOOK_TIMER(ptr_hook, last_exec.tv_usec));
|
||||
local_time = localtime (&HOOK_TIMER(ptr_hook, next_exec).tv_sec);
|
||||
strftime (text_time, sizeof (text_time),
|
||||
"%d/%m/%Y %H:%M:%S", local_time);
|
||||
log_printf (" next_exec.tv_sec . . : %ld (%s)",
|
||||
log_printf (" next_exec.tv_sec. . . : %ld (%s)",
|
||||
HOOK_TIMER(ptr_hook, next_exec.tv_sec),
|
||||
text_time);
|
||||
log_printf (" next_exec.tv_usec. . : %ld", HOOK_TIMER(ptr_hook, next_exec.tv_usec));
|
||||
log_printf (" next_exec.tv_usec . . : %ld", HOOK_TIMER(ptr_hook, next_exec.tv_usec));
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_FD:
|
||||
if (!ptr_hook->deleted)
|
||||
{
|
||||
log_printf (" fd data:");
|
||||
log_printf (" callback . . . . . . : 0x%lx", HOOK_FD(ptr_hook, callback));
|
||||
log_printf (" fd . . . . . . . . . : %d", HOOK_FD(ptr_hook, fd));
|
||||
log_printf (" flags. . . . . . . . : %d", HOOK_FD(ptr_hook, flags));
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_FD(ptr_hook, callback));
|
||||
log_printf (" fd. . . . . . . . . . : %d", HOOK_FD(ptr_hook, fd));
|
||||
log_printf (" flags . . . . . . . . : %d", HOOK_FD(ptr_hook, flags));
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_PROCESS:
|
||||
if (!ptr_hook->deleted)
|
||||
{
|
||||
log_printf (" process data:");
|
||||
log_printf (" callback . . . . . . : 0x%lx", HOOK_PROCESS(ptr_hook, callback));
|
||||
log_printf (" command. . . . . . . : '%s'", HOOK_PROCESS(ptr_hook, command));
|
||||
log_printf (" timeout. . . . . . . : %d", HOOK_PROCESS(ptr_hook, timeout));
|
||||
log_printf (" child_stdout_read. . : %d", HOOK_PROCESS(ptr_hook, child_stdout_read));
|
||||
log_printf (" child_stdout_write . : %d", HOOK_PROCESS(ptr_hook, child_stdout_write));
|
||||
log_printf (" child_stderr_read. . : %d", HOOK_PROCESS(ptr_hook, child_stderr_read));
|
||||
log_printf (" child_stderr_write . : %d", HOOK_PROCESS(ptr_hook, child_stderr_write));
|
||||
log_printf (" child_pid. . . . . . : %d", HOOK_PROCESS(ptr_hook, child_pid));
|
||||
log_printf (" hook_fd_stdout . . . : 0x%lx", HOOK_PROCESS(ptr_hook, hook_fd_stdout));
|
||||
log_printf (" hook_fd_stderr . . . : 0x%lx", HOOK_PROCESS(ptr_hook, hook_fd_stderr));
|
||||
log_printf (" hook_timer . . . . . : 0x%lx", HOOK_PROCESS(ptr_hook, hook_timer));
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_PROCESS(ptr_hook, callback));
|
||||
log_printf (" command . . . . . . . : '%s'", HOOK_PROCESS(ptr_hook, command));
|
||||
log_printf (" timeout . . . . . . . : %d", HOOK_PROCESS(ptr_hook, timeout));
|
||||
log_printf (" child_stdout_read . . : %d", HOOK_PROCESS(ptr_hook, child_stdout_read));
|
||||
log_printf (" child_stdout_write. . : %d", HOOK_PROCESS(ptr_hook, child_stdout_write));
|
||||
log_printf (" child_stderr_read . . : %d", HOOK_PROCESS(ptr_hook, child_stderr_read));
|
||||
log_printf (" child_stderr_write. . : %d", HOOK_PROCESS(ptr_hook, child_stderr_write));
|
||||
log_printf (" child_pid . . . . . . : %d", HOOK_PROCESS(ptr_hook, child_pid));
|
||||
log_printf (" hook_fd_stdout. . . . : 0x%lx", HOOK_PROCESS(ptr_hook, hook_fd_stdout));
|
||||
log_printf (" hook_fd_stderr. . . . : 0x%lx", HOOK_PROCESS(ptr_hook, hook_fd_stderr));
|
||||
log_printf (" hook_timer. . . . . . : 0x%lx", HOOK_PROCESS(ptr_hook, hook_timer));
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_CONNECT:
|
||||
if (!ptr_hook->deleted)
|
||||
{
|
||||
log_printf (" connect data:");
|
||||
log_printf (" callback . . . . . . : 0x%lx", HOOK_CONNECT(ptr_hook, callback));
|
||||
log_printf (" address. . . . . . . : '%s'", HOOK_CONNECT(ptr_hook, address));
|
||||
log_printf (" port . . . . . . . . : %d", HOOK_CONNECT(ptr_hook, port));
|
||||
log_printf (" sock . . . . . . . . : %d", HOOK_CONNECT(ptr_hook, sock));
|
||||
log_printf (" ipv6 . . . . . . . . : %d", HOOK_CONNECT(ptr_hook, ipv6));
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_CONNECT(ptr_hook, callback));
|
||||
log_printf (" address . . . . . . . : '%s'", HOOK_CONNECT(ptr_hook, address));
|
||||
log_printf (" port. . . . . . . . . : %d", HOOK_CONNECT(ptr_hook, port));
|
||||
log_printf (" sock. . . . . . . . . : %d", HOOK_CONNECT(ptr_hook, sock));
|
||||
log_printf (" ipv6. . . . . . . . . : %d", HOOK_CONNECT(ptr_hook, ipv6));
|
||||
#ifdef HAVE_GNUTLS
|
||||
log_printf (" gnutls_sess. . . . . : 0x%lx", HOOK_CONNECT(ptr_hook, gnutls_sess));
|
||||
log_printf (" gnutls_sess . . . . . : 0x%lx", HOOK_CONNECT(ptr_hook, gnutls_sess));
|
||||
#endif
|
||||
log_printf (" local_hostname . . . : '%s'", HOOK_CONNECT(ptr_hook, local_hostname));
|
||||
log_printf (" child_read . . . . . : %d", HOOK_CONNECT(ptr_hook, child_read));
|
||||
log_printf (" child_write. . . . . : %d", HOOK_CONNECT(ptr_hook, child_write));
|
||||
log_printf (" child_pid. . . . . . : %d", HOOK_CONNECT(ptr_hook, child_pid));
|
||||
log_printf (" hook_fd. . . . . . . : 0x%lx", HOOK_CONNECT(ptr_hook, hook_fd));
|
||||
log_printf (" local_hostname. . . . : '%s'", HOOK_CONNECT(ptr_hook, local_hostname));
|
||||
log_printf (" child_read. . . . . . : %d", HOOK_CONNECT(ptr_hook, child_read));
|
||||
log_printf (" child_write . . . . . : %d", HOOK_CONNECT(ptr_hook, child_write));
|
||||
log_printf (" child_pid . . . . . . : %d", HOOK_CONNECT(ptr_hook, child_pid));
|
||||
log_printf (" hook_fd . . . . . . . : 0x%lx", HOOK_CONNECT(ptr_hook, hook_fd));
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_PRINT:
|
||||
if (!ptr_hook->deleted)
|
||||
{
|
||||
log_printf (" print data:");
|
||||
log_printf (" callback . . . . . . : 0x%lx", HOOK_PRINT(ptr_hook, callback));
|
||||
log_printf (" buffer . . . . . . . : 0x%lx", HOOK_PRINT(ptr_hook, buffer));
|
||||
log_printf (" tags_count . . . . . : %d", HOOK_PRINT(ptr_hook, tags_count));
|
||||
log_printf (" tags_array . . . . . : 0x%lx", HOOK_PRINT(ptr_hook, tags_array));
|
||||
log_printf (" message. . . . . . . : '%s'", HOOK_PRINT(ptr_hook, message));
|
||||
log_printf (" strip_colors . . . . : %d", HOOK_PRINT(ptr_hook, strip_colors));
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_PRINT(ptr_hook, callback));
|
||||
log_printf (" buffer. . . . . . . . : 0x%lx", HOOK_PRINT(ptr_hook, buffer));
|
||||
log_printf (" tags_count. . . . . . : %d", HOOK_PRINT(ptr_hook, tags_count));
|
||||
log_printf (" tags_array. . . . . . : 0x%lx", HOOK_PRINT(ptr_hook, tags_array));
|
||||
log_printf (" message . . . . . . . : '%s'", HOOK_PRINT(ptr_hook, message));
|
||||
log_printf (" strip_colors. . . . . : %d", HOOK_PRINT(ptr_hook, strip_colors));
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_SIGNAL:
|
||||
if (!ptr_hook->deleted)
|
||||
{
|
||||
log_printf (" signal data:");
|
||||
log_printf (" callback . . . . . . : 0x%lx", HOOK_SIGNAL(ptr_hook, callback));
|
||||
log_printf (" signal . . . . . . . : '%s'", HOOK_SIGNAL(ptr_hook, signal));
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_SIGNAL(ptr_hook, callback));
|
||||
log_printf (" signal. . . . . . . . : '%s'", HOOK_SIGNAL(ptr_hook, signal));
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_CONFIG:
|
||||
if (!ptr_hook->deleted)
|
||||
{
|
||||
log_printf (" config data:");
|
||||
log_printf (" callback . . . . . . : 0x%lx", HOOK_CONFIG(ptr_hook, callback));
|
||||
log_printf (" option . . . . . . . : '%s'", HOOK_CONFIG(ptr_hook, option));
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_CONFIG(ptr_hook, callback));
|
||||
log_printf (" option. . . . . . . . : '%s'", HOOK_CONFIG(ptr_hook, option));
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_COMPLETION:
|
||||
if (!ptr_hook->deleted)
|
||||
{
|
||||
log_printf (" completion data:");
|
||||
log_printf (" callback . . . . . . : 0x%lx", HOOK_COMPLETION(ptr_hook, callback));
|
||||
log_printf (" completion_item. . . : '%s'", HOOK_COMPLETION(ptr_hook, completion_item));
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_COMPLETION(ptr_hook, callback));
|
||||
log_printf (" completion_item . . . : '%s'", HOOK_COMPLETION(ptr_hook, completion_item));
|
||||
log_printf (" description . . . . . : '%s'", HOOK_COMPLETION(ptr_hook, description));
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_MODIFIER:
|
||||
if (!ptr_hook->deleted)
|
||||
{
|
||||
log_printf (" modifier data:");
|
||||
log_printf (" callback . . . . . . : 0x%lx", HOOK_MODIFIER(ptr_hook, callback));
|
||||
log_printf (" modifier . . . . . . : '%s'", HOOK_MODIFIER(ptr_hook, modifier));
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_MODIFIER(ptr_hook, callback));
|
||||
log_printf (" modifier. . . . . . . : '%s'", HOOK_MODIFIER(ptr_hook, modifier));
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_INFO:
|
||||
if (!ptr_hook->deleted)
|
||||
{
|
||||
log_printf (" info data:");
|
||||
log_printf (" callback . . . . . . : 0x%lx", HOOK_INFO(ptr_hook, callback));
|
||||
log_printf (" info_name. . . . . . : '%s'", HOOK_INFO(ptr_hook, info_name));
|
||||
log_printf (" description. . . . . : '%s'", HOOK_INFO(ptr_hook, description));
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_INFO(ptr_hook, callback));
|
||||
log_printf (" info_name . . . . . . : '%s'", HOOK_INFO(ptr_hook, info_name));
|
||||
log_printf (" description . . . . . : '%s'", HOOK_INFO(ptr_hook, description));
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_INFOLIST:
|
||||
if (!ptr_hook->deleted)
|
||||
{
|
||||
log_printf (" infolist data:");
|
||||
log_printf (" callback . . . . . . : 0x%lx", HOOK_INFOLIST(ptr_hook, callback));
|
||||
log_printf (" infolist_name. . . . : '%s'", HOOK_INFOLIST(ptr_hook, infolist_name));
|
||||
log_printf (" description. . . . . : '%s'", HOOK_INFOLIST(ptr_hook, description));
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_INFOLIST(ptr_hook, callback));
|
||||
log_printf (" infolist_name . . . . : '%s'", HOOK_INFOLIST(ptr_hook, infolist_name));
|
||||
log_printf (" description . . . . . : '%s'", HOOK_INFOLIST(ptr_hook, description));
|
||||
}
|
||||
break;
|
||||
case HOOK_NUM_TYPES:
|
||||
@@ -2606,8 +2826,8 @@ hook_print_log ()
|
||||
it is never used as type */
|
||||
break;
|
||||
}
|
||||
log_printf (" prev_hook. . . . . . . : 0x%lx", ptr_hook->prev_hook);
|
||||
log_printf (" next_hook. . . . . . . : 0x%lx", ptr_hook->next_hook);
|
||||
log_printf (" prev_hook . . . . . . . : 0x%lx", ptr_hook->prev_hook);
|
||||
log_printf (" next_hook . . . . . . . : 0x%lx", ptr_hook->next_hook);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+22
-6
@@ -97,12 +97,26 @@ typedef int (t_hook_callback_command)(void *data, struct t_gui_buffer *buffer,
|
||||
|
||||
struct t_hook_command
|
||||
{
|
||||
t_hook_callback_command *callback; /* command callback */
|
||||
char *command; /* name of command (without '/') */
|
||||
char *description; /* (for /help) short cmd description */
|
||||
char *args; /* (for /help) command arguments */
|
||||
char *args_description; /* (for /help) args long description */
|
||||
char *completion; /* template for completion */
|
||||
t_hook_callback_command *callback; /* command callback */
|
||||
char *command; /* name of command (without '/') */
|
||||
char *description; /* (for /help) short cmd description*/
|
||||
char *args; /* (for /help) command arguments */
|
||||
char *args_description; /* (for /help) args long description*/
|
||||
char *completion; /* template for completion */
|
||||
|
||||
/* templates */
|
||||
int cplt_num_templates; /* number of templates for compl. */
|
||||
char **cplt_templates; /* completion templates */
|
||||
char **cplt_templates_static; /* static part of template (at */
|
||||
/* beginning */
|
||||
|
||||
/* arguments for each template */
|
||||
int *cplt_template_num_args; /* number of arguments for template */
|
||||
char ***cplt_template_args; /* arguments for each template */
|
||||
|
||||
/* concatenation of arg N for each template */
|
||||
int cplt_template_num_args_concat; /* number of concatened arguments */
|
||||
char **cplt_template_args_concat; /* concatened arguments */
|
||||
};
|
||||
|
||||
/* hook command run */
|
||||
@@ -241,6 +255,7 @@ struct t_hook_completion
|
||||
{
|
||||
t_hook_callback_completion *callback; /* completion callback */
|
||||
char *completion_item; /* name of completion */
|
||||
char *description; /* description */
|
||||
};
|
||||
|
||||
/* hook modifier */
|
||||
@@ -355,6 +370,7 @@ extern struct t_hook *hook_config (struct t_weechat_plugin *plugin,
|
||||
extern void hook_config_exec (const char *option, const char *value);
|
||||
extern struct t_hook *hook_completion (struct t_weechat_plugin *plugin,
|
||||
const char *completion_item,
|
||||
const char *description,
|
||||
t_hook_callback_completion *callback,
|
||||
void *callback_data);
|
||||
extern void hook_completion_list_add (struct t_gui_completion *completion,
|
||||
|
||||
@@ -52,6 +52,7 @@ struct t_proxy
|
||||
|
||||
/* variables */
|
||||
|
||||
extern char *proxy_option_string[];
|
||||
extern char *proxy_type_string[];
|
||||
extern struct t_proxy *weechat_proxies;
|
||||
extern struct t_proxy *last_weechat_proxy;
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
#include "wee-util.h"
|
||||
#include "../gui/gui-chat.h"
|
||||
#include "../gui/gui-color.h"
|
||||
#include "../gui/gui-completion.h"
|
||||
#include "../gui/gui-layout.h"
|
||||
#include "../gui/gui-main.h"
|
||||
#include "../gui/gui-keyboard.h"
|
||||
@@ -388,6 +389,7 @@ main (int argc, char *argv[])
|
||||
gui_main_pre_init (&argc, &argv); /* pre-initiliaze interface */
|
||||
weechat_init_vars (); /* initialize some variables */
|
||||
command_init (); /* initialize WeeChat commands */
|
||||
gui_completion_init (); /* add core completion hooks */
|
||||
gui_keyboard_init (); /* init keyboard */
|
||||
if (!config_weechat_init ()) /* init options with default values */
|
||||
exit (EXIT_FAILURE);
|
||||
|
||||
@@ -98,6 +98,7 @@ struct t_gui_bar
|
||||
|
||||
/* variables */
|
||||
|
||||
extern char *gui_bar_option_string[];
|
||||
extern char *gui_bar_type_string[];
|
||||
extern char *gui_bar_position_string[];
|
||||
extern char *gui_bar_filling_string[];
|
||||
|
||||
@@ -346,7 +346,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
|
||||
if (new_completion)
|
||||
{
|
||||
new_buffer->completion = new_completion;
|
||||
gui_completion_init (new_completion, new_buffer);
|
||||
gui_completion_buffer_init (new_completion, new_buffer);
|
||||
}
|
||||
|
||||
/* init history */
|
||||
|
||||
+505
-137
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,7 @@ struct t_gui_completion
|
||||
struct t_gui_buffer *buffer; /* buffer where completion was asked */
|
||||
int context; /* context: null, nick, command, cmd arg */
|
||||
char *base_command; /* cmd with arg to complete (can be NULL) */
|
||||
int base_command_arg; /* # arg to complete (if context=cmd arg) */
|
||||
int base_command_arg_index; /* # arg to complete (if context=cmd arg) */
|
||||
char *base_word; /* word to complete (when Tab was pressed) */
|
||||
int base_word_pos; /* beggining of base word */
|
||||
int position; /* position where Tab was pressed */
|
||||
@@ -63,8 +63,8 @@ extern struct t_gui_completion_partial *gui_completion_partial_list;
|
||||
|
||||
/* completion functions */
|
||||
|
||||
extern void gui_completion_init (struct t_gui_completion *completion,
|
||||
struct t_gui_buffer *buffer);
|
||||
extern void gui_completion_buffer_init (struct t_gui_completion *completion,
|
||||
struct t_gui_buffer *buffer);
|
||||
extern void gui_completion_free (struct t_gui_completion *completion);
|
||||
extern void gui_completion_stop (struct t_gui_completion *completion,
|
||||
int remove_partial_completion_list);
|
||||
@@ -75,5 +75,6 @@ extern void gui_completion_search (struct t_gui_completion *completion,
|
||||
int direction, const char *data, int size,
|
||||
int pos);
|
||||
extern void gui_completion_print_log (struct t_gui_completion *completion);
|
||||
extern void gui_completion_init ();
|
||||
|
||||
#endif /* gui-completion.h */
|
||||
|
||||
@@ -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