diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-11-09 15:45:14 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-11-09 15:45:14 +0100 |
commit | 8c129779acf613fb1c23a6345eb64d745ef7e2f4 (patch) | |
tree | e969794a729ca30328644b360201b82bf6079cb4 | |
parent | 25879ca18965d8b2a6e9f5de290cf1bc5eb82ae6 (diff) | |
download | weechat-8c129779acf613fb1c23a6345eb64d745ef7e2f4.zip |
Add function "hook_completion_get_string" in plugin API
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | doc/en/weechat_plugin_api.en.txt | 58 | ||||
-rw-r--r-- | doc/fr/weechat_plugin_api.fr.txt | 60 | ||||
-rw-r--r-- | doc/it/weechat_plugin_api.it.txt | 59 | ||||
-rw-r--r-- | src/core/wee-hook.c | 11 | ||||
-rw-r--r-- | src/core/wee-hook.h | 2 | ||||
-rw-r--r-- | src/gui/gui-completion.c | 21 | ||||
-rw-r--r-- | src/gui/gui-completion.h | 2 | ||||
-rw-r--r-- | src/plugins/plugin.c | 1 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 7 |
10 files changed, 224 insertions, 6 deletions
@@ -1,7 +1,7 @@ WeeChat ChangeLog ================= Sébastien Helleu <flashcode@flashtux.org> -v0.3.4-dev, 2010-11-08 +v0.3.4-dev, 2010-11-09 Version 0.3.4 (under dev!) @@ -26,9 +26,10 @@ Version 0.3.4 (under dev!) * api: add priority for hooks (task #10550) * api: add new functions: hashtable_get_string, hook_info_hashtable, info_get_hashtable, hook_hsignal, hook_hsignal_send, - nicklist_group_get_integer, nicklist_group_get_string, - nicklist_group_get_pointer, nicklist_group_set, nicklist_nick_get_integer, - nicklist_nick_get_string, nicklist_nick_get_pointer, nicklist_nick_set + hook_completion_get_string, nicklist_group_get_integer, + nicklist_group_get_string, nicklist_group_get_pointer, nicklist_group_set, + nicklist_nick_get_integer, nicklist_nick_get_string, nicklist_nick_get_pointer, + nicklist_nick_set * irc: add command /notify, new options irc.look.notify_tags_ison, irc.look.notify_tags_whois, irc.network.notify_check_ison, irc.network.notify_check_whois, new option "notify" in servers, new infolist diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index d9f657df4..1f19900d5 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -7342,6 +7342,64 @@ hook = weechat.hook_completion("plugin_item", "my custom completion!", "my_completion_cb", "") ---------------------------------------- +weechat_hook_completion_get_string +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +_New in version 0.3.4._ + +Get a completion property as string. + +Prototype: + +[source,C] +---------------------------------------- +const char *weechat_hook_completion_get_string (struct t_gui_completion *completion, + const char *property); +---------------------------------------- + +Arguments: + +* 'completion': completion pointer +* 'property': property name: +** 'base_command': command used for completion +** 'base_word': word being completed +** 'args': command arguments (including base word) + +C example: + +[source,C] +---------------------------------------- +int +my_completion_cb (void *data, const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) +{ + /* get arguments of command */ + const char *args = weechat_hook_completion_get_string (completion, "args"); + + /* completion depending on args */ + /* ... */ + + return WEECHAT_RC_OK; +} +---------------------------------------- + +Script (Python): + +[source,python] +---------------------------------------- +# prototype +value = weechat.hook_completion_get_string(completion, property) + +# example +def my_completion_cb(data, completion_item, buffer, completion): + # get arguments of command + args = weechat.hook_completion_get_string(completion, "args") + # completion depending on args + # ... + return weechat.WEECHAT_RC_OK +---------------------------------------- + weechat_hook_completion_list_add ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt index 8404a24d2..3241d1b50 100644 --- a/doc/fr/weechat_plugin_api.fr.txt +++ b/doc/fr/weechat_plugin_api.fr.txt @@ -7449,6 +7449,64 @@ hook = weechat.hook_completion("extension_item", "ma complétion !", "my_completion_cb", "") ---------------------------------------- +weechat_hook_completion_get_string +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +_Nouveau dans la version 0.3.4._ + +Retourne la valeur d'une propriété de la complétion sous forme de chaîne. + +Prototype : + +[source,C] +---------------------------------------- +const char *weechat_hook_completion_get_string (struct t_gui_completion *completion, + const char *property); +---------------------------------------- + +Paramètres : + +* 'completion' : pointeur vers la complétion +* 'property' : nom de la propriété : +** 'base_command' : commande utilisée pour la complétion +** 'base_word' : le mot qui va être complété +** 'args' : paramètres de la commande (incluant le mot de base "base_word") + +Exemple en C : + +[source,C] +---------------------------------------- +int +my_completion_cb (void *data, const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) +{ + /* récupère les paramètres de la commande */ + const char *args = weechat_hook_completion_get_string (completion, "args"); + + /* complétion selon les paramètres */ + /* ... */ + + return WEECHAT_RC_OK; +} +---------------------------------------- + +Script (Python): + +[source,python] +---------------------------------------- +# prototype +value = weechat.hook_completion_get_string(completion, property) + +# exemple +def my_completion_cb(data, completion_item, buffer, completion): + # récupère les paramètres de la commande + args = weechat.hook_completion_get_string(completion, "args") + # complétion selon les paramètres + # ... + return weechat.WEECHAT_RC_OK +---------------------------------------- + weechat_hook_completion_list_add ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8419,7 +8477,7 @@ weechat.prnt("", "mon numéro de tampon est : %d" % weechat.buffer_get_integer(m weechat_buffer_get_string ^^^^^^^^^^^^^^^^^^^^^^^^^ -Retourne la valeur d'une propriété sous forme de chaîne. +Retourne la valeur d'une propriété du tampon sous forme de chaîne. Prototype : diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt index 07e631548..3457f9667 100644 --- a/doc/it/weechat_plugin_api.it.txt +++ b/doc/it/weechat_plugin_api.it.txt @@ -7412,6 +7412,65 @@ hook = weechat.hook_completion("plugin_item", "my custom completion!", "my_completion_cb", "") ---------------------------------------- +// TRANSLATION MISSING +weechat_hook_completion_get_string +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +_New in version 0.3.4._ + +Get a completion property as string. + +Prototype: + +[source,C] +---------------------------------------- +const char *weechat_hook_completion_get_string (struct t_gui_completion *completion, + const char *property); +---------------------------------------- + +Arguments: + +* 'completion': completion pointer +* 'property': property name: +** 'base_command': command used for completion +** 'base_word': word being completed +** 'args': command arguments (including base word) + +C example: + +[source,C] +---------------------------------------- +int +my_completion_cb (void *data, const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) +{ + /* get arguments of command */ + const char *args = weechat_hook_completion_get_string (completion, "args"); + + /* completion depending on args */ + /* ... */ + + return WEECHAT_RC_OK; +} +---------------------------------------- + +Script (Python): + +[source,python] +---------------------------------------- +# prototype +value = weechat.hook_completion_get_string(completion, property) + +# example +def my_completion_cb(data, completion_item, buffer, completion): + # get arguments of command + args = weechat.hook_completion_get_string(completion, "args") + # completion depending on args + # ... + return weechat.WEECHAT_RC_OK +---------------------------------------- + weechat_hook_completion_list_add ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index dc0726231..5ed947f7e 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -2064,6 +2064,17 @@ hook_completion (struct t_weechat_plugin *plugin, const char *completion_item, } /* + * hook_completion_get_string: get 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); +} + +/* * hook_completion_list_add: add a word for a completion (called by plugins) */ diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h index c849b36af..45a5ed34c 100644 --- a/src/core/wee-hook.h +++ b/src/core/wee-hook.h @@ -439,6 +439,8 @@ extern struct t_hook *hook_completion (struct t_weechat_plugin *plugin, const char *description, t_hook_callback_completion *callback, 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); diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c index 02a7745b4..4b8f4c9e9 100644 --- a/src/gui/gui-completion.c +++ b/src/gui/gui-completion.c @@ -1162,6 +1162,27 @@ gui_completion_search (struct t_gui_completion *completion, int direction, } /* + * gui_completion_get_string: get a completion property as string + */ + +const char * +gui_completion_get_string (struct t_gui_completion *completion, + const char *property) +{ + if (completion) + { + if (string_strcasecmp (property, "base_command") == 0) + return completion->base_command; + else if (string_strcasecmp (property, "base_word") == 0) + return completion->base_word; + else if (string_strcasecmp (property, "args") == 0) + return completion->args; + } + + return NULL; +} + +/* * gui_completion_print_log: print completion list in log (usually for crash dump) */ diff --git a/src/gui/gui-completion.h b/src/gui/gui-completion.h index de0433997..f3bf2f44a 100644 --- a/src/gui/gui-completion.h +++ b/src/gui/gui-completion.h @@ -76,6 +76,8 @@ extern void gui_completion_list_add (struct t_gui_completion *completion, extern void gui_completion_search (struct t_gui_completion *completion, int direction, const char *data, int size, int pos); +extern const char *gui_completion_get_string (struct t_gui_completion *completion, + const char *property); extern void gui_completion_print_log (struct t_gui_completion *completion); #endif /* __WEECHAT_GUI_COMPLETION_H */ diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 57985c492..3c8070366 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -592,6 +592,7 @@ plugin_load (const char *filename) 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_modifier = &hook_modifier; new_plugin->hook_modifier_exec = &hook_modifier_exec; diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 3ae2cf881..c998c3b84 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -45,7 +45,7 @@ struct timeval; */ /* API version (used to check that plugin has same API and can be loaded) */ -#define WEECHAT_PLUGIN_API_VERSION "20101029-01" +#define WEECHAT_PLUGIN_API_VERSION "20101109-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -509,6 +509,8 @@ struct t_weechat_plugin struct t_gui_buffer *buffer, struct t_gui_completion *completion), void *callback_data); + const char *(*hook_completion_get_string) (struct t_gui_completion *completion, + const char *property); void (*hook_completion_list_add) (struct t_gui_completion *completion, const char *word, int nick_completion, @@ -1156,6 +1158,9 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); __callback, __data) \ weechat_plugin->hook_completion(weechat_plugin, __completion, \ __description, __callback, __data) +#define weechat_hook_completion_get_string(__completion, __property) \ + weechat_plugin->hook_completion_get_string(__completion, \ + __property) #define weechat_hook_completion_list_add(__completion, __word, \ __nick_completion, __where) \ weechat_plugin->hook_completion_list_add(__completion, __word, \ |