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

Update of translations for scripts, fix bugs and code factorized in script plugins

This commit is contained in:
Sebastien Helleu
2008-01-14 11:18:39 +01:00
parent 68f7238887
commit 337908e9ef
16 changed files with 1377 additions and 1038 deletions
+33 -178
View File
@@ -98,8 +98,8 @@ char *perl_weechat_code =
" }"
" return 0;"
"}"
"$SIG{__WARN__} = sub { weechat::print \"Perl error: $_[0]\", \"\"; };"
"$SIG{__DIE__} = sub { weechat::print \"Perl error: $_[0]\", \"\"; };"
"$SIG{__WARN__} = sub { weechat::print(\"\", \"perl error: $_[0]\"); };"
"$SIG{__DIE__} = sub { weechat::print(\"\", \"perl error: $_[0]\"); };"
};
@@ -462,176 +462,37 @@ int
weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
//int handler_found, modifier_found;
char *path_script;
struct t_plugin_script *ptr_script;
//struct t_plugin_handler *ptr_handler;
//struct t_plugin_modifier *ptr_modifier;
/* make C compiler happy */
(void) data;
(void) buffer;
if (argc == 1)
{
/* list registered Perl scripts */
weechat_printf (NULL, "");
weechat_printf (NULL,
weechat_gettext ("Registered %s scripts:"),
"perl");
if (perl_scripts)
{
for (ptr_script = perl_scripts; ptr_script;
ptr_script = ptr_script->next_script)
{
weechat_printf (NULL,
weechat_gettext (" %s v%s (%s), by %s, "
"license %s"),
ptr_script->name,
ptr_script->version,
ptr_script->description,
ptr_script->author,
ptr_script->license);
}
}
else
weechat_printf (NULL, weechat_gettext (" (none)"));
/*
// list Perl message handlers
plugin->print_server (plugin, "");
plugin->print_server (plugin, "Perl message handlers:");
handler_found = 0;
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == PLUGIN_HANDLER_MESSAGE)
&& (ptr_handler->handler_args))
{
handler_found = 1;
plugin->print_server (plugin, " IRC(%s) => Perl(%s)",
ptr_handler->irc_command,
ptr_handler->handler_args);
}
}
if (!handler_found)
plugin->print_server (plugin, " (none)");
// list Perl command handlers
plugin->print_server (plugin, "");
plugin->print_server (plugin, "Perl command handlers:");
handler_found = 0;
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ptr_handler->handler_args))
{
handler_found = 1;
plugin->print_server (plugin, " /%s => Perl(%s)",
ptr_handler->command,
ptr_handler->handler_args);
}
}
if (!handler_found)
plugin->print_server (plugin, " (none)");
// list Perl timer handlers
plugin->print_server (plugin, "");
plugin->print_server (plugin, "Perl timer handlers:");
handler_found = 0;
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == PLUGIN_HANDLER_TIMER)
&& (ptr_handler->handler_args))
{
handler_found = 1;
plugin->print_server (plugin, " %d seconds => Perl(%s)",
ptr_handler->interval,
ptr_handler->handler_args);
}
}
if (!handler_found)
plugin->print_server (plugin, " (none)");
// list Perl keyboard handlers
plugin->print_server (plugin, "");
plugin->print_server (plugin, "Perl keyboard handlers:");
handler_found = 0;
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == PLUGIN_HANDLER_KEYBOARD)
&& (ptr_handler->handler_args))
{
handler_found = 1;
plugin->print_server (plugin, " Perl(%s)",
ptr_handler->handler_args);
}
}
if (!handler_found)
plugin->print_server (plugin, " (none)");
// list Perl event handlers
plugin->print_server (plugin, "");
plugin->print_server (plugin, "Perl event handlers:");
handler_found = 0;
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == PLUGIN_HANDLER_EVENT)
&& (ptr_handler->handler_args))
{
handler_found = 1;
plugin->print_server (plugin, " %s => Perl(%s)",
ptr_handler->event,
ptr_handler->handler_args);
}
}
if (!handler_found)
plugin->print_server (plugin, " (none)");
// list Perl modifiers
plugin->print_server (plugin, "");
plugin->print_server (plugin, "Perl modifiers:");
modifier_found = 0;
for (ptr_modifier = plugin->modifiers;
ptr_modifier; ptr_modifier = ptr_modifier->next_modifier)
{
modifier_found = 1;
if (ptr_modifier->type == PLUGIN_MODIFIER_IRC_IN)
plugin->print_server (plugin, " IRC(%s, %s) => Perl(%s)",
ptr_modifier->command,
PLUGIN_MODIFIER_IRC_IN_STR,
ptr_modifier->modifier_args);
else if (ptr_modifier->type == PLUGIN_MODIFIER_IRC_USER)
plugin->print_server (plugin, " IRC(%s, %s) => Perl(%s)",
ptr_modifier->command,
PLUGIN_MODIFIER_IRC_USER_STR,
ptr_modifier->modifier_args);
else if (ptr_modifier->type == PLUGIN_MODIFIER_IRC_OUT)
plugin->print_server (plugin, " IRC(%s, %s) => Perl(%s)",
ptr_modifier->command,
PLUGIN_MODIFIER_IRC_OUT_STR,
ptr_modifier->modifier_args);
}
if (!modifier_found)
plugin->print_server (plugin, " (none)");
*/
script_display_list (weechat_perl_plugin, perl_scripts,
NULL, 0);
}
else if (argc == 2)
{
if (weechat_strcasecmp (argv[1], "autoload") == 0)
if (weechat_strcasecmp (argv[1], "list") == 0)
{
script_auto_load (weechat_perl_plugin,
"perl", &weechat_perl_load_cb);
script_display_list (weechat_perl_plugin, perl_scripts,
NULL, 0);
}
else if (weechat_strcasecmp (argv[1], "listfull") == 0)
{
script_display_list (weechat_perl_plugin, perl_scripts,
NULL, 1);
}
else if (weechat_strcasecmp (argv[1], "autoload") == 0)
{
script_auto_load (weechat_perl_plugin, &weechat_perl_load_cb);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
weechat_perl_unload_all ();
script_auto_load (weechat_perl_plugin,
"perl", &weechat_perl_load_cb);
script_auto_load (weechat_perl_plugin, &weechat_perl_load_cb);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
@@ -640,11 +501,21 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
}
else
{
if (weechat_strcasecmp (argv[1], "load") == 0)
if (weechat_strcasecmp (argv[1], "list") == 0)
{
script_display_list (weechat_perl_plugin, perl_scripts,
argv_eol[2], 0);
}
else if (weechat_strcasecmp (argv[1], "listfull") == 0)
{
script_display_list (weechat_perl_plugin, perl_scripts,
argv_eol[2], 1);
}
else if (weechat_strcasecmp (argv[1], "load") == 0)
{
/* load Perl script */
path_script = script_search_full_name (weechat_perl_plugin,
"perl", argv_eol[2]);
argv_eol[2]);
weechat_perl_load ((path_script) ? path_script : argv_eol[2]);
if (path_script)
free (path_script);
@@ -712,25 +583,9 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
eval_pv (perl_weechat_code, TRUE);
#endif
weechat_hook_command ("perl",
weechat_gettext ("list/load/unload Perl scripts"),
weechat_gettext ("[load filename] | [autoload] | "
"[reload] | [unload [script]]"),
weechat_gettext ("filename: Perl script (file) to "
"load\n"
"script: script name to unload\n\n"
"Without argument, /perl command "
"lists all loaded Perl scripts."),
"load|autoload|reload|unload %f",
&weechat_perl_command_cb, NULL);
weechat_mkdir_home ("perl", 0644);
weechat_mkdir_home ("perl/autoload", 0644);
weechat_hook_signal ("dump_data", &weechat_perl_dump_data_cb, NULL);
script_init (weechat_perl_plugin);
script_auto_load (weechat_perl_plugin, "perl", &weechat_perl_load_cb);
script_init (weechat_perl_plugin,
&weechat_perl_command_cb, &weechat_perl_dump_data_cb,
&weechat_perl_load_cb);
/* init ok */
return WEECHAT_RC_OK;