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

Add function "hook_completion_get_string" in plugin API

This commit is contained in:
Sebastien Helleu
2010-11-09 15:45:14 +01:00
parent 25879ca189
commit 8c129779ac
10 changed files with 224 additions and 6 deletions
+11
View File
@@ -2063,6 +2063,17 @@ hook_completion (struct t_weechat_plugin *plugin, const char *completion_item,
return new_hook;
}
/*
* 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)
*/
+2
View File
@@ -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);
+21
View File
@@ -1161,6 +1161,27 @@ gui_completion_search (struct t_gui_completion *completion, int direction,
free (old_word_found);
}
/*
* 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)
*/
+2
View File
@@ -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 */
+1
View File
@@ -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;
+6 -1
View File
@@ -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, \