1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-02 15:53:12 +02:00

scripts: add hdata with list of scripts for each language

This commit is contained in:
Sebastien Helleu
2012-08-03 12:13:21 +02:00
parent 746ca9623d
commit b501fd1b24
13 changed files with 550 additions and 2 deletions
+16
View File
@@ -656,6 +656,21 @@ weechat_guile_completion_cb (void *data, const char *completion_item,
return WEECHAT_RC_OK;
}
/*
* weechat_guile_hdata_cb: callback for hdata
*/
struct t_hdata *
weechat_guile_hdata_cb (void *data, const char *hdata_name)
{
/* make C compiler happy */
(void) data;
return plugin_script_hdata_script (weechat_plugin,
&guile_scripts, &last_guile_script,
hdata_name);
}
/*
* weechat_guile_infolist_cb: callback for infolist
*/
@@ -870,6 +885,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
init.callback_command = &weechat_guile_command_cb;
init.callback_completion = &weechat_guile_completion_cb;
init.callback_hdata = &weechat_guile_hdata_cb;
init.callback_infolist = &weechat_guile_infolist_cb;
init.callback_signal_debug_dump = &weechat_guile_signal_debug_dump_cb;
init.callback_signal_buffer_closed = &weechat_guile_signal_buffer_closed_cb;
+16
View File
@@ -615,6 +615,21 @@ weechat_lua_completion_cb (void *data, const char *completion_item,
return WEECHAT_RC_OK;
}
/*
* weechat_lua_hdata_cb: callback for hdata
*/
struct t_hdata *
weechat_lua_hdata_cb (void *data, const char *hdata_name)
{
/* make C compiler happy */
(void) data;
return plugin_script_hdata_script (weechat_plugin,
&lua_scripts, &last_lua_script,
hdata_name);
}
/*
* weechat_lua_infolist_cb: callback for infolist
*/
@@ -761,6 +776,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
init.callback_command = &weechat_lua_command_cb;
init.callback_completion = &weechat_lua_completion_cb;
init.callback_hdata = &weechat_lua_hdata_cb;
init.callback_infolist = &weechat_lua_infolist_cb;
init.callback_signal_debug_dump = &weechat_lua_signal_debug_dump_cb;
init.callback_signal_buffer_closed = &weechat_lua_signal_buffer_closed_cb;
+16
View File
@@ -778,6 +778,21 @@ weechat_perl_completion_cb (void *data, const char *completion_item,
return WEECHAT_RC_OK;
}
/*
* weechat_perl_hdata_cb: callback for hdata
*/
struct t_hdata *
weechat_perl_hdata_cb (void *data, const char *hdata_name)
{
/* make C compiler happy */
(void) data;
return plugin_script_hdata_script (weechat_plugin,
&perl_scripts, &last_perl_script,
hdata_name);
}
/*
* weechat_perl_infolist_cb: callback for infolist
*/
@@ -974,6 +989,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
init.callback_command = &weechat_perl_command_cb;
init.callback_completion = &weechat_perl_completion_cb;
init.callback_hdata = &weechat_perl_hdata_cb;
init.callback_infolist = &weechat_perl_infolist_cb;
init.callback_signal_debug_dump = &weechat_perl_signal_debug_dump_cb;
init.callback_signal_buffer_closed = &weechat_perl_signal_buffer_closed_cb;
+38 -1
View File
@@ -22,6 +22,7 @@
*/
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
@@ -162,7 +163,7 @@ plugin_script_init (struct t_weechat_plugin *weechat_plugin,
if (completion)
free (completion);
/* add completion and infolist */
/* add completion, hdata and infolist */
length = strlen (weechat_plugin->name) + 16;
string = malloc (length);
if (string)
@@ -170,6 +171,8 @@ plugin_script_init (struct t_weechat_plugin *weechat_plugin,
snprintf (string, length, "%s_script", weechat_plugin->name);
weechat_hook_completion (string, N_("list of scripts"),
init->callback_completion, NULL);
weechat_hook_hdata (string, N_("list of scripts"),
init->callback_hdata, NULL);
weechat_hook_infolist (string, N_("list of scripts"),
N_("script pointer (optional)"),
N_("script name (can start or end with \"*\" as wildcard) (optional)"),
@@ -1147,6 +1150,40 @@ plugin_script_display_short_list (struct t_weechat_plugin *weechat_plugin,
}
}
/*
* plugin_script_hdata_script: return hdata for script
*/
struct t_hdata *
plugin_script_hdata_script (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script **scripts,
struct t_plugin_script **last_script,
const char *hdata_name)
{
struct t_hdata *hdata;
hdata = weechat_hdata_new (hdata_name, "prev_script", "next_script");
if (hdata)
{
WEECHAT_HDATA_VAR(struct t_plugin_script, filename, STRING, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, interpreter, POINTER, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, name, STRING, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, author, STRING, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, version, STRING, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, license, STRING, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, description, STRING, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, shutdown_func, STRING, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, charset, STRING, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, callbacks, POINTER, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, unloading, INTEGER, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_plugin_script, prev_script, POINTER, NULL, hdata_name);
WEECHAT_HDATA_VAR(struct t_plugin_script, next_script, POINTER, NULL, hdata_name);
WEECHAT_HDATA_LIST(*scripts);
WEECHAT_HDATA_LIST(*last_script);
}
return hdata;
}
/*
* plugin_script_add_to_infolist: add a script in an infolist
* return 1 if ok, 0 if error
+6
View File
@@ -74,6 +74,8 @@ struct t_plugin_script_init
int (*callback_completion)(void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion);
struct t_hdata *(*callback_hdata)(void *data,
const char *hdata_name);
struct t_infolist *(*callback_infolist)(void *data,
const char *infolist_name,
void *pointer,
@@ -146,6 +148,10 @@ extern void plugin_script_display_list (struct t_weechat_plugin *weechat_plugin,
const char *name, int full);
extern void plugin_script_display_short_list (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts);
extern struct t_hdata *plugin_script_hdata_script (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script **scripts,
struct t_plugin_script **last_script,
const char *hdata_name);
extern int plugin_script_add_to_infolist (struct t_weechat_plugin *weechat_plugin,
struct t_infolist *infolist,
struct t_plugin_script *script);
+16
View File
@@ -1012,6 +1012,21 @@ weechat_python_info_cb (void *data, const char *info_name,
return NULL;
}
/*
* weechat_python_hdata_cb: callback for hdata
*/
struct t_hdata *
weechat_python_hdata_cb (void *data, const char *hdata_name)
{
/* make C compiler happy */
(void) data;
return plugin_script_hdata_script (weechat_plugin,
&python_scripts, &last_python_script,
hdata_name);
}
/*
* weechat_python_infolist_cb: callback for infolist
*/
@@ -1201,6 +1216,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
init.callback_command = &weechat_python_command_cb;
init.callback_completion = &weechat_python_completion_cb;
init.callback_hdata = &weechat_python_hdata_cb;
init.callback_infolist = &weechat_python_infolist_cb;
init.callback_signal_debug_dump = &weechat_python_signal_debug_dump_cb;
init.callback_signal_buffer_closed = &weechat_python_signal_buffer_closed_cb;
+16
View File
@@ -828,6 +828,21 @@ weechat_ruby_completion_cb (void *data, const char *completion_item,
return WEECHAT_RC_OK;
}
/*
* weechat_ruby_hdata_cb: callback for hdata
*/
struct t_hdata *
weechat_ruby_hdata_cb (void *data, const char *hdata_name)
{
/* make C compiler happy */
(void) data;
return plugin_script_hdata_script (weechat_plugin,
&ruby_scripts, &last_ruby_script,
hdata_name);
}
/*
* weechat_ruby_infolist_cb: callback for infolist
*/
@@ -1072,6 +1087,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
init.callback_command = &weechat_ruby_command_cb;
init.callback_completion = &weechat_ruby_completion_cb;
init.callback_hdata = &weechat_ruby_hdata_cb;
init.callback_infolist = &weechat_ruby_infolist_cb;
init.callback_signal_debug_dump = &weechat_ruby_signal_debug_dump_cb;
init.callback_signal_buffer_closed = &weechat_ruby_signal_buffer_closed_cb;
+16
View File
@@ -574,6 +574,21 @@ weechat_tcl_completion_cb (void *data, const char *completion_item,
return WEECHAT_RC_OK;
}
/*
* weechat_tcl_hdata_cb: callback for hdata
*/
struct t_hdata *
weechat_tcl_hdata_cb (void *data, const char *hdata_name)
{
/* make C compiler happy */
(void) data;
return plugin_script_hdata_script (weechat_plugin,
&tcl_scripts, &last_tcl_script,
hdata_name);
}
/*
* weechat_tcl_infolist_cb: callback for infolist
*/
@@ -720,6 +735,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
init.callback_command = &weechat_tcl_command_cb;
init.callback_completion = &weechat_tcl_completion_cb;
init.callback_hdata = &weechat_tcl_hdata_cb;
init.callback_infolist = &weechat_tcl_infolist_cb;
init.callback_signal_debug_dump = &weechat_tcl_signal_debug_dump_cb;
init.callback_signal_buffer_closed = &weechat_tcl_signal_buffer_closed_cb;