diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2020-05-08 10:49:20 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2020-05-08 10:51:30 +0200 |
commit | 88bef0b1b127f67149060fe36757940379d7f4a3 (patch) | |
tree | 0f71e6a7c1b6c322013d78eb0f48aa753cd246af /src | |
parent | b7765ed9606f17e83ccd9e6aa96a1ca88294952e (diff) | |
download | weechat-88bef0b1b127f67149060fe36757940379d7f4a3.zip |
core: rename functions hook_completion_{get_string|list_add} to completion_{get_string|list_add}
Old functions are kept for compatibility reasons.
Diffstat (limited to 'src')
24 files changed, 652 insertions, 238 deletions
diff --git a/src/core/hook/wee-hook-completion.c b/src/core/hook/wee-hook-completion.c index 2562baa1a..8a8827f19 100644 --- a/src/core/hook/wee-hook-completion.c +++ b/src/core/hook/wee-hook-completion.c @@ -83,29 +83,6 @@ hook_completion (struct t_weechat_plugin *plugin, const char *completion_item, } /* - * Gets a completion property as string. - */ - -const char * -hook_completion_get_string (struct t_gui_completion *completion, - const char *property) -{ - return gui_completion_get_string (completion, property); -} - -/* - * Adds a word for a completion. - */ - -void -hook_completion_list_add (struct t_gui_completion *completion, - const char *word, int nick_completion, - const char *where) -{ - gui_completion_list_add (completion, word, nick_completion, where); -} - -/* * Executes a completion hook. */ diff --git a/src/core/hook/wee-hook-completion.h b/src/core/hook/wee-hook-completion.h index 4252bd14c..91a56ffae 100644 --- a/src/core/hook/wee-hook-completion.h +++ b/src/core/hook/wee-hook-completion.h @@ -45,11 +45,6 @@ extern struct t_hook *hook_completion (struct t_weechat_plugin *plugin, t_hook_callback_completion *callback, const void *callback_pointer, void *callback_data); -extern const char *hook_completion_get_string (struct t_gui_completion *completion, - const char *property); -extern void hook_completion_list_add (struct t_gui_completion *completion, - const char *word, int nick_completion, - const char *where); extern void hook_completion_exec (struct t_weechat_plugin *plugin, const char *completion_item, struct t_gui_buffer *buffer, diff --git a/src/plugins/alias/alias-completion.c b/src/plugins/alias/alias-completion.c index 9152f9e71..32dfffcd7 100644 --- a/src/plugins/alias/alias-completion.c +++ b/src/plugins/alias/alias-completion.c @@ -48,8 +48,8 @@ alias_completion_alias_cb (const void *pointer, void *data, for (ptr_alias = alias_list; ptr_alias; ptr_alias = ptr_alias->next_alias) { - weechat_hook_completion_list_add (completion, ptr_alias->name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_alias->name, + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -76,7 +76,7 @@ alias_completion_alias_value_cb (const void *pointer, void *data, (void) completion_item; (void) buffer; - args = weechat_hook_completion_get_string (completion, "args"); + args = weechat_completion_get_string (completion, "args"); if (args) { argv = weechat_string_split (args, " ", NULL, @@ -96,10 +96,10 @@ alias_completion_alias_value_cb (const void *pointer, void *data, ptr_alias = alias_search (alias_name); if (ptr_alias) { - weechat_hook_completion_list_add (completion, - ptr_alias->command, - 0, - WEECHAT_LIST_POS_BEGINNING); + weechat_completion_list_add (completion, + ptr_alias->command, + 0, + WEECHAT_LIST_POS_BEGINNING); } free (alias_name); } diff --git a/src/plugins/exec/exec-completion.c b/src/plugins/exec/exec-completion.c index 72f703520..63b070cf5 100644 --- a/src/plugins/exec/exec-completion.c +++ b/src/plugins/exec/exec-completion.c @@ -51,12 +51,12 @@ exec_completion_commands_ids_cb (const void *pointer, void *data, { snprintf (str_number, sizeof (str_number), "%ld", ptr_exec_cmd->number); - weechat_hook_completion_list_add (completion, str_number, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, str_number, + 0, WEECHAT_LIST_POS_SORT); if (ptr_exec_cmd->name) { - weechat_hook_completion_list_add (completion, ptr_exec_cmd->name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_exec_cmd->name, + 0, WEECHAT_LIST_POS_SORT); } } diff --git a/src/plugins/fset/fset-completion.c b/src/plugins/fset/fset-completion.c index efb634cad..265648afc 100644 --- a/src/plugins/fset/fset-completion.c +++ b/src/plugins/fset/fset-completion.c @@ -62,19 +62,19 @@ fset_completion_option_cb (const void *pointer, void *data, { if (!config_section_added) { - weechat_hook_completion_list_add ( + weechat_completion_list_add ( completion, weechat_config_option_get_string (ptr_option, "config_name"), 0, WEECHAT_LIST_POS_SORT); - weechat_hook_completion_list_add ( + weechat_completion_list_add ( completion, weechat_config_option_get_string (ptr_option, "section_name"), 0, WEECHAT_LIST_POS_SORT); config_section_added = 1; } - weechat_hook_completion_list_add ( + weechat_completion_list_add ( completion, weechat_config_option_get_string (ptr_option, "name"), 0, @@ -92,7 +92,7 @@ fset_completion_option_cb (const void *pointer, void *data, { for (i = 0; i < num_words; i++) { - weechat_hook_completion_list_add ( + weechat_completion_list_add ( completion, words[i], 0, WEECHAT_LIST_POS_SORT); } } diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index 15f51b735..d35beba86 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -2057,6 +2057,11 @@ weechat_guile_api_hook_completion (SCM completion, SCM description, API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_get_string. + */ + SCM weechat_guile_api_hook_completion_get_string (SCM completion, SCM property) { @@ -2074,6 +2079,11 @@ weechat_guile_api_hook_completion_get_string (SCM completion, SCM property) API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_list_add. + */ + SCM weechat_guile_api_hook_completion_list_add (SCM completion, SCM word, SCM nick_completion, SCM where) @@ -4138,6 +4148,40 @@ weechat_guile_api_completion_search (SCM completion, SCM data, SCM position, } SCM +weechat_guile_api_completion_get_string (SCM completion, SCM property) +{ + const char *result; + SCM return_value; + + API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY); + if (!scm_is_string (completion) || !scm_is_string (property)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + result = weechat_completion_get_string ( + API_STR2PTR(API_SCM_TO_STRING(completion)), + API_SCM_TO_STRING(property)); + + API_RETURN_STRING(result); +} + +SCM +weechat_guile_api_completion_list_add (SCM completion, SCM word, + SCM nick_completion, SCM where) +{ + API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR); + if (!scm_is_string (completion) || !scm_is_string (word) + || !scm_is_integer (nick_completion) || !scm_is_string (where)) + API_WRONG_ARGS(API_RETURN_ERROR); + + weechat_completion_list_add (API_STR2PTR(API_SCM_TO_STRING(completion)), + API_SCM_TO_STRING(word), + scm_to_int (nick_completion), + API_SCM_TO_STRING(where)); + + API_RETURN_OK; +} + +SCM weechat_guile_api_completion_free (SCM completion) { API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR); @@ -5103,6 +5147,8 @@ weechat_guile_api_module_init (void *data) API_DEF_FUNC(command_options, 3); API_DEF_FUNC(completion_new, 1); API_DEF_FUNC(completion_search, 4); + API_DEF_FUNC(completion_get_string, 2); + API_DEF_FUNC(completion_list_add, 4); API_DEF_FUNC(completion_free, 1); API_DEF_FUNC(info_get, 2); API_DEF_FUNC(info_get_hashtable, 2); diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c index 79453f3fd..9efcb7d70 100644 --- a/src/plugins/irc/irc-completion.c +++ b/src/plugins/irc/irc-completion.c @@ -56,8 +56,8 @@ irc_completion_server_cb (const void *pointer, void *data, if (ptr_server) { - weechat_hook_completion_list_add (completion, ptr_server->name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_server->name, + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -82,8 +82,8 @@ irc_completion_server_nick_cb (const void *pointer, void *data, if (ptr_server && ptr_server->nick) { - weechat_hook_completion_list_add (completion, ptr_server->nick, - 1, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_server->nick, + 1, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -115,16 +115,16 @@ irc_completion_server_channels_cb (const void *pointer, void *data, { if (ptr_channel2->type == IRC_CHANNEL_TYPE_CHANNEL) { - weechat_hook_completion_list_add (completion, ptr_channel2->name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_channel2->name, + 0, WEECHAT_LIST_POS_SORT); } } /* add current channel first in list */ if (ptr_channel) { - weechat_hook_completion_list_add (completion, ptr_channel->name, - 0, WEECHAT_LIST_POS_BEGINNING); + weechat_completion_list_add (completion, ptr_channel->name, + 0, WEECHAT_LIST_POS_BEGINNING); } } @@ -157,8 +157,8 @@ irc_completion_server_privates_cb (const void *pointer, void *data, { if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) { - weechat_hook_completion_list_add (completion, ptr_channel->name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_channel->name, + 0, WEECHAT_LIST_POS_SORT); } } } @@ -196,15 +196,15 @@ irc_completion_server_nicks_cb (const void *pointer, void *data, for (ptr_nick = ptr_channel2->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) { - weechat_hook_completion_list_add (completion, ptr_nick->name, - 1, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_nick->name, + 1, WEECHAT_LIST_POS_SORT); } } } /* add self nick at the end */ - weechat_hook_completion_list_add (completion, ptr_server->nick, - 1, WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, ptr_server->nick, + 1, WEECHAT_LIST_POS_END); } return WEECHAT_RC_OK; @@ -231,8 +231,8 @@ irc_completion_servers_cb (const void *pointer, void *data, for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) { - weechat_hook_completion_list_add (completion, ptr_server->name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_server->name, + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -257,8 +257,8 @@ irc_completion_channel_cb (const void *pointer, void *data, if (ptr_channel) { - weechat_hook_completion_list_add (completion, ptr_channel->name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_channel->name, + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -286,10 +286,10 @@ irc_completion_channel_nicks_add_speakers (struct t_gui_completion *completion, weechat_list_get (channel->nicks_speaking[highlight], i)); if (nick && irc_nick_search (server, channel, nick)) { - weechat_hook_completion_list_add (completion, - nick, - 1, - WEECHAT_LIST_POS_BEGINNING); + weechat_completion_list_add (completion, + nick, + 1, + WEECHAT_LIST_POS_BEGINNING); } } } @@ -322,10 +322,10 @@ irc_completion_channel_nicks_cb (const void *pointer, void *data, for (ptr_nick = ptr_channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) { - weechat_hook_completion_list_add (completion, - ptr_nick->name, - 1, - WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + ptr_nick->name, + 1, + WEECHAT_LIST_POS_SORT); } /* add recent speakers on channel */ if (weechat_config_integer (irc_config_look_nick_completion_smart) == IRC_CONFIG_NICK_COMPLETION_SMART_SPEAKERS) @@ -338,22 +338,22 @@ irc_completion_channel_nicks_cb (const void *pointer, void *data, irc_completion_channel_nicks_add_speakers (completion, ptr_server, ptr_channel, 1); } /* add self nick at the end */ - weechat_hook_completion_list_add (completion, - ptr_server->nick, - 1, - WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, + ptr_server->nick, + 1, + WEECHAT_LIST_POS_END); break; case IRC_CHANNEL_TYPE_PRIVATE: /* remote nick */ - weechat_hook_completion_list_add (completion, - ptr_channel->name, - 1, - WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + ptr_channel->name, + 1, + WEECHAT_LIST_POS_SORT); /* add self nick at the end */ - weechat_hook_completion_list_add (completion, - ptr_server->nick, - 1, - WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, + ptr_server->nick, + 1, + WEECHAT_LIST_POS_END); break; } ptr_channel->nick_completion_reset = 0; @@ -391,10 +391,10 @@ irc_completion_channel_nicks_hosts_cb (const void *pointer, void *data, for (ptr_nick = ptr_channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) { - weechat_hook_completion_list_add (completion, - ptr_nick->name, - 1, - WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + ptr_nick->name, + 1, + WEECHAT_LIST_POS_SORT); if (ptr_nick->host) { length = strlen (ptr_nick->name) + 1 + @@ -404,7 +404,7 @@ irc_completion_channel_nicks_hosts_cb (const void *pointer, void *data, { snprintf (buf, length, "%s!%s", ptr_nick->name, ptr_nick->host); - weechat_hook_completion_list_add ( + weechat_completion_list_add ( completion, buf, 0, WEECHAT_LIST_POS_SORT); free (buf); } @@ -412,7 +412,7 @@ irc_completion_channel_nicks_hosts_cb (const void *pointer, void *data, } break; case IRC_CHANNEL_TYPE_PRIVATE: - weechat_hook_completion_list_add ( + weechat_completion_list_add ( completion, ptr_channel->name, 1, WEECHAT_LIST_POS_SORT); break; } @@ -453,9 +453,9 @@ irc_completion_modelist_masks_cb (const void *pointer, void *data, for (ptr_item = ptr_modelist->items; ptr_item; ptr_item = ptr_item->next_item) { - weechat_hook_completion_list_add (completion, - ptr_item->mask, - 0, WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, + ptr_item->mask, + 0, WEECHAT_LIST_POS_END); } } } @@ -497,9 +497,9 @@ irc_completion_modelist_numbers_cb (const void *pointer, void *data, { snprintf (str_number, sizeof (str_number), "%d", ptr_item->number + 1); - weechat_hook_completion_list_add (completion, - str_number, - 0, WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, + str_number, + 0, WEECHAT_LIST_POS_END); } } } @@ -551,9 +551,9 @@ irc_completion_channel_topic_cb (const void *pointer, void *data, else topic = strdup (ptr_channel->topic); - weechat_hook_completion_list_add (completion, - (topic) ? topic : ptr_channel->topic, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + (topic) ? topic : ptr_channel->topic, + 0, WEECHAT_LIST_POS_SORT); if (topic) free (topic); } @@ -603,10 +603,10 @@ irc_completion_channels_cb (const void *pointer, void *data, } else { - weechat_hook_completion_list_add (completion, - ptr_channel2->name, - 0, - WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + ptr_channel2->name, + 0, + WEECHAT_LIST_POS_SORT); } } } @@ -615,7 +615,7 @@ irc_completion_channels_cb (const void *pointer, void *data, /* add channels of current server first in list */ for (i = weechat_list_size (channels_current_server) - 1; i >= 0; i--) { - weechat_hook_completion_list_add ( + weechat_completion_list_add ( completion, weechat_list_string ( weechat_list_get (channels_current_server, i)), @@ -627,8 +627,8 @@ irc_completion_channels_cb (const void *pointer, void *data, /* add current channel first in list */ if (ptr_channel) { - weechat_hook_completion_list_add (completion, ptr_channel->name, - 0, WEECHAT_LIST_POS_BEGINNING); + weechat_completion_list_add (completion, ptr_channel->name, + 0, WEECHAT_LIST_POS_BEGINNING); } return WEECHAT_RC_OK; @@ -661,8 +661,8 @@ irc_completion_privates_cb (const void *pointer, void *data, { if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) { - weechat_hook_completion_list_add (completion, ptr_channel->name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_channel->name, + 0, WEECHAT_LIST_POS_SORT); } } } @@ -695,8 +695,8 @@ irc_completion_msg_kick_cb (const void *pointer, void *data, IRC_SERVER_OPTION_MSG_KICK); if (msg_kick && msg_kick[0]) { - weechat_hook_completion_list_add (completion, msg_kick, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, msg_kick, + 0, WEECHAT_LIST_POS_SORT); } } @@ -728,8 +728,8 @@ irc_completion_msg_part_cb (const void *pointer, void *data, IRC_SERVER_OPTION_MSG_PART); if (msg_part && msg_part[0]) { - weechat_hook_completion_list_add (completion, msg_part, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, msg_part, + 0, WEECHAT_LIST_POS_SORT); } } @@ -759,8 +759,8 @@ irc_completion_ignores_numbers_cb (const void *pointer, void *data, 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); + weechat_completion_list_add (completion, str_number, + 0, WEECHAT_LIST_POS_END); } return WEECHAT_RC_OK; @@ -790,8 +790,8 @@ irc_completion_notify_nicks_cb (const void *pointer, void *data, for (ptr_notify = ptr_server->notify_list; ptr_notify; ptr_notify = ptr_notify->next_notify) { - weechat_hook_completion_list_add (completion, ptr_notify->nick, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_notify->nick, + 0, WEECHAT_LIST_POS_SORT); } } else @@ -802,8 +802,8 @@ irc_completion_notify_nicks_cb (const void *pointer, void *data, for (ptr_notify = ptr_server->notify_list; ptr_notify; ptr_notify = ptr_notify->next_notify) { - weechat_hook_completion_list_add (completion, ptr_notify->nick, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_notify->nick, + 0, WEECHAT_LIST_POS_SORT); } } } @@ -831,37 +831,37 @@ irc_completion_raw_filters_cb (const void *pointer, void *data, (void) completion_item; /* all messages */ - weechat_hook_completion_list_add (completion, "*", - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, "*", + 0, WEECHAT_LIST_POS_SORT); /* condition */ - weechat_hook_completion_list_add (completion, - "c:${recv} && ${command}==PRIVMSG", - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + "c:${recv} && ${command}==PRIVMSG", + 0, WEECHAT_LIST_POS_SORT); /* message flag */ - weechat_hook_completion_list_add (completion, "f:modified", - 0, WEECHAT_LIST_POS_SORT); - weechat_hook_completion_list_add (completion, "f:recv", - 0, WEECHAT_LIST_POS_SORT); - weechat_hook_completion_list_add (completion, "f:redirected", - 0, WEECHAT_LIST_POS_SORT); - weechat_hook_completion_list_add (completion, "f:sent", - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, "f:modified", + 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, "f:recv", + 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, "f:redirected", + 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, "f:sent", + 0, WEECHAT_LIST_POS_SORT); /* IRC command */ - weechat_hook_completion_list_add (completion, "m:notice", - 0, WEECHAT_LIST_POS_SORT); - weechat_hook_completion_list_add (completion, "m:privmsg", - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, "m:notice", + 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, "m:privmsg", + 0, WEECHAT_LIST_POS_SORT); /* server */ for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) { snprintf (str_filter, sizeof (str_filter), "s:%s", ptr_server->name); - weechat_hook_completion_list_add (completion, str_filter, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, str_filter, + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp index 275c38592..19e33c431 100644 --- a/src/plugins/javascript/weechat-js-api.cpp +++ b/src/plugins/javascript/weechat-js-api.cpp @@ -1948,6 +1948,11 @@ API_FUNC(hook_completion) API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_get_string. + */ + API_FUNC(hook_completion_get_string) { const char *result; @@ -1964,6 +1969,11 @@ API_FUNC(hook_completion_get_string) API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_list_add. + */ + API_FUNC(hook_completion_list_add) { int nick_completion; @@ -4033,6 +4043,42 @@ API_FUNC(completion_search) API_RETURN_INT(rc); } +API_FUNC(completion_get_string) +{ + const char *result; + + API_INIT_FUNC(1, "completion_get_string", "ss", API_RETURN_EMPTY); + + v8::String::Utf8Value completion(args[0]); + v8::String::Utf8Value property(args[1]); + + result = weechat_completion_get_string ( + (struct t_gui_completion *)API_STR2PTR(*completion), + *property); + + API_RETURN_STRING(result); +} + +API_FUNC(completion_list_add) +{ + int nick_completion; + + API_INIT_FUNC(1, "completion_list_add", "ssis", API_RETURN_ERROR); + + v8::String::Utf8Value completion(args[0]); + v8::String::Utf8Value word(args[1]); + nick_completion = args[2]->IntegerValue(); + v8::String::Utf8Value where(args[3]); + + weechat_completion_list_add ( + (struct t_gui_completion *)API_STR2PTR(*completion), + *word, + nick_completion, + *where); + + API_RETURN_OK; +} + API_FUNC(completion_free) { API_INIT_FUNC(1, "completion_free", "s", API_RETURN_ERROR); @@ -5038,6 +5084,8 @@ WeechatJsV8::loadLibs() API_DEF_FUNC(command_options); API_DEF_FUNC(completion_new); API_DEF_FUNC(completion_search); + API_DEF_FUNC(completion_get_string); + API_DEF_FUNC(completion_list_add); API_DEF_FUNC(completion_free); API_DEF_FUNC(info_get); API_DEF_FUNC(info_get_hashtable); diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index f6587a90e..68ff70175 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -2165,6 +2165,11 @@ API_FUNC(hook_completion) API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_get_string. + */ + API_FUNC(hook_completion_get_string) { const char *completion, *property, *result; @@ -2182,6 +2187,11 @@ API_FUNC(hook_completion_get_string) API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_list_add. + */ + API_FUNC(hook_completion_list_add) { const char *completion, *word, *where; @@ -4373,6 +4383,45 @@ API_FUNC(completion_search) API_RETURN_INT(rc); } +API_FUNC(completion_get_string) +{ + const char *completion, *property, *result; + + API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY); + if (lua_gettop (L) < 2) + API_WRONG_ARGS(API_RETURN_EMPTY); + + completion = lua_tostring (L, -2); + property = lua_tostring (L, -1); + + result = weechat_completion_get_string (API_STR2PTR(completion), + property); + + API_RETURN_STRING(result); +} + +API_FUNC(completion_list_add) +{ + const char *completion, *word, *where; + int nick_completion; + + API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR); + if (lua_gettop (L) < 4) + API_WRONG_ARGS(API_RETURN_ERROR); + + completion = lua_tostring (L, -4); + word = lua_tostring (L, -3); + nick_completion = lua_tonumber (L, -2); + where = lua_tostring (L, -1); + + weechat_completion_list_add (API_STR2PTR(completion), + word, + nick_completion, + where); + + API_RETURN_OK; +} + API_FUNC(completion_free) { const char *completion; @@ -5398,6 +5447,8 @@ const struct luaL_Reg weechat_lua_api_funcs[] = { API_DEF_FUNC(command_options), API_DEF_FUNC(completion_new), API_DEF_FUNC(completion_search), + API_DEF_FUNC(completion_get_string), + API_DEF_FUNC(completion_list_add), API_DEF_FUNC(completion_free), API_DEF_FUNC(info_get), API_DEF_FUNC(info_get_hashtable), diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index 259fb29ca..62ad7961d 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -2081,6 +2081,11 @@ API_FUNC(hook_completion) API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_get_string. + */ + API_FUNC(hook_completion_get_string) { char *completion, *property; @@ -2100,6 +2105,11 @@ API_FUNC(hook_completion_get_string) API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_list_add. + */ + API_FUNC(hook_completion_list_add) { char *completion, *word, *where; @@ -4296,6 +4306,46 @@ API_FUNC(completion_search) API_RETURN_INT(rc); } +API_FUNC(completion_get_string) +{ + char *completion, *property; + const char *result; + dXSARGS; + + API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY); + if (items < 2) + API_WRONG_ARGS(API_RETURN_EMPTY); + + completion = SvPV_nolen (ST (0)); + property = SvPV_nolen (ST (1)); + + result = weechat_completion_get_string (API_STR2PTR(completion), + property); + + API_RETURN_STRING(result); +} + +API_FUNC(completion_list_add) +{ + char *completion, *word, *where; + dXSARGS; + + API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR); + if (items < 4) + API_WRONG_ARGS(API_RETURN_ERROR); + + completion = SvPV_nolen (ST (0)); + word = SvPV_nolen (ST (1)); + where = SvPV_nolen (ST (3)); + + weechat_completion_list_add (API_STR2PTR(completion), + word, + SvIV (ST (2)), /* nick_completion */ + where); + + API_RETURN_OK; +} + API_FUNC(completion_free) { dXSARGS; @@ -5355,6 +5405,8 @@ weechat_perl_api_init (pTHX) API_DEF_FUNC(command_options); API_DEF_FUNC(completion_new); API_DEF_FUNC(completion_search); + API_DEF_FUNC(completion_get_string); + API_DEF_FUNC(completion_list_add); API_DEF_FUNC(completion_free); API_DEF_FUNC(info_get); API_DEF_FUNC(info_get_hashtable); diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index 7a736061d..f974732b2 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -2206,6 +2206,11 @@ API_FUNC(hook_completion) API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_get_string. + */ + API_FUNC(hook_completion_get_string) { zend_string *z_completion, *z_property; @@ -2227,6 +2232,11 @@ API_FUNC(hook_completion_get_string) API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_list_add. + */ + API_FUNC(hook_completion_list_add) { zend_string *z_completion, *z_word, *z_where; @@ -4308,6 +4318,53 @@ API_FUNC(completion_search) API_RETURN_INT(rc); } +API_FUNC(completion_get_string) +{ + zend_string *z_completion, *z_property; + struct t_gui_completion *completion; + char *property; + const char *result; + + API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "SS", &z_completion, + &z_property) == FAILURE) + API_WRONG_ARGS(API_RETURN_EMPTY); + + completion = (struct t_gui_completion *)API_STR2PTR(ZSTR_VAL(z_completion)); + property = ZSTR_VAL(z_property); + + result = weechat_completion_get_string (completion, + (const char *)property); + + API_RETURN_STRING(result); +} + +API_FUNC(completion_list_add) +{ + zend_string *z_completion, *z_word, *z_where; + zend_long z_nick_completion; + struct t_gui_completion *completion; + char *word, *where; + int nick_completion; + + API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "SSlS", &z_completion, + &z_word, &z_nick_completion, &z_where) == FAILURE) + API_WRONG_ARGS(API_RETURN_ERROR); + + completion = (struct t_gui_completion *)API_STR2PTR(ZSTR_VAL(z_completion)); + word = ZSTR_VAL(z_word); + nick_completion = (int)z_nick_completion; + where = ZSTR_VAL(z_where); + + weechat_completion_list_add (completion, + (const char *)word, + nick_completion, + (const char *)where); + + API_RETURN_OK; +} + API_FUNC(completion_free) { zend_string *z_completion; diff --git a/src/plugins/php/weechat-php-api.h b/src/plugins/php/weechat-php-api.h index 303b30735..71ca67b26 100644 --- a/src/plugins/php/weechat-php-api.h +++ b/src/plugins/php/weechat-php-api.h @@ -200,6 +200,8 @@ PHP_FUNCTION(weechat_command); PHP_FUNCTION(weechat_command_options); PHP_FUNCTION(weechat_completion_new); PHP_FUNCTION(weechat_completion_search); +PHP_FUNCTION(weechat_completion_get_string); +PHP_FUNCTION(weechat_completion_list_add); PHP_FUNCTION(weechat_completion_free); PHP_FUNCTION(weechat_info_get); PHP_FUNCTION(weechat_info_get_hashtable); diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c index 95e096b8f..93a1f2069 100644 --- a/src/plugins/php/weechat-php.c +++ b/src/plugins/php/weechat-php.c @@ -253,6 +253,8 @@ const zend_function_entry weechat_functions[] = { PHP_FE(weechat_command_options, NULL) PHP_FE(weechat_completion_new, NULL) PHP_FE(weechat_completion_search, NULL) + PHP_FE(weechat_completion_get_string, NULL) + PHP_FE(weechat_completion_list_add, NULL) PHP_FE(weechat_completion_free, NULL) PHP_FE(weechat_info_get, NULL) PHP_FE(weechat_info_get_hashtable, NULL) diff --git a/src/plugins/plugin-script.c b/src/plugins/plugin-script.c index 7a036df47..dbf1da5fd 100644 --- a/src/plugins/plugin-script.c +++ b/src/plugins/plugin-script.c @@ -1087,8 +1087,8 @@ plugin_script_completion (struct t_weechat_plugin *weechat_plugin, for (ptr_script = scripts; ptr_script; ptr_script = ptr_script->next_script) { - weechat_hook_completion_list_add (completion, ptr_script->name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_script->name, + 0, WEECHAT_LIST_POS_SORT); } } diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 1b5cf78a1..ab929983e 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -786,8 +786,8 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv) new_plugin->hook_hsignal_send = &hook_hsignal_send; new_plugin->hook_config = &hook_config; new_plugin->hook_completion = &hook_completion; - new_plugin->hook_completion_get_string = &hook_completion_get_string; - new_plugin->hook_completion_list_add = &hook_completion_list_add; + new_plugin->hook_completion_get_string = &gui_completion_get_string; + new_plugin->hook_completion_list_add = &gui_completion_list_add; new_plugin->hook_modifier = &hook_modifier; new_plugin->hook_modifier_exec = &hook_modifier_exec; new_plugin->hook_info = &hook_info; @@ -852,6 +852,8 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv) new_plugin->completion_new = &gui_completion_new; new_plugin->completion_search = &gui_completion_search; + new_plugin->completion_get_string = &gui_completion_get_string; + new_plugin->completion_list_add = &gui_completion_list_add; new_plugin->completion_free = &gui_completion_free; new_plugin->network_pass_proxy = &network_pass_proxy; diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index 0803ed21b..d772b97c4 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -2071,6 +2071,11 @@ API_FUNC(hook_completion) API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_get_string. + */ + API_FUNC(hook_completion_get_string) { char *completion, *property; @@ -2088,6 +2093,11 @@ API_FUNC(hook_completion_get_string) API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_list_add. + */ + API_FUNC(hook_completion_list_add) { char *completion, *word, *where; @@ -4308,6 +4318,45 @@ API_FUNC(completion_search) API_RETURN_INT(rc); } +API_FUNC(completion_get_string) +{ + char *completion, *property; + const char *result; + + API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY); + completion = NULL; + property = NULL; + if (!PyArg_ParseTuple (args, "ss", &completion, &property)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + result = weechat_completion_get_string (API_STR2PTR(completion), + property); + + API_RETURN_STRING(result); +} + +API_FUNC(completion_list_add) +{ + char *completion, *word, *where; + int nick_completion; + + API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR); + completion = NULL; + word = NULL; + nick_completion = 0; + where = NULL; + if (!PyArg_ParseTuple (args, "ssis", &completion, &word, &nick_completion, + &where)) + API_WRONG_ARGS(API_RETURN_ERROR); + + weechat_completion_list_add (API_STR2PTR(completion), + word, + nick_completion, + where); + + API_RETURN_OK; +} + API_FUNC(completion_free) { char *completion; @@ -5305,6 +5354,8 @@ PyMethodDef weechat_python_funcs[] = API_DEF_FUNC(command_options), API_DEF_FUNC(completion_new), API_DEF_FUNC(completion_search), + API_DEF_FUNC(completion_get_string), + API_DEF_FUNC(completion_list_add), API_DEF_FUNC(completion_free), API_DEF_FUNC(info_get), API_DEF_FUNC(info_get_hashtable), diff --git a/src/plugins/relay/relay-completion.c b/src/plugins/relay/relay-completion.c index 48c8d46b0..bb17c4a1a 100644 --- a/src/plugins/relay/relay-completion.c +++ b/src/plugins/relay/relay-completion.c @@ -55,36 +55,36 @@ relay_completion_protocol_name_cb (const void *pointer, void *data, /* TCP socket */ snprintf (protocol_name, sizeof (protocol_name), "irc.%s", weechat_infolist_string (infolist, "name")); - weechat_hook_completion_list_add (completion, protocol_name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, protocol_name, + 0, WEECHAT_LIST_POS_SORT); snprintf (protocol_name, sizeof (protocol_name), "ssl.irc.%s", weechat_infolist_string (infolist, "name")); - weechat_hook_completion_list_add (completion, protocol_name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, protocol_name, + 0, WEECHAT_LIST_POS_SORT); /* UNIX domain socket */ snprintf (protocol_name, sizeof (protocol_name), "unix.irc.%s", weechat_infolist_string (infolist, "name")); - weechat_hook_completion_list_add (completion, protocol_name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, protocol_name, + 0, WEECHAT_LIST_POS_SORT); snprintf (protocol_name, sizeof (protocol_name), "unix.ssl.irc.%s", weechat_infolist_string (infolist, "name")); - weechat_hook_completion_list_add (completion, protocol_name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, protocol_name, + 0, WEECHAT_LIST_POS_SORT); } weechat_infolist_free (infolist); } /* TCP socket */ - weechat_hook_completion_list_add (completion, "weechat", - 0, WEECHAT_LIST_POS_SORT); - weechat_hook_completion_list_add (completion, "ssl.weechat", - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, "weechat", + 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, "ssl.weechat", + 0, WEECHAT_LIST_POS_SORT); /* UNIX domain socket */ - weechat_hook_completion_list_add (completion, "unix.weechat", - 0, WEECHAT_LIST_POS_SORT); - weechat_hook_completion_list_add (completion, "unix.ssl.weechat", - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, "unix.weechat", + 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, "unix.ssl.weechat", + 0, WEECHAT_LIST_POS_SORT); return WEECHAT_RC_OK; } @@ -110,9 +110,9 @@ relay_completion_relays_cb (const void *pointer, void *data, for (ptr_server = relay_servers; ptr_server; ptr_server = ptr_server->next_server) { - weechat_hook_completion_list_add (completion, - ptr_server->protocol_string, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + ptr_server->protocol_string, + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -149,8 +149,8 @@ relay_completion_free_port_cb (const void *pointer, void *data, port_max = 8000 - 1; snprintf (str_port, sizeof (str_port), "%d", port_max + 1); - weechat_hook_completion_list_add (completion, str_port, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, str_port, + 0, WEECHAT_LIST_POS_SORT); return WEECHAT_RC_OK; } diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index 31bbc2103..8813693f3 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -2550,6 +2550,11 @@ weechat_ruby_api_hook_completion (VALUE class, VALUE completion, API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_get_string. + */ + static VALUE weechat_ruby_api_hook_completion_get_string (VALUE class, VALUE completion, VALUE property) @@ -2573,6 +2578,11 @@ weechat_ruby_api_hook_completion_get_string (VALUE class, VALUE completion, API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_list_add. + */ + static VALUE weechat_ruby_api_hook_completion_list_add (VALUE class, VALUE completion, VALUE word, VALUE nick_completion, @@ -5198,6 +5208,60 @@ weechat_ruby_api_completion_search (VALUE class, VALUE completion, VALUE data, } static VALUE +weechat_ruby_api_completion_get_string (VALUE class, VALUE completion, + VALUE property) +{ + char *c_completion, *c_property; + const char *result; + + API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY); + if (NIL_P (completion) || NIL_P (property)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + Check_Type (completion, T_STRING); + Check_Type (property, T_STRING); + + c_completion = StringValuePtr (completion); + c_property = StringValuePtr (property); + + result = weechat_completion_get_string (API_STR2PTR(c_completion), + c_property); + + API_RETURN_STRING(result); +} + +static VALUE +weechat_ruby_api_completion_list_add (VALUE class, VALUE completion, + VALUE word, VALUE nick_completion, + VALUE where) +{ + char *c_completion, *c_word, *c_where; + int c_nick_completion; + + API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR); + if (NIL_P (completion) || NIL_P (word) || NIL_P (nick_completion) + || NIL_P (where)) + API_WRONG_ARGS(API_RETURN_ERROR); + + Check_Type (completion, T_STRING); + Check_Type (word, T_STRING); + CHECK_INTEGER(nick_completion); + Check_Type (where, T_STRING); + + c_completion = StringValuePtr (completion); + c_word = StringValuePtr (word); + c_nick_completion = NUM2INT (nick_completion); + c_where = StringValuePtr (where); + + weechat_completion_list_add (API_STR2PTR(c_completion), + c_word, + c_nick_completion, + c_where); + + API_RETURN_OK; +} + +static VALUE weechat_ruby_api_completion_free (VALUE class, VALUE completion) { char *c_completion; @@ -6488,6 +6552,8 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) API_DEF_FUNC(command_options, 3); API_DEF_FUNC(completion_new, 1); API_DEF_FUNC(completion_search, 4); + API_DEF_FUNC(completion_get_string, 2); + API_DEF_FUNC(completion_list_add, 4); API_DEF_FUNC(completion_free, 1); API_DEF_FUNC(info_get, 2); API_DEF_FUNC(info_get_hashtable, 2); diff --git a/src/plugins/script/script-completion.c b/src/plugins/script/script-completion.c index bfc63cd42..3d23dd2ed 100644 --- a/src/plugins/script/script-completion.c +++ b/src/plugins/script/script-completion.c @@ -49,9 +49,9 @@ script_completion_languages_cb (const void *pointer, void *data, for (i = 0; i < SCRIPT_NUM_LANGUAGES; i++) { - weechat_hook_completion_list_add (completion, - script_language[i], - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + script_language[i], + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -77,9 +77,9 @@ script_completion_extensions_cb (const void *pointer, void *data, for (i = 0; i < SCRIPT_NUM_LANGUAGES; i++) { - weechat_hook_completion_list_add (completion, - script_extension[i], - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + script_extension[i], + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -106,9 +106,9 @@ script_completion_scripts_cb (const void *pointer, void *data, for (ptr_script = scripts_repo; ptr_script; ptr_script = ptr_script->next_script) { - weechat_hook_completion_list_add (completion, - ptr_script->name_with_extension, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + ptr_script->name_with_extension, + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -137,9 +137,9 @@ script_completion_scripts_installed_cb (const void *pointer, void *data, { if (ptr_script->status & SCRIPT_STATUS_INSTALLED) { - weechat_hook_completion_list_add (completion, - ptr_script->name_with_extension, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + ptr_script->name_with_extension, + 0, WEECHAT_LIST_POS_SORT); } } @@ -172,9 +172,9 @@ script_completion_exec_file_cb (void *data, const char *filename) if (filename2) { ptr_base_name = basename (filename2); - weechat_hook_completion_list_add (completion, - ptr_base_name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + ptr_base_name, + 0, WEECHAT_LIST_POS_SORT); free (filename2); } } @@ -271,9 +271,9 @@ script_completion_tags_cb (const void *pointer, void *data, { for (i = 0; i < num_tags; i++) { - weechat_hook_completion_list_add (completion, - list_tags[i], - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + list_tags[i], + 0, WEECHAT_LIST_POS_SORT); } weechat_string_free_split (list_tags); } diff --git a/src/plugins/spell/spell-completion.c b/src/plugins/spell/spell-completion.c index 2d3452095..a2d0c9dcd 100644 --- a/src/plugins/spell/spell-completion.c +++ b/src/plugins/spell/spell-completion.c @@ -48,9 +48,9 @@ spell_completion_langs_cb (const void *pointer, void *data, for (i = 0; spell_langs[i].code; i++) { - weechat_hook_completion_list_add (completion, - spell_langs[i].code, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + spell_langs[i].code, + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -73,8 +73,8 @@ spell_completion_enchant_add_dict_cb (const char *lang_tag, (void) provider_desc; (void) provider_file; - weechat_hook_completion_list_add ((struct t_gui_completion *)user_data, - lang_tag, 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add ((struct t_gui_completion *)user_data, + lang_tag, 0, WEECHAT_LIST_POS_SORT); } #endif /* USE_ENCHANT */ @@ -112,8 +112,8 @@ spell_completion_dicts_cb (const void *pointer, void *data, while ((dict = aspell_dict_info_enumeration_next (elements)) != NULL) { - weechat_hook_completion_list_add (completion, dict->name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, dict->name, + 0, WEECHAT_LIST_POS_SORT); } delete_aspell_dict_info_enumeration (elements); diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index d7df56161..6589a65d0 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -2332,6 +2332,11 @@ API_FUNC(hook_completion) API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_get_string. + */ + API_FUNC(hook_completion_get_string) { Tcl_Obj *objp; @@ -2352,6 +2357,11 @@ API_FUNC(hook_completion_get_string) API_RETURN_STRING(result); } +/* + * This function deprecated since WeeChat 2.9, kept for compatibility. + * It is replaced by completion_list_add. + */ + API_FUNC(hook_completion_list_add) { Tcl_Obj *objp; @@ -4665,6 +4675,51 @@ API_FUNC(completion_search) API_RETURN_INT(rc); } +API_FUNC(completion_get_string) +{ + Tcl_Obj *objp; + char *completion, *property; + const char *result; + int i; + + API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY); + if (objc < 3) + API_WRONG_ARGS(API_RETURN_EMPTY); + + completion = Tcl_GetStringFromObj (objv[1], &i); + property = Tcl_GetStringFromObj (objv[2], &i); + + result = weechat_completion_get_string (API_STR2PTR(completion), + property); + + API_RETURN_STRING(result); +} + +API_FUNC(completion_list_add) +{ + Tcl_Obj *objp; + char *completion, *word, *where; + int i, nick_completion; + + API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR); + if (objc < 5) + API_WRONG_ARGS(API_RETURN_ERROR); + + if (Tcl_GetIntFromObj (interp, objv[3], &nick_completion) != TCL_OK) + API_WRONG_ARGS(API_RETURN_ERROR); + + completion = Tcl_GetStringFromObj (objv[1], &i); + word = Tcl_GetStringFromObj (objv[2], &i); + where = Tcl_GetStringFromObj (objv[4], &i); + + weechat_completion_list_add (API_STR2PTR(completion), + word, + nick_completion, /* nick_completion */ + where); + + API_RETURN_OK; +} + API_FUNC(info_get) { Tcl_Obj *objp; @@ -5823,6 +5878,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp) API_DEF_FUNC(command_options); API_DEF_FUNC(completion_new); API_DEF_FUNC(completion_search); + API_DEF_FUNC(completion_get_string); + API_DEF_FUNC(completion_list_add); API_DEF_FUNC(info_get); API_DEF_FUNC(info_get_hashtable); API_DEF_FUNC(infolist_new); diff --git a/src/plugins/trigger/trigger-completion.c b/src/plugins/trigger/trigger-completion.c index 536a0a502..358f5d4b0 100644 --- a/src/plugins/trigger/trigger-completion.c +++ b/src/plugins/trigger/trigger-completion.c @@ -49,8 +49,8 @@ trigger_completion_triggers_cb (const void *pointer, void *data, for (ptr_trigger = triggers; ptr_trigger; ptr_trigger = ptr_trigger->next_trigger) { - weechat_hook_completion_list_add (completion, ptr_trigger->name, - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, ptr_trigger->name, + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -77,9 +77,9 @@ trigger_completion_triggers_default_cb (const void *pointer, void *data, for (i = 0; trigger_config_default_list[i][0]; i++) { - weechat_hook_completion_list_add (completion, - trigger_config_default_list[i][0], - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + trigger_config_default_list[i][0], + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -105,9 +105,9 @@ trigger_completion_options_cb (const void *pointer, void *data, for (i = 0; i < TRIGGER_NUM_OPTIONS; i++) { - weechat_hook_completion_list_add (completion, - trigger_option_string[i], - 0, WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + trigger_option_string[i], + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -134,7 +134,7 @@ trigger_completion_option_value_cb (const void *pointer, void *data, (void) completion_item; (void) buffer; - args = weechat_hook_completion_get_string (completion, "args"); + args = weechat_completion_get_string (completion, "args"); if (!args) return WEECHAT_RC_OK; @@ -153,20 +153,21 @@ trigger_completion_option_value_cb (const void *pointer, void *data, { if (weechat_strcasecmp (argv[2], "name") == 0) { - weechat_hook_completion_list_add (completion, - ptr_trigger->name, - 0, - WEECHAT_LIST_POS_BEGINNING); + weechat_completion_list_add (completion, + ptr_trigger->name, + 0, + WEECHAT_LIST_POS_BEGINNING); } else { index_option = trigger_search_option (argv[2]); if (index_option >= 0) { - weechat_hook_completion_list_add (completion, - weechat_config_string (ptr_trigger->options[index_option]), - 0, - WEECHAT_LIST_POS_BEGINNING); + weechat_completion_list_add ( + completion, + weechat_config_string (ptr_trigger->options[index_option]), + 0, + WEECHAT_LIST_POS_BEGINNING); } } } @@ -197,9 +198,9 @@ trigger_completion_hooks_cb (const void *pointer, void *data, for (i = 0; i < TRIGGER_NUM_HOOK_TYPES; i++) { - weechat_hook_completion_list_add (completion, - trigger_hook_type_string[i], - 0, WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, + trigger_hook_type_string[i], + 0, WEECHAT_LIST_POS_END); } return WEECHAT_RC_OK; @@ -228,8 +229,8 @@ trigger_completion_hooks_filter_cb (const void *pointer, void *data, { snprintf (str_hook, sizeof (str_hook), "@%s", trigger_hook_type_string[i]); - weechat_hook_completion_list_add (completion, str_hook, - 0, WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, str_hook, + 0, WEECHAT_LIST_POS_END); } return WEECHAT_RC_OK; @@ -252,8 +253,7 @@ trigger_completion_add_quoted_word (struct t_gui_completion *completion, return; snprintf (temp, length, "\"%s\"", word); - weechat_hook_completion_list_add (completion, temp, 0, - WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, temp, 0, WEECHAT_LIST_POS_END); free (temp); } @@ -273,7 +273,7 @@ trigger_completion_add_default_for_hook (struct t_gui_completion *completion, char **argv, **items; int argc, num_items, type, i; - args = weechat_hook_completion_get_string (completion, "args"); + args = weechat_completion_get_string (completion, "args"); if (!args) return; @@ -341,8 +341,7 @@ trigger_completion_hook_arguments_cb (const void *pointer, void *data, trigger_completion_add_default_for_hook (completion, trigger_hook_default_arguments, NULL); - weechat_hook_completion_list_add (completion, "\"\"", 0, - WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, "\"\"", 0, WEECHAT_LIST_POS_END); return WEECHAT_RC_OK; } @@ -363,12 +362,11 @@ trigger_completion_hook_conditions_cb (const void *pointer, void *data, (void) completion_item; (void) buffer; - weechat_hook_completion_list_add (completion, - "\"" TRIGGER_HOOK_DEFAULT_CONDITIONS "\"", - 0, - WEECHAT_LIST_POS_END); - weechat_hook_completion_list_add (completion, "\"\"", 0, - WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, + "\"" TRIGGER_HOOK_DEFAULT_CONDITIONS "\"", + 0, + WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, "\"\"", 0, WEECHAT_LIST_POS_END); return WEECHAT_RC_OK; } @@ -389,12 +387,11 @@ trigger_completion_hook_regex_cb (const void *pointer, void *data, (void) completion_item; (void) buffer; - weechat_hook_completion_list_add (completion, - "\"" TRIGGER_HOOK_DEFAULT_REGEX "\"", - 0, - WEECHAT_LIST_POS_END); - weechat_hook_completion_list_add (completion, "\"\"", 0, - WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, + "\"" TRIGGER_HOOK_DEFAULT_REGEX "\"", + 0, + WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, "\"\"", 0, WEECHAT_LIST_POS_END); return WEECHAT_RC_OK; } @@ -415,12 +412,11 @@ trigger_completion_hook_command_cb (const void *pointer, void *data, (void) completion_item; (void) buffer; - weechat_hook_completion_list_add (completion, - "\"" TRIGGER_HOOK_DEFAULT_COMMAND "\"", - 0, - WEECHAT_LIST_POS_END); - weechat_hook_completion_list_add (completion, "\"\"", 0, - WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, + "\"" TRIGGER_HOOK_DEFAULT_COMMAND "\"", + 0, + WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, "\"\"", 0, WEECHAT_LIST_POS_END); return WEECHAT_RC_OK; } diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index f58705e80..27bcb3456 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -67,7 +67,7 @@ struct timeval; * please change the date with current one; for a second change at same * date, increment the 01, otherwise please keep 01. */ -#define WEECHAT_PLUGIN_API_VERSION "20200428-01" +#define WEECHAT_PLUGIN_API_VERSION "20200508-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -1014,6 +1014,12 @@ struct t_weechat_plugin struct t_gui_buffer *buffer); int (*completion_search) (struct t_gui_completion *completion, const char *data, int position, int direction); + const char *(*completion_get_string) (struct t_gui_completion *completion, + const char *property); + void (*completion_list_add) (struct t_gui_completion *completion, + const char *word, + int nick_completion, + const char *where); void (*completion_free) (struct t_gui_completion *completion); /* network */ @@ -1956,6 +1962,12 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); __direction) \ (weechat_plugin->completion_search)(__completion, __data, \ __position, __direction) +#define weechat_completion_get_string(__completion, __property) \ + (weechat_plugin->completion_get_string)(__completion, __property) +#define weechat_completion_list_add(__completion, __word, \ + __nick_completion, __where) \ + (weechat_plugin->completion_list_add)(__completion, __word, \ + __nick_completion, __where) #define weechat_completion_free(__completion) \ (weechat_plugin->completion_free)(__completion) diff --git a/src/plugins/xfer/xfer-completion.c b/src/plugins/xfer/xfer-completion.c index 23d8955ed..d92a92e6b 100644 --- a/src/plugins/xfer/xfer-completion.c +++ b/src/plugins/xfer/xfer-completion.c @@ -49,15 +49,15 @@ xfer_completion_nick_cb (const void *pointer, void *data, if (ptr_xfer) { /* remote nick */ - weechat_hook_completion_list_add (completion, - ptr_xfer->remote_nick, - 0, - WEECHAT_LIST_POS_SORT); + weechat_completion_list_add (completion, + ptr_xfer->remote_nick, + 0, + WEECHAT_LIST_POS_SORT); /* add self nick at the end */ - weechat_hook_completion_list_add (completion, - ptr_xfer->local_nick, - 1, - WEECHAT_LIST_POS_END); + weechat_completion_list_add (completion, + ptr_xfer->local_nick, + 1, + WEECHAT_LIST_POS_END); } return WEECHAT_RC_OK; |