mirror of
https://github.com/weechat/weechat.git
synced 2026-07-06 01:33:12 +02:00
Remove some messages during startup about scripts and plugins loaded
It is still possible to see messages by changing debug level for "core" or plugins (perl, python, ruby, lua, tcl).
This commit is contained in:
+18
-17
@@ -10,7 +10,7 @@
|
||||
* ## ##
|
||||
* ## By FlashCode <flashcode@flashtux.org> ##
|
||||
* ## ##
|
||||
* ## http://weechat.flashtux.org ##
|
||||
* ## http://weechat.flashtux.org/ ##
|
||||
* ## ##
|
||||
* ##########################################################################
|
||||
*
|
||||
@@ -299,11 +299,11 @@ weechat_welcome_message ()
|
||||
if (CONFIG_BOOLEAN(config_startup_display_logo))
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
"%s ___ __ ______________ _____ \n"
|
||||
"%s __ | / /___________ ____/__ /_______ __ /_\n"
|
||||
"%s __ | /| / /_ _ \\ _ \\ / __ __ \\ __ `/ __/\n"
|
||||
"%s __ |/ |/ / / __/ __/ /___ _ / / / /_/ // /_ \n"
|
||||
"%s ____/|__/ \\___/\\___/\\____/ /_/ /_/\\__,_/ \\__/ ",
|
||||
"%s ___ __ ______________ _____ \n"
|
||||
"%s __ | / /___________ ____/__ /_______ __ /_\n"
|
||||
"%s __ | /| / /_ _ \\ _ \\ / __ __ \\ __ `/ __/\n"
|
||||
"%s __ |/ |/ / / __/ __/ /___ _ / / / /_/ // /_ \n"
|
||||
"%s ____/|__/ \\___/\\___/\\____/ /_/ /_/\\__,_/ \\__/ ",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK),
|
||||
@@ -313,9 +313,7 @@ weechat_welcome_message ()
|
||||
if (CONFIG_STRING(config_startup_weechat_slogan)
|
||||
&& CONFIG_STRING(config_startup_weechat_slogan)[0])
|
||||
{
|
||||
gui_chat_printf (NULL, _("%sWelcome to %s%s%s, %s"),
|
||||
(CONFIG_BOOLEAN(config_startup_display_logo)) ?
|
||||
" " : "",
|
||||
gui_chat_printf (NULL, _("Welcome to %s%s%s, %s"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
|
||||
PACKAGE_NAME,
|
||||
GUI_NO_COLOR,
|
||||
@@ -323,21 +321,24 @@ weechat_welcome_message ()
|
||||
}
|
||||
if (CONFIG_BOOLEAN(config_startup_display_version))
|
||||
{
|
||||
gui_chat_printf (NULL, "%s%s%s%s, %s %s %s",
|
||||
(CONFIG_BOOLEAN(config_startup_display_logo)) ?
|
||||
" " : "",
|
||||
gui_chat_printf (NULL, "%sWeeChat %s %s[%s%s %s %s%s]",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
|
||||
PACKAGE_STRING,
|
||||
GUI_NO_COLOR,
|
||||
_("compiled on"), __DATE__, __TIME__);
|
||||
PACKAGE_VERSION,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_HOST),
|
||||
_("compiled on"),
|
||||
__DATE__,
|
||||
__TIME__,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
|
||||
}
|
||||
if (CONFIG_BOOLEAN(config_startup_display_logo) ||
|
||||
(CONFIG_STRING(config_startup_weechat_slogan)
|
||||
&& CONFIG_STRING(config_startup_weechat_slogan)[0]) ||
|
||||
CONFIG_BOOLEAN(config_startup_display_version))
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
"%s-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK));
|
||||
"- - - - - - - - - - - - - - - - - - - - - - - - - - - -");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -78,7 +78,7 @@ gui_history_buffer_add (struct t_gui_buffer *buffer, const char *string)
|
||||
ptr_history = buffer->last_history->prev_history;
|
||||
if (buffer->ptr_history == buffer->last_history)
|
||||
buffer->ptr_history = ptr_history;
|
||||
buffer->last_history->prev_history->next_history = NULL;
|
||||
((buffer->last_history)->prev_history)->next_history = NULL;
|
||||
if (buffer->last_history->text)
|
||||
free (buffer->last_history->text);
|
||||
free (buffer->last_history);
|
||||
@@ -128,7 +128,7 @@ gui_history_global_add (const char *string)
|
||||
ptr_history = last_history_global->prev_history;
|
||||
if (history_global_ptr == last_history_global)
|
||||
history_global_ptr = ptr_history;
|
||||
last_history_global->prev_history->next_history = NULL;
|
||||
(last_history_global->prev_history)->next_history = NULL;
|
||||
if (last_history_global->text)
|
||||
free (last_history_global->text);
|
||||
free (last_history_global);
|
||||
|
||||
@@ -238,7 +238,7 @@ gui_hotlist_add_hotlist (struct t_gui_hotlist **hotlist,
|
||||
new_hotlist->prev_hotlist = pos_hotlist->prev_hotlist;
|
||||
new_hotlist->next_hotlist = pos_hotlist;
|
||||
if (pos_hotlist->prev_hotlist)
|
||||
pos_hotlist->prev_hotlist->next_hotlist = new_hotlist;
|
||||
(pos_hotlist->prev_hotlist)->next_hotlist = new_hotlist;
|
||||
else
|
||||
*hotlist = new_hotlist;
|
||||
pos_hotlist->prev_hotlist = new_hotlist;
|
||||
|
||||
@@ -267,6 +267,7 @@ gui_keyboard_insert_sorted (struct t_gui_key **keys, struct t_gui_key **last_key
|
||||
}
|
||||
else
|
||||
{
|
||||
/* first key in list */
|
||||
key->prev_key = NULL;
|
||||
key->next_key = NULL;
|
||||
*keys = key;
|
||||
|
||||
@@ -95,7 +95,7 @@ gui_nicklist_insert_group_sorted (struct t_gui_nick_group **groups,
|
||||
group->prev_group = pos_group->prev_group;
|
||||
group->next_group = pos_group;
|
||||
if (pos_group->prev_group)
|
||||
pos_group->prev_group->next_group = group;
|
||||
(pos_group->prev_group)->next_group = group;
|
||||
else
|
||||
*groups = group;
|
||||
pos_group->prev_group = group;
|
||||
@@ -243,7 +243,7 @@ gui_nicklist_insert_nick_sorted (struct t_gui_nick_group *group,
|
||||
nick->prev_nick = pos_nick->prev_nick;
|
||||
nick->next_nick = pos_nick;
|
||||
if (pos_nick->prev_nick)
|
||||
pos_nick->prev_nick->next_nick = nick;
|
||||
(pos_nick->prev_nick)->next_nick = nick;
|
||||
else
|
||||
group->nicks = nick;
|
||||
pos_nick->prev_nick = nick;
|
||||
|
||||
@@ -380,6 +380,18 @@ charset_set (struct t_config_section *section, const char *type,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* charset_display_charsets: display charsets
|
||||
*/
|
||||
|
||||
void
|
||||
charset_display_charsets ()
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s: terminal: %s, internal: %s"),
|
||||
CHARSET_PLUGIN_NAME, charset_terminal, charset_internal);
|
||||
}
|
||||
|
||||
/*
|
||||
* charset_command_cb: callback for /charset command
|
||||
*/
|
||||
@@ -398,10 +410,8 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: missing parameters"),
|
||||
weechat_prefix ("error"), CHARSET_PLUGIN_NAME);
|
||||
return WEECHAT_RC_ERROR;
|
||||
charset_display_charsets ();
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
ptr_section = NULL;
|
||||
@@ -504,9 +514,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
charset_internal = weechat_info_get ("charset_internal", "");
|
||||
|
||||
/* display message */
|
||||
weechat_printf (NULL,
|
||||
_("%s: terminal: %s, internal: %s"),
|
||||
CHARSET_PLUGIN_NAME, charset_terminal, charset_internal);
|
||||
if (weechat_charset_plugin->debug >= 1)
|
||||
charset_display_charsets ();
|
||||
|
||||
if (!charset_config_init ())
|
||||
{
|
||||
|
||||
+11
-3
@@ -42,6 +42,7 @@ WEECHAT_PLUGIN_LICENSE("GPL3");
|
||||
struct t_weechat_plugin *weechat_fifo_plugin = NULL;
|
||||
#define weechat_plugin weechat_fifo_plugin
|
||||
|
||||
int fifo_quiet = 0;
|
||||
int fifo_fd = -1;
|
||||
struct t_hook *fifo_fd_hook = NULL;
|
||||
char *fifo_filename;
|
||||
@@ -95,9 +96,12 @@ fifo_create ()
|
||||
if ((fifo_fd = open (fifo_filename,
|
||||
O_RDONLY | O_NONBLOCK)) != -1)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s: pipe opened"),
|
||||
FIFO_PLUGIN_NAME),
|
||||
if ((weechat_fifo_plugin->debug >= 1) || !fifo_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s: pipe opened"),
|
||||
FIFO_PLUGIN_NAME);
|
||||
}
|
||||
rc = 1;
|
||||
}
|
||||
else
|
||||
@@ -366,6 +370,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
fifo_quiet = 1;
|
||||
|
||||
if (fifo_create ())
|
||||
fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0,
|
||||
&fifo_read, NULL);
|
||||
@@ -374,6 +380,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
|
||||
fifo_info_init ();
|
||||
|
||||
fifo_quiet = 0;
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
+119
-13
@@ -55,6 +55,7 @@
|
||||
#include "plugin-config.h"
|
||||
|
||||
|
||||
int plugin_quiet = 0;
|
||||
struct t_weechat_plugin *weechat_plugins = NULL;
|
||||
struct t_weechat_plugin *last_weechat_plugin = NULL;
|
||||
|
||||
@@ -125,6 +126,67 @@ plugin_get_name (struct t_weechat_plugin *plugin)
|
||||
return (plugin) ? plugin->name : plugin_core;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_find_pos: find position for a plugin (for sorting plugins list)
|
||||
*/
|
||||
|
||||
struct t_weechat_plugin *
|
||||
plugin_find_pos (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
{
|
||||
if (string_strcasecmp (plugin->name, ptr_plugin->name) < 0)
|
||||
return ptr_plugin;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_insert_sorted: insert a plugin in list, keeping sort on name
|
||||
*/
|
||||
|
||||
void
|
||||
plugin_insert_sorted (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
struct t_weechat_plugin *pos_plugin;
|
||||
|
||||
if (weechat_plugins)
|
||||
{
|
||||
pos_plugin = plugin_find_pos (plugin);
|
||||
|
||||
if (pos_plugin)
|
||||
{
|
||||
/* insert plugin into the list (before plugin found) */
|
||||
plugin->prev_plugin = pos_plugin->prev_plugin;
|
||||
plugin->next_plugin = pos_plugin;
|
||||
if (pos_plugin->prev_plugin)
|
||||
(pos_plugin->prev_plugin)->next_plugin = plugin;
|
||||
else
|
||||
weechat_plugins = plugin;
|
||||
pos_plugin->prev_plugin = plugin;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* add plugin to the end */
|
||||
plugin->prev_plugin = last_weechat_plugin;
|
||||
plugin->next_plugin = NULL;
|
||||
last_weechat_plugin->next_plugin = plugin;
|
||||
last_weechat_plugin = plugin;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* first plugin in list */
|
||||
plugin->prev_plugin = NULL;
|
||||
plugin->next_plugin = NULL;
|
||||
weechat_plugins = plugin;
|
||||
last_weechat_plugin = plugin;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_load: load a WeeChat plugin (a dynamic library)
|
||||
* return: pointer to new WeeChat plugin, NULL if error
|
||||
@@ -518,15 +580,8 @@ plugin_load (const char *filename)
|
||||
new_plugin->upgrade_read = &upgrade_file_read;
|
||||
new_plugin->upgrade_close = &upgrade_file_close;
|
||||
|
||||
/* add new plugin to list */
|
||||
new_plugin->prev_plugin = last_weechat_plugin;
|
||||
new_plugin->next_plugin = NULL;
|
||||
if (weechat_plugins)
|
||||
last_weechat_plugin->next_plugin = new_plugin;
|
||||
else
|
||||
weechat_plugins = new_plugin;
|
||||
last_weechat_plugin = new_plugin;
|
||||
|
||||
plugin_insert_sorted (new_plugin);
|
||||
|
||||
/* associate orphan buffers with this plugin (if asked during upgrade
|
||||
process) */
|
||||
gui_buffer_set_plugin_for_upgrade (name, new_plugin);
|
||||
@@ -591,9 +646,12 @@ plugin_load (const char *filename)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gui_chat_printf (NULL,
|
||||
_("Plugin \"%s\" loaded"),
|
||||
name);
|
||||
if ((weechat_debug_core >= 1) || !plugin_quiet)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("Plugin \"%s\" loaded"),
|
||||
name);
|
||||
}
|
||||
|
||||
free (full_name);
|
||||
|
||||
@@ -825,7 +883,7 @@ plugin_unload_all ()
|
||||
{
|
||||
while (weechat_plugins)
|
||||
{
|
||||
plugin_unload (last_weechat_plugin);
|
||||
plugin_unload (weechat_plugins);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -859,6 +917,49 @@ plugin_reload_name (const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_display_short_list: print list of plugins on one line
|
||||
*/
|
||||
|
||||
void
|
||||
plugin_display_short_list ()
|
||||
{
|
||||
const char *plugins_loaded;
|
||||
char *buf;
|
||||
int length;
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
|
||||
if (weechat_plugins)
|
||||
{
|
||||
plugins_loaded = _("Plugins loaded:");
|
||||
|
||||
length = strlen (plugins_loaded) + 1;
|
||||
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
{
|
||||
length += strlen (ptr_plugin->name) + 2;
|
||||
}
|
||||
length++;
|
||||
|
||||
buf = malloc (length);
|
||||
if (buf)
|
||||
{
|
||||
strcpy (buf, plugins_loaded);
|
||||
strcat (buf, " ");
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
{
|
||||
strcat (buf, ptr_plugin->name);
|
||||
if (ptr_plugin->next_plugin)
|
||||
strcat (buf, ", ");
|
||||
}
|
||||
gui_chat_printf (NULL, "%s", buf);
|
||||
free (buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_init: init plugin support
|
||||
*/
|
||||
@@ -878,7 +979,12 @@ plugin_init (int auto_load, int argc, char *argv[])
|
||||
|
||||
/* auto-load plugins if asked */
|
||||
if (auto_load)
|
||||
{
|
||||
plugin_quiet = 1;
|
||||
plugin_auto_load ();
|
||||
plugin_display_short_list ();
|
||||
plugin_quiet = 0;
|
||||
}
|
||||
|
||||
/* discard command arguments for future plugins */
|
||||
plugin_argc = 0;
|
||||
|
||||
@@ -107,7 +107,7 @@ weechat_lua_api_register (lua_State *L)
|
||||
|
||||
/* register script */
|
||||
lua_current_script = script_add (weechat_lua_plugin,
|
||||
&lua_scripts,
|
||||
&lua_scripts, &last_lua_script,
|
||||
(lua_current_script_filename) ?
|
||||
lua_current_script_filename : "",
|
||||
name,
|
||||
@@ -119,10 +119,13 @@ weechat_lua_api_register (lua_State *L)
|
||||
charset);
|
||||
if (lua_current_script)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: registered script \"%s\", "
|
||||
"version %s (%s)"),
|
||||
LUA_PLUGIN_NAME, name, version, description);
|
||||
if ((weechat_lua_plugin->debug >= 1) || !lua_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: registered script \"%s\", "
|
||||
"version %s (%s)"),
|
||||
LUA_PLUGIN_NAME, name, version, description);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -42,7 +42,9 @@ WEECHAT_PLUGIN_LICENSE("GPL3");
|
||||
|
||||
struct t_weechat_plugin *weechat_lua_plugin;
|
||||
|
||||
int lua_quiet = 0;
|
||||
struct t_plugin_script *lua_scripts = NULL;
|
||||
struct t_plugin_script *last_lua_script = NULL;
|
||||
struct t_plugin_script *lua_current_script = NULL;
|
||||
const char *lua_current_script_filename = NULL;
|
||||
lua_State *lua_current_interpreter = NULL;
|
||||
@@ -95,7 +97,8 @@ weechat_lua_exec (struct t_plugin_script *script,
|
||||
if (argv[6])
|
||||
{
|
||||
argc = 7;
|
||||
lua_pushstring (lua_current_interpreter, argv[6]);
|
||||
lua_pushstring (lua_current_interpreter,
|
||||
argv[6]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,9 +163,12 @@ weechat_lua_load (const char *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
LUA_PLUGIN_NAME, filename);
|
||||
if ((weechat_lua_plugin->debug >= 1) || !lua_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
LUA_PLUGIN_NAME, filename);
|
||||
}
|
||||
|
||||
lua_current_script = NULL;
|
||||
|
||||
@@ -233,7 +239,7 @@ weechat_lua_load (const char *filename)
|
||||
fclose (fp);
|
||||
/* if script was registered, removing from list */
|
||||
if (lua_current_script)
|
||||
script_remove (weechat_lua_plugin, &lua_scripts,
|
||||
script_remove (weechat_lua_plugin, &lua_scripts, &last_lua_script,
|
||||
lua_current_script);
|
||||
return 0;
|
||||
}
|
||||
@@ -298,7 +304,7 @@ weechat_lua_unload (struct t_plugin_script *script)
|
||||
lua_current_script = (lua_current_script->prev_script) ?
|
||||
lua_current_script->prev_script : lua_current_script->next_script;
|
||||
|
||||
script_remove (weechat_lua_plugin, &lua_scripts, script);
|
||||
script_remove (weechat_lua_plugin, &lua_scripts, &last_lua_script, script);
|
||||
|
||||
lua_close (script->interpreter);
|
||||
}
|
||||
@@ -448,8 +454,8 @@ weechat_lua_completion_cb (void *data, const char *completion_item,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_lua_debug_dump_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
weechat_lua_debug_dump_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -467,8 +473,8 @@ weechat_lua_debug_dump_cb (void *data, const char *signal, const char *type_data
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_lua_buffer_closed_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
weechat_lua_buffer_closed_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -494,12 +500,17 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
|
||||
weechat_lua_plugin = plugin;
|
||||
|
||||
lua_quiet = 1;
|
||||
script_init (weechat_lua_plugin,
|
||||
&weechat_lua_command_cb,
|
||||
&weechat_lua_completion_cb,
|
||||
&weechat_lua_debug_dump_cb,
|
||||
&weechat_lua_buffer_closed_cb,
|
||||
&weechat_lua_load_cb);
|
||||
lua_quiet = 0;
|
||||
|
||||
script_display_short_list (weechat_lua_plugin,
|
||||
lua_scripts);
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
extern struct t_weechat_plugin *weechat_lua_plugin;
|
||||
|
||||
extern int lua_quiet;
|
||||
extern struct t_plugin_script *lua_scripts;
|
||||
extern struct t_plugin_script *last_lua_script;
|
||||
extern struct t_plugin_script *lua_current_script;
|
||||
extern const char *lua_current_script_filename;
|
||||
extern lua_State *lua_current_interpreter;
|
||||
|
||||
@@ -104,17 +104,20 @@ static XS (XS_weechat_api_register)
|
||||
|
||||
/* register script */
|
||||
perl_current_script = script_add (weechat_perl_plugin,
|
||||
&perl_scripts,
|
||||
&perl_scripts, &last_perl_script,
|
||||
(perl_current_script_filename) ?
|
||||
perl_current_script_filename : "",
|
||||
name, author, version, license,
|
||||
description, shutdown_func, charset);
|
||||
if (perl_current_script)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: registered script \"%s\", "
|
||||
"version %s (%s)"),
|
||||
PERL_PLUGIN_NAME, name, version, description);
|
||||
if ((weechat_perl_plugin->debug >= 1) || !perl_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: registered script \"%s\", "
|
||||
"version %s (%s)"),
|
||||
PERL_PLUGIN_NAME, name, version, description);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -40,7 +40,9 @@ WEECHAT_PLUGIN_LICENSE("GPL3");
|
||||
|
||||
struct t_weechat_plugin *weechat_perl_plugin = NULL;
|
||||
|
||||
int perl_quiet = 0;
|
||||
struct t_plugin_script *perl_scripts = NULL;
|
||||
struct t_plugin_script *last_perl_script = NULL;
|
||||
struct t_plugin_script *perl_current_script = NULL;
|
||||
const char *perl_current_script_filename = NULL;
|
||||
|
||||
@@ -259,9 +261,12 @@ weechat_perl_load (const char *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
PERL_PLUGIN_NAME, filename);
|
||||
if ((weechat_perl_plugin->debug >= 1) || !perl_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
PERL_PLUGIN_NAME, filename);
|
||||
}
|
||||
|
||||
perl_current_script = NULL;
|
||||
|
||||
@@ -354,7 +359,8 @@ weechat_perl_load (const char *filename)
|
||||
#endif
|
||||
if (perl_current_script && (perl_current_script != &temp_script))
|
||||
{
|
||||
script_remove (weechat_perl_plugin, &perl_scripts,
|
||||
script_remove (weechat_perl_plugin,
|
||||
&perl_scripts, &last_perl_script,
|
||||
perl_current_script);
|
||||
}
|
||||
|
||||
@@ -436,7 +442,8 @@ weechat_perl_unload (struct t_plugin_script *script)
|
||||
perl_current_script = (perl_current_script->prev_script) ?
|
||||
perl_current_script->prev_script : perl_current_script->next_script;
|
||||
|
||||
script_remove (weechat_perl_plugin, &perl_scripts, script);
|
||||
script_remove (weechat_perl_plugin, &perl_scripts, &last_perl_script,
|
||||
script);
|
||||
|
||||
#ifdef MULTIPLICITY
|
||||
perl_destruct (interpreter);
|
||||
@@ -592,8 +599,8 @@ weechat_perl_completion_cb (void *data, const char *completion_item,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_perl_debug_dump_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
weechat_perl_debug_dump_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -611,8 +618,8 @@ weechat_perl_debug_dump_cb (void *data, const char *signal, const char *type_dat
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_perl_buffer_closed_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
weechat_perl_buffer_closed_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -669,12 +676,17 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
eval_pv (perl_weechat_code, TRUE);
|
||||
#endif
|
||||
|
||||
perl_quiet = 1;
|
||||
script_init (weechat_perl_plugin,
|
||||
&weechat_perl_command_cb,
|
||||
&weechat_perl_completion_cb,
|
||||
&weechat_perl_debug_dump_cb,
|
||||
&weechat_perl_buffer_closed_cb,
|
||||
&weechat_perl_load_cb);
|
||||
perl_quiet = 0;
|
||||
|
||||
script_display_short_list (weechat_perl_plugin,
|
||||
perl_scripts);
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
extern struct t_weechat_plugin *weechat_perl_plugin;
|
||||
|
||||
extern int perl_quiet;
|
||||
extern struct t_plugin_script *perl_scripts;
|
||||
extern struct t_plugin_script *last_perl_script;
|
||||
extern struct t_plugin_script *perl_current_script;
|
||||
extern const char *perl_current_script_filename;
|
||||
|
||||
|
||||
@@ -95,17 +95,20 @@ weechat_python_api_register (PyObject *self, PyObject *args)
|
||||
|
||||
/* register script */
|
||||
python_current_script = script_add (weechat_python_plugin,
|
||||
&python_scripts,
|
||||
&python_scripts, &last_python_script,
|
||||
(python_current_script_filename) ?
|
||||
python_current_script_filename : "",
|
||||
name, author, version, license,
|
||||
description, shutdown_func, charset);
|
||||
if (python_current_script)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: registered script \"%s\", "
|
||||
"version %s (%s)"),
|
||||
PYTHON_PLUGIN_NAME, name, version, description);
|
||||
if ((weechat_python_plugin->debug >= 1) || !python_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: registered script \"%s\", "
|
||||
"version %s (%s)"),
|
||||
PYTHON_PLUGIN_NAME, name, version, description);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -38,7 +38,9 @@ WEECHAT_PLUGIN_LICENSE("GPL3");
|
||||
|
||||
struct t_weechat_plugin *weechat_python_plugin = NULL;
|
||||
|
||||
int python_quiet;
|
||||
struct t_plugin_script *python_scripts = NULL;
|
||||
struct t_plugin_script *last_python_script = NULL;
|
||||
struct t_plugin_script *python_current_script = NULL;
|
||||
const char *python_current_script_filename = NULL;
|
||||
PyThreadState *python_mainThreadState = NULL;
|
||||
@@ -94,21 +96,25 @@ weechat_python_exec (struct t_plugin_script *script,
|
||||
{
|
||||
if (argv[6])
|
||||
{
|
||||
rc = PyObject_CallFunction (evFunc, "sssssss", argv[0],
|
||||
argv[1], argv[2], argv[3],
|
||||
argv[4], argv[5], argv[6]);
|
||||
rc = PyObject_CallFunction (evFunc, "sssssss",
|
||||
argv[0], argv[1],
|
||||
argv[2], argv[3],
|
||||
argv[4], argv[5],
|
||||
argv[6]);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = PyObject_CallFunction (evFunc, "ssssss", argv[0],
|
||||
argv[1], argv[2], argv[3],
|
||||
rc = PyObject_CallFunction (evFunc, "ssssss",
|
||||
argv[0], argv[1],
|
||||
argv[2], argv[3],
|
||||
argv[4], argv[5]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = PyObject_CallFunction (evFunc, "sssss", argv[0],
|
||||
argv[1], argv[2], argv[3],
|
||||
rc = PyObject_CallFunction (evFunc, "sssss",
|
||||
argv[0], argv[1],
|
||||
argv[2], argv[3],
|
||||
argv[4]);
|
||||
}
|
||||
}
|
||||
@@ -283,9 +289,12 @@ weechat_python_load (const char *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
PYTHON_PLUGIN_NAME, filename);
|
||||
if ((weechat_python_plugin->debug >= 1) || !python_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
PYTHON_PLUGIN_NAME, filename);
|
||||
}
|
||||
|
||||
python_current_script = NULL;
|
||||
|
||||
@@ -389,7 +398,8 @@ weechat_python_load (const char *filename)
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_INT", PyString_FromString(WEECHAT_HOOK_SIGNAL_INT));
|
||||
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_POINTER", PyString_FromString(WEECHAT_HOOK_SIGNAL_POINTER));
|
||||
|
||||
weechat_outputs = Py_InitModule("weechatOutputs", weechat_python_output_funcs);
|
||||
weechat_outputs = Py_InitModule("weechatOutputs",
|
||||
weechat_python_output_funcs);
|
||||
if (weechat_outputs == NULL)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -426,11 +436,14 @@ weechat_python_load (const char *filename)
|
||||
PyErr_Print ();
|
||||
Py_EndInterpreter (python_current_interpreter);
|
||||
/* PyEval_ReleaseLock (); */
|
||||
|
||||
|
||||
/* if script was registered, removing from list */
|
||||
if (python_current_script != NULL)
|
||||
script_remove (weechat_python_plugin, &python_scripts,
|
||||
python_current_script);
|
||||
{
|
||||
script_remove (weechat_python_plugin,
|
||||
&python_scripts, &last_python_script,
|
||||
python_current_script);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -501,7 +514,8 @@ weechat_python_unload (struct t_plugin_script *script)
|
||||
python_current_script = (python_current_script->prev_script) ?
|
||||
python_current_script->prev_script : python_current_script->next_script;
|
||||
|
||||
script_remove (weechat_python_plugin, &python_scripts, script);
|
||||
script_remove (weechat_python_plugin, &python_scripts, &last_python_script,
|
||||
script);
|
||||
|
||||
PyThreadState_Swap (interpreter);
|
||||
Py_EndInterpreter (interpreter);
|
||||
@@ -653,8 +667,8 @@ weechat_python_completion_cb (void *data, const char *completion_item,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_python_debug_dump_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
weechat_python_debug_dump_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -672,8 +686,8 @@ weechat_python_debug_dump_cb (void *data, const char *signal, const char *type_d
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_python_buffer_closed_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
weechat_python_buffer_closed_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -725,13 +739,18 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
weechat_prefix ("error"), PYTHON_PLUGIN_NAME);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
python_quiet = 1;
|
||||
script_init (weechat_python_plugin,
|
||||
&weechat_python_command_cb,
|
||||
&weechat_python_completion_cb,
|
||||
&weechat_python_debug_dump_cb,
|
||||
&weechat_python_buffer_closed_cb,
|
||||
&weechat_python_load_cb);
|
||||
python_quiet = 0;
|
||||
|
||||
script_display_short_list (weechat_python_plugin,
|
||||
python_scripts);
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
extern struct t_weechat_plugin *weechat_python_plugin;
|
||||
|
||||
extern int python_quiet;
|
||||
extern struct t_plugin_script *python_scripts;
|
||||
extern struct t_plugin_script *last_python_script;
|
||||
extern struct t_plugin_script *python_current_script;
|
||||
extern const char *python_current_script_filename;
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ weechat_ruby_api_register (VALUE class, VALUE name, VALUE author,
|
||||
|
||||
/* register script */
|
||||
ruby_current_script = script_add (weechat_ruby_plugin,
|
||||
&ruby_scripts,
|
||||
&ruby_scripts, &last_ruby_script,
|
||||
(ruby_current_script_filename) ?
|
||||
ruby_current_script_filename : "",
|
||||
c_name, c_author, c_version, c_license,
|
||||
@@ -120,10 +120,13 @@ weechat_ruby_api_register (VALUE class, VALUE name, VALUE author,
|
||||
|
||||
if (ruby_current_script)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: registered script \"%s\", "
|
||||
"version %s (%s)"),
|
||||
RUBY_PLUGIN_NAME, c_name, c_version, c_description);
|
||||
if ((weechat_ruby_plugin->debug >= 1) || !ruby_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: registered script \"%s\", "
|
||||
"version %s (%s)"),
|
||||
RUBY_PLUGIN_NAME, c_name, c_version, c_description);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -41,7 +41,9 @@ WEECHAT_PLUGIN_LICENSE("GPL3");
|
||||
|
||||
struct t_weechat_plugin *weechat_ruby_plugin = NULL;
|
||||
|
||||
int ruby_quiet = 0;
|
||||
struct t_plugin_script *ruby_scripts = NULL;
|
||||
struct t_plugin_script *last_ruby_script = NULL;
|
||||
struct t_plugin_script *ruby_current_script = NULL;
|
||||
const char *ruby_current_script_filename = NULL;
|
||||
|
||||
@@ -340,9 +342,12 @@ weechat_ruby_load (const char *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
RUBY_PLUGIN_NAME, filename);
|
||||
if ((weechat_ruby_plugin->debug >= 1) || !ruby_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
RUBY_PLUGIN_NAME, filename);
|
||||
}
|
||||
|
||||
ruby_current_script = NULL;
|
||||
|
||||
@@ -429,7 +434,8 @@ weechat_ruby_load (const char *filename)
|
||||
|
||||
if (ruby_current_script != NULL)
|
||||
{
|
||||
script_remove (weechat_ruby_plugin, &ruby_scripts,
|
||||
script_remove (weechat_ruby_plugin,
|
||||
&ruby_scripts, &last_ruby_script,
|
||||
ruby_current_script);
|
||||
}
|
||||
|
||||
@@ -495,7 +501,8 @@ weechat_ruby_unload (struct t_plugin_script *script)
|
||||
ruby_current_script = (ruby_current_script->prev_script) ?
|
||||
ruby_current_script->prev_script : ruby_current_script->next_script;
|
||||
|
||||
script_remove (weechat_ruby_plugin, &ruby_scripts, script);
|
||||
script_remove (weechat_ruby_plugin, &ruby_scripts, &last_ruby_script,
|
||||
script);
|
||||
|
||||
if (interpreter)
|
||||
rb_gc_unregister_address (interpreter);
|
||||
@@ -646,8 +653,8 @@ weechat_ruby_completion_cb (void *data, const char *completion_item,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_ruby_debug_dump_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
weechat_ruby_debug_dump_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -665,8 +672,8 @@ weechat_ruby_debug_dump_cb (void *data, const char *signal, const char *type_dat
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_ruby_buffer_closed_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
weechat_ruby_buffer_closed_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -750,10 +757,14 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
|
||||
/* redirect stdin and stdout */
|
||||
ruby_mWeechatOutputs = rb_define_module("WeechatOutputs");
|
||||
rb_define_singleton_method(ruby_mWeechatOutputs, "write", weechat_ruby_output, 1);
|
||||
rb_define_singleton_method(ruby_mWeechatOutputs, "puts", weechat_ruby_output, 1);
|
||||
rb_define_singleton_method(ruby_mWeechatOutputs, "p", weechat_ruby_output, 1);
|
||||
rb_define_singleton_method(ruby_mWeechatOutputs, "flush", weechat_ruby_output_flush, 0);
|
||||
rb_define_singleton_method(ruby_mWeechatOutputs, "write",
|
||||
weechat_ruby_output, 1);
|
||||
rb_define_singleton_method(ruby_mWeechatOutputs, "puts",
|
||||
weechat_ruby_output, 1);
|
||||
rb_define_singleton_method(ruby_mWeechatOutputs, "p",
|
||||
weechat_ruby_output, 1);
|
||||
rb_define_singleton_method(ruby_mWeechatOutputs, "flush",
|
||||
weechat_ruby_output_flush, 0);
|
||||
|
||||
rb_eval_string_protect(weechat_ruby_code, &ruby_error);
|
||||
if (ruby_error)
|
||||
@@ -770,12 +781,17 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
ruby_quiet = 1;
|
||||
script_init (weechat_ruby_plugin,
|
||||
&weechat_ruby_command_cb,
|
||||
&weechat_ruby_completion_cb,
|
||||
&weechat_ruby_debug_dump_cb,
|
||||
&weechat_ruby_buffer_closed_cb,
|
||||
&weechat_ruby_load_cb);
|
||||
ruby_quiet = 0;
|
||||
|
||||
script_display_short_list (weechat_ruby_plugin,
|
||||
ruby_scripts);
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
extern struct t_weechat_plugin *weechat_ruby_plugin;
|
||||
|
||||
extern int ruby_quiet;
|
||||
extern struct t_plugin_script *ruby_scripts;
|
||||
extern struct t_plugin_script *last_ruby_script;
|
||||
extern struct t_plugin_script *ruby_current_script;
|
||||
extern const char *ruby_current_script_filename;
|
||||
|
||||
|
||||
@@ -90,10 +90,10 @@ script_callback_remove (struct t_plugin_script *script,
|
||||
{
|
||||
/* remove callback from list */
|
||||
if (script_callback->prev_callback)
|
||||
script_callback->prev_callback->next_callback =
|
||||
(script_callback->prev_callback)->next_callback =
|
||||
script_callback->next_callback;
|
||||
if (script_callback->next_callback)
|
||||
script_callback->next_callback->prev_callback =
|
||||
(script_callback->next_callback)->prev_callback =
|
||||
script_callback->prev_callback;
|
||||
if (script->callbacks == script_callback)
|
||||
script->callbacks = script_callback->next_callback;
|
||||
|
||||
+118
-10
@@ -342,6 +342,71 @@ script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
||||
return strdup (filename);
|
||||
}
|
||||
|
||||
/*
|
||||
* script_find_pos: find position for a script (for sorting scripts list)
|
||||
*/
|
||||
|
||||
struct t_plugin_script *
|
||||
script_find_pos (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *scripts,
|
||||
struct t_plugin_script *script)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
for (ptr_script = scripts; ptr_script; ptr_script = ptr_script->next_script)
|
||||
{
|
||||
if (weechat_strcasecmp (script->name, ptr_script->name) < 0)
|
||||
return ptr_script;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_insert_sorted: insert a script in list, keeping sort on name
|
||||
*/
|
||||
|
||||
void
|
||||
script_insert_sorted (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **scripts,
|
||||
struct t_plugin_script **last_script,
|
||||
struct t_plugin_script *script)
|
||||
{
|
||||
struct t_plugin_script *pos_script;
|
||||
|
||||
if (*scripts)
|
||||
{
|
||||
pos_script = script_find_pos (weechat_plugin, *scripts, script);
|
||||
|
||||
if (pos_script)
|
||||
{
|
||||
/* insert script into the list (before script found) */
|
||||
script->prev_script = pos_script->prev_script;
|
||||
script->next_script = pos_script;
|
||||
if (pos_script->prev_script)
|
||||
(pos_script->prev_script)->next_script = script;
|
||||
else
|
||||
*scripts = script;
|
||||
pos_script->prev_script = script;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* add script to the end */
|
||||
script->prev_script = *last_script;
|
||||
script->next_script = NULL;
|
||||
(*last_script)->next_script = script;
|
||||
*last_script = script;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* first script in list */
|
||||
script->prev_script = NULL;
|
||||
script->next_script = NULL;
|
||||
*scripts = script;
|
||||
*last_script = script;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* script_add: add a script to list of scripts
|
||||
*/
|
||||
@@ -349,6 +414,7 @@ script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *
|
||||
script_add (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **scripts,
|
||||
struct t_plugin_script **last_script,
|
||||
const char *filename, const char *name, const char *author, const char *version,
|
||||
const char *license, const char *description, const char *shutdown_func,
|
||||
const char *charset)
|
||||
@@ -388,15 +454,9 @@ script_add (struct t_weechat_plugin *weechat_plugin,
|
||||
new_script->shutdown_func = (shutdown_func) ?
|
||||
strdup (shutdown_func) : NULL;
|
||||
new_script->charset = (charset) ? strdup (charset) : NULL;
|
||||
|
||||
new_script->callbacks = NULL;
|
||||
|
||||
/* add new script to list */
|
||||
if (*scripts)
|
||||
(*scripts)->prev_script = new_script;
|
||||
new_script->prev_script = NULL;
|
||||
new_script->next_script = *scripts;
|
||||
*scripts = new_script;
|
||||
script_insert_sorted (weechat_plugin, scripts, last_script, new_script);
|
||||
|
||||
return new_script;
|
||||
}
|
||||
@@ -443,6 +503,7 @@ script_remove_buffer_callbacks (struct t_plugin_script *scripts,
|
||||
void
|
||||
script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **scripts,
|
||||
struct t_plugin_script **last_script,
|
||||
struct t_plugin_script *script)
|
||||
{
|
||||
struct t_script_callback *ptr_script_callback, *next_script_callback;
|
||||
@@ -456,7 +517,7 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
weechat_unhook (ptr_script_callback->hook);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ptr_script_callback = script->callbacks;
|
||||
while (ptr_script_callback)
|
||||
{
|
||||
@@ -516,10 +577,12 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
/* remove script from list */
|
||||
if (script->prev_script)
|
||||
(script->prev_script)->next_script = script->next_script;
|
||||
else
|
||||
*scripts = script->next_script;
|
||||
if (script->next_script)
|
||||
(script->next_script)->prev_script = script->prev_script;
|
||||
if (*scripts == script)
|
||||
*scripts = script->next_script;
|
||||
if (*last_script == script)
|
||||
*last_script = script->prev_script;
|
||||
|
||||
/* free script */
|
||||
free (script);
|
||||
@@ -591,6 +654,51 @@ script_display_list (struct t_weechat_plugin *weechat_plugin,
|
||||
weechat_printf (NULL, _(" (none)"));
|
||||
}
|
||||
|
||||
/*
|
||||
* script_display_short_list: print list of scripts on one line
|
||||
*/
|
||||
|
||||
void
|
||||
script_display_short_list (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *scripts)
|
||||
{
|
||||
const char *scripts_loaded;
|
||||
char *buf;
|
||||
int length;
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
if (scripts)
|
||||
{
|
||||
/* TRANSLATORS: %s is language (for example "perl") */
|
||||
scripts_loaded = _("%s scripts loaded:");
|
||||
|
||||
length = strlen (scripts_loaded) + strlen (weechat_plugin->name) + 1;
|
||||
|
||||
for (ptr_script = scripts; ptr_script;
|
||||
ptr_script = ptr_script->next_script)
|
||||
{
|
||||
length += strlen (ptr_script->name) + 2;
|
||||
}
|
||||
length++;
|
||||
|
||||
buf = malloc (length);
|
||||
if (buf)
|
||||
{
|
||||
snprintf (buf, length, scripts_loaded, weechat_plugin->name);
|
||||
strcat (buf, " ");
|
||||
for (ptr_script = scripts; ptr_script;
|
||||
ptr_script = ptr_script->next_script)
|
||||
{
|
||||
strcat (buf, ptr_script->name);
|
||||
if (ptr_script->next_script)
|
||||
strcat (buf, ", ");
|
||||
}
|
||||
weechat_printf (NULL, "%s", buf);
|
||||
free (buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* script_print_log: print script infos in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
@@ -85,6 +85,7 @@ extern char *script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
||||
const char *filename);
|
||||
extern struct t_plugin_script *script_add (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **scripts,
|
||||
struct t_plugin_script **last_script,
|
||||
const char *filename, const char *name,
|
||||
const char *author, const char *version,
|
||||
const char *license, const char *description,
|
||||
@@ -93,6 +94,7 @@ extern void script_remove_buffer_callbacks (struct t_plugin_script *scripts,
|
||||
struct t_gui_buffer *buffer);
|
||||
extern void script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **scripts,
|
||||
struct t_plugin_script **last_script,
|
||||
struct t_plugin_script *script);
|
||||
extern void script_completion (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_gui_completion *completion,
|
||||
@@ -100,6 +102,8 @@ extern void script_completion (struct t_weechat_plugin *weechat_plugin,
|
||||
extern void script_display_list (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *scripts,
|
||||
const char *name, int full);
|
||||
extern void script_display_short_list (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *scripts);
|
||||
extern void script_print_log (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *scripts);
|
||||
|
||||
|
||||
@@ -198,17 +198,20 @@ weechat_tcl_api_register (ClientData clientData, Tcl_Interp *interp, int objc,
|
||||
|
||||
/* register script */
|
||||
tcl_current_script = script_add (weechat_tcl_plugin,
|
||||
&tcl_scripts,
|
||||
&tcl_scripts, &last_tcl_script,
|
||||
(tcl_current_script_filename) ?
|
||||
tcl_current_script_filename : "",
|
||||
name, author, version, license,
|
||||
description, shutdown_func, charset);
|
||||
if (tcl_current_script)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: registered script \"%s\", "
|
||||
"version %s (%s)"),
|
||||
TCL_PLUGIN_NAME, name, version, description);
|
||||
if ((weechat_tcl_plugin->debug >= 1) || !tcl_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: registered script \"%s\", "
|
||||
"version %s (%s)"),
|
||||
TCL_PLUGIN_NAME, name, version, description);
|
||||
}
|
||||
tcl_current_script->interpreter = (void *)interp;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -43,7 +43,9 @@ WEECHAT_PLUGIN_LICENSE("GPL3");
|
||||
|
||||
struct t_weechat_plugin *weechat_tcl_plugin = NULL;
|
||||
|
||||
int tcl_quiet = 0;
|
||||
struct t_plugin_script *tcl_scripts = NULL;
|
||||
struct t_plugin_script *last_tcl_script = NULL;
|
||||
struct t_plugin_script *tcl_current_script = NULL;
|
||||
const char *tcl_current_script_filename = NULL;
|
||||
|
||||
@@ -155,9 +157,12 @@ weechat_tcl_load (const char *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
TCL_PLUGIN_NAME, filename);
|
||||
if ((weechat_tcl_plugin->debug >= 1) || !tcl_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
TCL_PLUGIN_NAME, filename);
|
||||
}
|
||||
|
||||
tcl_current_script = NULL;
|
||||
|
||||
@@ -239,7 +244,7 @@ weechat_tcl_unload (struct t_plugin_script *script)
|
||||
tcl_current_script = (tcl_current_script->prev_script) ?
|
||||
tcl_current_script->prev_script : tcl_current_script->next_script;
|
||||
|
||||
script_remove (weechat_tcl_plugin, &tcl_scripts, script);
|
||||
script_remove (weechat_tcl_plugin, &tcl_scripts, &last_tcl_script, script);
|
||||
|
||||
Tcl_DeleteInterp(interp);
|
||||
}
|
||||
@@ -389,8 +394,8 @@ weechat_tcl_completion_cb (void *data, const char *completion_item,
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_tcl_debug_dump_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
weechat_tcl_debug_dump_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -408,8 +413,8 @@ weechat_tcl_debug_dump_cb (void *data, const char *signal, const char *type_data
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_tcl_buffer_closed_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
weechat_tcl_buffer_closed_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -435,12 +440,17 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
|
||||
weechat_tcl_plugin = plugin;
|
||||
|
||||
tcl_quiet = 1;
|
||||
script_init (weechat_tcl_plugin,
|
||||
weechat_tcl_command_cb,
|
||||
weechat_tcl_completion_cb,
|
||||
weechat_tcl_debug_dump_cb,
|
||||
weechat_tcl_buffer_closed_cb,
|
||||
weechat_tcl_load_cb);
|
||||
tcl_quiet = 0;
|
||||
|
||||
script_display_short_list (weechat_tcl_plugin,
|
||||
tcl_scripts);
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
extern struct t_weechat_plugin *weechat_tcl_plugin;
|
||||
|
||||
extern int tcl_quiet;
|
||||
extern struct t_plugin_script *tcl_scripts;
|
||||
extern struct t_plugin_script *last_tcl_script;
|
||||
extern struct t_plugin_script *tcl_current_script;
|
||||
extern const char *tcl_current_script_filename;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user