1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 21:06:38 +02:00

Add description for info and infolist hooks

This commit is contained in:
Sebastien Helleu
2008-09-02 17:02:59 +02:00
parent e756f4770a
commit e7dcf13764
24 changed files with 970 additions and 227 deletions
+2 -1
View File
@@ -89,5 +89,6 @@ void
alias_info_init ()
{
/* alias infolist hooks */
weechat_hook_infolist ("alias", &alias_info_get_infolist_cb, NULL);
weechat_hook_infolist ("alias", N_("list of alias"),
&alias_info_get_infolist_cb, NULL);
}
+2 -1
View File
@@ -53,5 +53,6 @@ void
fifo_info_init ()
{
/* fifo info hooks */
weechat_hook_info ("fifo_filename", &fifo_info_get_info_cb, NULL);
weechat_hook_info ("fifo_filename", N_("fifo filename"),
&fifo_info_get_info_cb, NULL);
}
+12 -6
View File
@@ -326,12 +326,18 @@ void
irc_info_init ()
{
/* irc info hooks */
weechat_hook_info ("irc_is_channel", &irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_nick_from_host", &irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_buffer", &irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_is_channel", N_("1 if string is an IRC channel"),
&irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_nick_from_host", N_("get nick from IRC host"),
&irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_buffer", N_("get buffer pointer for an IRC server/channel"),
&irc_info_get_info_cb, NULL);
/* irc infolist hooks */
weechat_hook_infolist ("irc_server", &irc_info_get_infolist_cb, NULL);
weechat_hook_infolist ("irc_channel", &irc_info_get_infolist_cb, NULL);
weechat_hook_infolist ("irc_nick", &irc_info_get_infolist_cb, NULL);
weechat_hook_infolist ("irc_server", N_("list of IRC servers"),
&irc_info_get_infolist_cb, NULL);
weechat_hook_infolist ("irc_channel", N_("list of channels for an IRC server"),
&irc_info_get_infolist_cb, NULL);
weechat_hook_infolist ("irc_nick", N_("list of nicks for an IRC channel"),
&irc_info_get_infolist_cb, NULL);
}
+2 -1
View File
@@ -92,5 +92,6 @@ void
logger_info_init ()
{
/* irc infolist hooks */
weechat_hook_infolist ("logger_buffer", &logger_info_get_infolist_cb, NULL);
weechat_hook_infolist ("logger_buffer", N_("list of logger buffers"),
&logger_info_get_infolist_cb, NULL);
}
+36 -19
View File
@@ -675,25 +675,42 @@ void
plugin_api_init ()
{
/* WeeChat core info hooks */
hook_info (NULL, "version", &plugin_api_info_get_internal, NULL);
hook_info (NULL, "date", &plugin_api_info_get_internal, NULL);
hook_info (NULL, "dir_separator", &plugin_api_info_get_internal, NULL);
hook_info (NULL, "weechat_dir", &plugin_api_info_get_internal, NULL);
hook_info (NULL, "weechat_libdir", &plugin_api_info_get_internal, NULL);
hook_info (NULL, "weechat_sharedir", &plugin_api_info_get_internal, NULL);
hook_info (NULL, "weechat_localedir", &plugin_api_info_get_internal, NULL);
hook_info (NULL, "charset_terminal", &plugin_api_info_get_internal, NULL);
hook_info (NULL, "charset_internal", &plugin_api_info_get_internal, NULL);
hook_info (NULL, "inactivity", &plugin_api_info_get_internal, NULL);
hook_info (NULL, "filters_enabled", &plugin_api_info_get_internal, NULL);
hook_info (NULL, "version", N_("WeeChat version"),
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "date", N_("WeeChat compilation date"),
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "dir_separator", N_("directory separator"),
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "weechat_dir", N_("WeeChat directory"),
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "weechat_libdir", N_("WeeChat \"lib\" directory"),
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "weechat_sharedir", N_("WeeChat \"share\" directory"),
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "weechat_localedir", N_("WeeChat \"locale\" directory"),
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "charset_terminal", N_("terminal charset"),
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "charset_internal", N_("WeeChat internal charset"),
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "inactivity", N_("keyboard inactivity (seconds)"),
&plugin_api_info_get_internal, NULL);
hook_info (NULL, "filters_enabled", N_("1 if filters are enabled"),
&plugin_api_info_get_internal, NULL);
/* WeeChat core infolist hooks */
hook_infolist (NULL, "buffer", &plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "buffer_lines", &plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "buffer", &plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "nicklist", &plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "window", &plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "hotlist", &plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "option", &plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "hook", &plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "buffer", N_("list of buffers"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "buffer_lines", N_("lines of a buffer"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "nicklist", N_("nicks in nicklist for a buffer"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "window", N_("list of windows"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "hotlist", N_("list of buffers in hotlist"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "option", N_("list of options"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "hook", N_("list of hooks"),
&plugin_api_infolist_get_internal, NULL);
}
+10 -6
View File
@@ -3105,7 +3105,7 @@ weechat_lua_api_hook_info_cb (void *data, const char *info_name,
static int
weechat_lua_api_hook_info (lua_State *L)
{
const char *info_name, *function;
const char *info_name, *description, *function;
char *result;
int n;
@@ -3123,18 +3123,20 @@ weechat_lua_api_hook_info (lua_State *L)
n = lua_gettop (lua_current_interpreter);
if (n < 2)
if (n < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info");
LUA_RETURN_EMPTY;
}
info_name = lua_tostring (lua_current_interpreter, -2);
info_name = 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_info (weechat_lua_plugin,
lua_current_script,
info_name,
description,
&weechat_lua_api_hook_info_cb,
function));
@@ -3178,7 +3180,7 @@ weechat_lua_api_hook_infolist_cb (void *data, const char *info_name,
static int
weechat_lua_api_hook_infolist (lua_State *L)
{
const char *infolist_name, *function;
const char *infolist_name, *description, *function;
char *result;
int n;
@@ -3196,18 +3198,20 @@ weechat_lua_api_hook_infolist (lua_State *L)
n = lua_gettop (lua_current_interpreter);
if (n < 2)
if (n < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist");
LUA_RETURN_EMPTY;
}
infolist_name = lua_tostring (lua_current_interpreter, -2);
infolist_name = 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_infolist (weechat_lua_plugin,
lua_current_script,
infolist_name,
description,
&weechat_lua_api_hook_infolist_cb,
function));
+10 -6
View File
@@ -2597,7 +2597,7 @@ weechat_perl_api_hook_info_cb (void *data, const char *info_name,
static XS (XS_weechat_hook_info)
{
char *result, *info_name, *perl_fn;
char *result, *info_name, *description, *perl_fn;
dXSARGS;
/* make C compiler happy */
@@ -2609,17 +2609,19 @@ static XS (XS_weechat_hook_info)
PERL_RETURN_EMPTY;
}
if (items < 2)
if (items < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info");
PERL_RETURN_EMPTY;
}
info_name = SvPV (ST (0), PL_na);
perl_fn = SvPV (ST (1), PL_na);
description = SvPV (ST (1), PL_na);
perl_fn = SvPV (ST (2), PL_na);
result = script_ptr2str (script_api_hook_info (weechat_perl_plugin,
perl_current_script,
info_name,
description,
&weechat_perl_api_hook_info_cb,
perl_fn));
@@ -2662,7 +2664,7 @@ weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name,
static XS (XS_weechat_hook_infolist)
{
char *result, *infolist_name, *perl_fn;
char *result, *infolist_name, *description, *perl_fn;
dXSARGS;
/* make C compiler happy */
@@ -2674,17 +2676,19 @@ static XS (XS_weechat_hook_infolist)
PERL_RETURN_EMPTY;
}
if (items < 2)
if (items < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist");
PERL_RETURN_EMPTY;
}
infolist_name = SvPV (ST (0), PL_na);
perl_fn = SvPV (ST (1), PL_na);
description = SvPV (ST (1), PL_na);
perl_fn = SvPV (ST (2), PL_na);
result = script_ptr2str (script_api_hook_infolist (weechat_perl_plugin,
perl_current_script,
infolist_name,
description,
&weechat_perl_api_hook_infolist_cb,
perl_fn));
@@ -2754,7 +2754,7 @@ weechat_python_api_hook_info_cb (void *data, const char *info_name,
static PyObject *
weechat_python_api_hook_info (PyObject *self, PyObject *args)
{
char *info_name, *function, *result;
char *info_name, *description, *function, *result;
PyObject *object;
/* make C compiler happy */
@@ -2767,9 +2767,10 @@ weechat_python_api_hook_info (PyObject *self, PyObject *args)
}
info_name = NULL;
description = NULL;
function = NULL;
if (!PyArg_ParseTuple (args, "ss", &info_name, &function))
if (!PyArg_ParseTuple (args, "sss", &info_name, &description, &function))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info");
PYTHON_RETURN_EMPTY;
@@ -2778,6 +2779,7 @@ weechat_python_api_hook_info (PyObject *self, PyObject *args)
result = script_ptr2str(script_api_hook_info (weechat_python_plugin,
python_current_script,
info_name,
description,
&weechat_python_api_hook_info_cb,
function));
@@ -2821,7 +2823,7 @@ weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name,
static PyObject *
weechat_python_api_hook_infolist (PyObject *self, PyObject *args)
{
char *infolist_name, *function, *result;
char *infolist_name, *description, *function, *result;
PyObject *object;
/* make C compiler happy */
@@ -2834,9 +2836,10 @@ weechat_python_api_hook_infolist (PyObject *self, PyObject *args)
}
infolist_name = NULL;
description = NULL;
function = NULL;
if (!PyArg_ParseTuple (args, "ss", &infolist_name, &function))
if (!PyArg_ParseTuple (args, "sss", &infolist_name, &description, &function))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist");
PYTHON_RETURN_EMPTY;
@@ -2845,6 +2848,7 @@ weechat_python_api_hook_infolist (PyObject *self, PyObject *args)
result = script_ptr2str(script_api_hook_infolist (weechat_python_plugin,
python_current_script,
infolist_name,
description,
&weechat_python_api_hook_infolist_cb,
function));
+18 -8
View File
@@ -3162,9 +3162,10 @@ weechat_ruby_api_hook_info_cb (void *data, const char *info_name,
*/
static VALUE
weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE function)
weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE description,
VALUE function)
{
char *c_info_name, *c_function, *result;
char *c_info_name, *c_description, *c_function, *result;
VALUE return_value;
/* make C compiler happy */
@@ -3177,23 +3178,27 @@ weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE function)
}
c_info_name = NULL;
c_description = NULL;
c_function = NULL;
if (NIL_P (info_name) || NIL_P (function))
if (NIL_P (info_name) || NIL_P (description) || NIL_P (function))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info");
RUBY_RETURN_EMPTY;
}
Check_Type (info_name, T_STRING);
Check_Type (description, T_STRING);
Check_Type (function, T_STRING);
c_info_name = STR2CSTR (info_name);
c_description = STR2CSTR (description);
c_function = STR2CSTR (function);
result = script_ptr2str (script_api_hook_info (weechat_ruby_plugin,
ruby_current_script,
c_info_name,
c_description,
&weechat_ruby_api_hook_info_cb,
c_function));
@@ -3235,9 +3240,10 @@ weechat_ruby_api_hook_infolist_cb (void *data, const char *infolist_name,
*/
static VALUE
weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, VALUE function)
weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name,
VALUE description, VALUE function)
{
char *c_infolist_name, *c_function, *result;
char *c_infolist_name, *c_description, *c_function, *result;
VALUE return_value;
/* make C compiler happy */
@@ -3250,23 +3256,27 @@ weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, VALUE function
}
c_infolist_name = NULL;
c_description = NULL;
c_function = NULL;
if (NIL_P (infolist_name) || NIL_P (function))
if (NIL_P (infolist_name) || NIL_P (description) || NIL_P (function))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist");
RUBY_RETURN_EMPTY;
}
Check_Type (infolist_name, T_STRING);
Check_Type (description, T_STRING);
Check_Type (function, T_STRING);
c_infolist_name = STR2CSTR (infolist_name);
c_description = STR2CSTR (description);
c_function = STR2CSTR (function);
result = script_ptr2str (script_api_hook_infolist (weechat_ruby_plugin,
ruby_current_script,
c_infolist_name,
c_description,
&weechat_ruby_api_hook_infolist_cb,
c_function));
@@ -4964,8 +4974,8 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
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);
rb_define_module_function (ruby_mWeechat, "hook_info", &weechat_ruby_api_hook_info, 2);
rb_define_module_function (ruby_mWeechat, "hook_infolist", &weechat_ruby_api_hook_infolist, 2);
rb_define_module_function (ruby_mWeechat, "hook_info", &weechat_ruby_api_hook_info, 3);
rb_define_module_function (ruby_mWeechat, "hook_infolist", &weechat_ruby_api_hook_infolist, 3);
rb_define_module_function (ruby_mWeechat, "unhook", &weechat_ruby_api_unhook, 1);
rb_define_module_function (ruby_mWeechat, "unhook_all", &weechat_ruby_api_unhook_all, 0);
rb_define_module_function (ruby_mWeechat, "buffer_new", &weechat_ruby_api_buffer_new, 4);
+5 -2
View File
@@ -884,6 +884,7 @@ struct t_hook *
script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *info_name,
const char *description,
char *(*callback)(void *data,
const char *info_name,
const char *arguments),
@@ -896,7 +897,8 @@ script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
if (!new_script_callback)
return NULL;
new_hook = weechat_hook_info (info_name, callback, new_script_callback);
new_hook = weechat_hook_info (info_name, description,
callback, new_script_callback);
if (!new_hook)
{
script_callback_free_data (new_script_callback);
@@ -922,6 +924,7 @@ struct t_hook *
script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *infolist_name,
const char *description,
struct t_infolist *(*callback)(void *data,
const char *infolist_name,
void *pointer,
@@ -935,7 +938,7 @@ script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
if (!new_script_callback)
return NULL;
new_hook = weechat_hook_infolist (infolist_name,
new_hook = weechat_hook_infolist (infolist_name, description,
callback, new_script_callback);
if (!new_hook)
{
+2
View File
@@ -153,6 +153,7 @@ extern struct t_hook *script_api_hook_modifier (struct t_weechat_plugin *weechat
extern struct t_hook *script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *info_name,
const char *description,
char *(*callback)(void *data,
const char *info_name,
const char *arguments),
@@ -160,6 +161,7 @@ extern struct t_hook *script_api_hook_info (struct t_weechat_plugin *weechat_plu
extern struct t_hook *script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *infolist_name,
const char *description,
struct t_infolist *(*callback)(void *data,
const char *infolist_name,
void *pointer,
+8 -4
View File
@@ -370,12 +370,14 @@ struct t_weechat_plugin
const char *string);
struct t_hook *(*hook_info) (struct t_weechat_plugin *plugin,
const char *info_name,
const char *description,
char *(*callback)(void *data,
const char *info_name,
const char *arguments),
void *callback_data);
struct t_hook *(*hook_infolist) (struct t_weechat_plugin *plugin,
const char *infolist_name,
const char *description,
struct t_infolist *(*callback)(void *data,
const char *infolist_name,
void *pointer,
@@ -836,12 +838,14 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
__string) \
weechat_plugin->hook_modifier_exec(weechat_plugin, __modifier, \
__modifier_data, __string)
#define weechat_hook_info(__info_name, __callback, __data) \
#define weechat_hook_info(__info_name, __description, __callback, \
__data) \
weechat_plugin->hook_info(weechat_plugin, __info_name, \
__callback, __data)
#define weechat_hook_infolist(__infolist_name, __callback, __data) \
__description, __callback, __data)
#define weechat_hook_infolist(__infolist_name, __description, \
__callback, __data) \
weechat_plugin->hook_infolist(weechat_plugin, __infolist_name, \
__callback, __data)
__description, __callback, __data)
#define weechat_unhook(__hook) \
weechat_plugin->unhook( __hook)
#define weechat_unhook_all() \
+2 -1
View File
@@ -90,5 +90,6 @@ void
xfer_info_init ()
{
/* xfer infolist hooks */
weechat_hook_infolist ("xfer", &xfer_info_get_infolist_cb, NULL);
weechat_hook_infolist ("xfer", N_("list of xfer"),
&xfer_info_get_infolist_cb, NULL);
}