1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-24 03:46:39 +02:00

script: add control of autoload (enable/disable/toggle) (task #12393)

New option script.scripts.autoload, new options autoload/noautoload/toggleautoload
for command /script, new action "A" (meta-A) on script buffer (toggle autoload).
This commit is contained in:
Sebastien Helleu
2013-02-25 08:46:41 +01:00
parent 87b5096972
commit b60aec975b
35 changed files with 1227 additions and 535 deletions
+32 -2
View File
@@ -52,7 +52,7 @@ lua_State *lua_current_interpreter = NULL;
/*
* string used to execute action "install":
* when signal "lua_install_script" is received, name of string
* when signal "lua_script_install" is received, name of string
* is added to this string, to be installed later by a timer (when nothing is
* running in script)
*/
@@ -60,12 +60,20 @@ char *lua_action_install_list = NULL;
/*
* string used to execute action "remove":
* when signal "lua_remove_script" is received, name of string
* when signal "lua_script_remove" is received, name of string
* is added to this string, to be removed later by a timer (when nothing is
* running in script)
*/
char *lua_action_remove_list = NULL;
/*
* string used to execute action "autoload":
* when signal "lua_script_autoload" is received, name of string
* is added to this string, to autoload or disable autoload later by a timer
* (when nothing is running in script)
*/
char *lua_action_autoload_list = NULL;
/*
* Callback called for each key/value in a hashtable.
@@ -769,6 +777,12 @@ weechat_lua_timer_action_cb (void *data, int remaining_calls)
&lua_quiet,
&lua_action_remove_list);
}
else if (data == &lua_action_autoload_list)
{
plugin_script_action_autoload (weechat_lua_plugin,
&lua_quiet,
&lua_action_autoload_list);
}
}
return WEECHAT_RC_OK;
@@ -804,6 +818,14 @@ weechat_lua_signal_script_action_cb (void *data, const char *signal,
&weechat_lua_timer_action_cb,
&lua_action_remove_list);
}
else if (strcmp (signal, "lua_script_autoload") == 0)
{
plugin_script_action_add (&lua_action_autoload_list,
(const char *)signal_data);
weechat_hook_timer (1, 0, 1,
&weechat_lua_timer_action_cb,
&lua_action_autoload_list);
}
}
return WEECHAT_RC_OK;
@@ -852,5 +874,13 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
plugin_script_end (plugin, &lua_scripts, &weechat_lua_unload_all);
lua_quiet = 0;
/* free some data */
if (lua_action_install_list)
free (lua_action_install_list);
if (lua_action_remove_list)
free (lua_action_remove_list);
if (lua_action_autoload_list)
free (lua_action_autoload_list);
return WEECHAT_RC_OK;
}