core: add function "hook_set" in plugin API, add "subplugin" in hooks (set by script plugins), display subplugin in /help on commands (task #12049)
This commit is contained in:
parent
92aa9bff45
commit
c03fcd5e12
@ -1,12 +1,14 @@
|
||||
WeeChat ChangeLog
|
||||
=================
|
||||
Sébastien Helleu <flashcode@flashtux.org>
|
||||
v0.3.9-dev, 2012-07-07
|
||||
v0.3.9-dev, 2012-07-09
|
||||
|
||||
|
||||
Version 0.3.9 (under dev!)
|
||||
--------------------------
|
||||
|
||||
* core: add function "hook_set" in plugin API, add "subplugin" in hooks (set by
|
||||
script plugins), display subplugin in /help on commands (task #12049)
|
||||
* core: add option weechat.look.jump_smart_back_to_buffer (jump back to initial
|
||||
buffer after reaching end of hotlist, on by default, which is old behaviour)
|
||||
* core: add default key alt+"s" (toggle aspell)
|
||||
|
@ -9079,6 +9079,49 @@ def my_focus_nicklist_cb(data, info):
|
||||
hook = weechat.hook_focus("buffer_nicklist", "my_focus_nicklist_cb", "")
|
||||
----------------------------------------
|
||||
|
||||
weechat_hook_set
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
_New in version 0.3.9._
|
||||
|
||||
Set string value of a hook property.
|
||||
|
||||
Prototype:
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
void weechat_hook_set (struct t_hook *hook, const char *property,
|
||||
const char *value);
|
||||
----------------------------------------
|
||||
|
||||
Arguments:
|
||||
|
||||
* 'hook': something hooked with "weechat_hook_xxx()"
|
||||
* 'property' and 'value': property name, with its value:
|
||||
|
||||
[width="100%",cols="^2,4,8",options="header"]
|
||||
|========================================
|
||||
| Name | Value | Description
|
||||
|
||||
| subplugin | any string |
|
||||
name of sub plugin (commonly script name, which is displayed in
|
||||
`/help command` for a hook of type 'command')
|
||||
|========================================
|
||||
|
||||
C example:
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
struct t_hook *my_command_hook =
|
||||
weechat_hook_command ("abcd", "description",
|
||||
"args", "description args",
|
||||
"", &my_command_cb, NULL);
|
||||
weechat_hook_set (my_command_hook, "subplugin", "test");
|
||||
----------------------------------------
|
||||
|
||||
[NOTE]
|
||||
This function is not available in scripting API.
|
||||
|
||||
weechat_unhook
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -9234,6 +9234,49 @@ def my_focus_nicklist_cb(data, info):
|
||||
hook = weechat.hook_focus("buffer_nicklist", "my_focus_nicklist_cb", "")
|
||||
----------------------------------------
|
||||
|
||||
weechat_hook_set
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
_Nouveau dans la version 0.3.9._
|
||||
|
||||
Affecte une valeur à une propriété d'un hook.
|
||||
|
||||
Prototype :
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
void weechat_hook_set (struct t_hook *hook, const char *property,
|
||||
const char *value);
|
||||
----------------------------------------
|
||||
|
||||
Paramètres :
|
||||
|
||||
* 'hook' : quelque chose d'accroché avec "weechat_hook_xxx()"
|
||||
* 'property' et 'value' : nom de la propriété, avec sa valeur :
|
||||
|
||||
[width="100%",cols="^2,4,8",options="header"]
|
||||
|========================================
|
||||
| Nom | Valeur | Description
|
||||
|
||||
| subplugin | toute chaîne |
|
||||
nom de la sous-extension (couramment un nom de script, qui est affiché dans
|
||||
`/help commande` pour un hook de type 'command')
|
||||
|========================================
|
||||
|
||||
Exemple en C :
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
struct t_hook *my_command_hook =
|
||||
weechat_hook_command ("abcd", "description",
|
||||
"args", "description args",
|
||||
"", &my_command_cb, NULL);
|
||||
weechat_hook_set (my_command_hook, "subplugin", "test");
|
||||
----------------------------------------
|
||||
|
||||
[NOTE]
|
||||
Cette fonction n'est pas disponible dans l'API script.
|
||||
|
||||
weechat_unhook
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -9142,6 +9142,51 @@ def my_focus_nicklist_cb(data, info):
|
||||
hook = weechat.hook_focus("buffer_nicklist", "my_focus_nicklist_cb", "")
|
||||
----------------------------------------
|
||||
|
||||
weechat_hook_set
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
_Novità nella versione 0.3.9._
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Set string value of a hook property.
|
||||
|
||||
Prototipo:
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
void weechat_hook_set (struct t_hook *hook, const char *property,
|
||||
const char *value);
|
||||
----------------------------------------
|
||||
|
||||
Argomenti:
|
||||
|
||||
* 'hook': qualcosa su cui è presente un hook con "weechat_hook_xxx()"
|
||||
* 'property' e 'value': nome della proprietà, con il proprio valore:
|
||||
|
||||
[width="100%",cols="^2,4,8",options="header"]
|
||||
|========================================
|
||||
| Nome | Valore | Descrizione
|
||||
|
||||
| subplugin | qualsiasi stringa |
|
||||
// TRANSLATION MISSING
|
||||
name of sub plugin (commonly script name, which is displayed in
|
||||
`/help command` for a hook of type 'command')
|
||||
|========================================
|
||||
|
||||
Esempio in C:
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
struct t_hook *my_command_hook =
|
||||
weechat_hook_command ("abcd", "description",
|
||||
"args", "description args",
|
||||
"", &my_command_cb, NULL);
|
||||
weechat_hook_set (my_command_hook, "subplugin", "test");
|
||||
----------------------------------------
|
||||
|
||||
[NOTE]
|
||||
Questa funzione non è disponibile nelle API per lo scripting.
|
||||
|
||||
weechat_unhook
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -1926,10 +1926,18 @@ COMMAND_CALLBACK(help)
|
||||
else
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
"%s[%s%s%s] %s/%s %s%s",
|
||||
"%s[%s%s%s%s%s%s%s] %s/%s %s%s",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
plugin_get_name (ptr_hook->plugin),
|
||||
(ptr_hook->subplugin && ptr_hook->subplugin[0]) ?
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
|
||||
(ptr_hook->subplugin && ptr_hook->subplugin[0]) ?
|
||||
"/" : "",
|
||||
(ptr_hook->subplugin && ptr_hook->subplugin[0]) ?
|
||||
GUI_COLOR(GUI_COLOR_CHAT) : "",
|
||||
(ptr_hook->subplugin && ptr_hook->subplugin[0]) ?
|
||||
ptr_hook->subplugin : "",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
|
||||
HOOK_COMMAND(ptr_hook, command),
|
||||
|
@ -309,6 +309,7 @@ hook_init_data (struct t_hook *hook, struct t_weechat_plugin *plugin,
|
||||
int type, int priority, void *callback_data)
|
||||
{
|
||||
hook->plugin = plugin;
|
||||
hook->subplugin = NULL;
|
||||
hook->type = type;
|
||||
hook->deleted = 0;
|
||||
hook->running = 0;
|
||||
@ -3011,6 +3012,21 @@ hook_focus_get_data (struct t_hashtable *hashtable_focus1,
|
||||
return hashtable1;
|
||||
}
|
||||
|
||||
/*
|
||||
* hook_set: set a hook property (string)
|
||||
*/
|
||||
|
||||
void
|
||||
hook_set (struct t_hook *hook, const char *property, const char *value)
|
||||
{
|
||||
if (string_strcasecmp (property, "subplugin") == 0)
|
||||
{
|
||||
if (hook->subplugin)
|
||||
free(hook->subplugin);
|
||||
hook->subplugin = strdup (value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* unhook: unhook something
|
||||
*/
|
||||
@ -3037,6 +3053,8 @@ unhook (struct t_hook *hook)
|
||||
}
|
||||
|
||||
/* free data */
|
||||
if (hook->subplugin)
|
||||
free (hook->subplugin);
|
||||
if (hook->hook_data)
|
||||
{
|
||||
switch (hook->type)
|
||||
@ -3327,6 +3345,8 @@ hook_add_to_infolist_type (struct t_infolist *infolist, int type,
|
||||
(ptr_hook->plugin) ?
|
||||
ptr_hook->plugin->name : NULL))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "subplugin", ptr_hook->subplugin))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "type", hook_type_string[ptr_hook->type]))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "deleted", ptr_hook->deleted))
|
||||
@ -3744,11 +3764,12 @@ hook_print_log ()
|
||||
log_printf ("[hook (addr:0x%lx)]", ptr_hook);
|
||||
log_printf (" plugin. . . . . . . . . : 0x%lx ('%s')",
|
||||
ptr_hook->plugin, plugin_get_name (ptr_hook->plugin));
|
||||
log_printf (" subplugin . . . . . . . : '%s'", ptr_hook->subplugin);
|
||||
log_printf (" type. . . . . . . . . . : %d (%s)",
|
||||
ptr_hook->type, hook_type_string[ptr_hook->type]);
|
||||
log_printf (" deleted . . . . . . . . : %d", ptr_hook->deleted);
|
||||
log_printf (" running . . . . . . . . : %d", ptr_hook->running);
|
||||
log_printf (" priority. . . . . . . . : %d", ptr_hook->priority);
|
||||
log_printf (" type. . . . . . . . . . : %d (%s)",
|
||||
ptr_hook->type, hook_type_string[ptr_hook->type]);
|
||||
log_printf (" callback_data . . . . . : 0x%lx", ptr_hook->callback_data);
|
||||
switch (ptr_hook->type)
|
||||
{
|
||||
|
@ -103,6 +103,10 @@ struct t_hook
|
||||
/* data common to all hooks */
|
||||
struct t_weechat_plugin *plugin; /* plugin which created this hook */
|
||||
/* (NULL for hook created by WeeChat)*/
|
||||
char *subplugin; /* subplugin which created this hook */
|
||||
/* (commonly a script name, NULL for */
|
||||
/* hook created by WeeChat or by */
|
||||
/* plugin itself) */
|
||||
enum t_hook_type type; /* hook type */
|
||||
int deleted; /* hook marked for deletion ? */
|
||||
int running; /* 1 if hook is currently running */
|
||||
@ -562,6 +566,8 @@ extern struct t_hook *hook_focus (struct t_weechat_plugin *plugin,
|
||||
void *callback_data);
|
||||
extern struct t_hashtable *hook_focus_get_data (struct t_hashtable *hashtable_focus1,
|
||||
struct t_hashtable *hashtable_focus2);
|
||||
extern void hook_set (struct t_hook *hook, const char *property,
|
||||
const char *value);
|
||||
extern void unhook (struct t_hook *hook);
|
||||
extern void unhook_all_plugin (struct t_weechat_plugin *plugin);
|
||||
extern void unhook_all ();
|
||||
|
@ -654,6 +654,7 @@ plugin_load (const char *filename, int argc, char **argv)
|
||||
new_plugin->hook_infolist = &hook_infolist;
|
||||
new_plugin->hook_hdata = &hook_hdata;
|
||||
new_plugin->hook_focus = &hook_focus;
|
||||
new_plugin->hook_set = &hook_set;
|
||||
new_plugin->unhook = &unhook;
|
||||
new_plugin->unhook_all = &unhook_all_plugin;
|
||||
|
||||
|
@ -734,6 +734,7 @@ script_api_hook_command (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -773,6 +774,7 @@ script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -811,6 +813,7 @@ script_api_hook_timer (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -849,6 +852,7 @@ script_api_hook_fd (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -895,6 +899,7 @@ script_api_hook_process_hashtable (struct t_weechat_plugin *weechat_plugin,
|
||||
script_callback_remove (script, new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
new_script_callback->hook = new_hook;
|
||||
|
||||
@ -961,6 +966,7 @@ script_api_hook_connect (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -1005,6 +1011,7 @@ script_api_hook_print (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -1043,6 +1050,7 @@ script_api_hook_signal (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -1080,6 +1088,7 @@ script_api_hook_hsignal (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -1117,6 +1126,7 @@ script_api_hook_config (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -1158,6 +1168,7 @@ script_api_hook_completion (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -1196,6 +1207,7 @@ script_api_hook_modifier (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -1237,6 +1249,7 @@ script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -1281,6 +1294,7 @@ script_api_hook_info_hashtable (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -1325,6 +1339,7 @@ script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
@ -1362,6 +1377,7 @@ script_api_hook_focus (struct t_weechat_plugin *weechat_plugin,
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
|
@ -46,7 +46,7 @@ struct timeval;
|
||||
*/
|
||||
|
||||
/* API version (used to check that plugin has same API and can be loaded) */
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20120323-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20120709-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@ -647,6 +647,8 @@ struct t_weechat_plugin
|
||||
struct t_hashtable *(*callback)(void *data,
|
||||
struct t_hashtable *info),
|
||||
void *callback_data);
|
||||
void (*hook_set) (struct t_hook *hook, const char *property,
|
||||
const char *value);
|
||||
void (*unhook) (struct t_hook *hook);
|
||||
void (*unhook_all) (struct t_weechat_plugin *plugin);
|
||||
|
||||
@ -1381,6 +1383,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
#define weechat_hook_focus(__area, __callback, __data) \
|
||||
weechat_plugin->hook_focus(weechat_plugin, __area, __callback, \
|
||||
__data)
|
||||
#define weechat_hook_set(__hook, __property, __value) \
|
||||
weechat_plugin->hook_set(__hook, __property, __value)
|
||||
#define weechat_unhook(__hook) \
|
||||
weechat_plugin->unhook( __hook)
|
||||
#define weechat_unhook_all() \
|
||||
|
Loading…
x
Reference in New Issue
Block a user