From b60aec975ba13d347edd3a110cbfef7699bc3cfb Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Mon, 25 Feb 2013 08:46:41 +0100 Subject: 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). --- src/plugins/tcl/weechat-tcl.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/plugins/tcl/weechat-tcl.c') diff --git a/src/plugins/tcl/weechat-tcl.c b/src/plugins/tcl/weechat-tcl.c index d379c0133..733af1c45 100644 --- a/src/plugins/tcl/weechat-tcl.c +++ b/src/plugins/tcl/weechat-tcl.c @@ -52,7 +52,7 @@ const char *tcl_current_script_filename = NULL; /* * string used to execute action "install": - * when signal "tcl_install_script" is received, name of string + * when signal "tcl_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 *tcl_action_install_list = NULL; /* * string used to execute action "remove": - * when signal "tcl_remove_script" is received, name of string + * when signal "tcl_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 *tcl_action_remove_list = NULL; +/* + * string used to execute action "autoload": + * when signal "tcl_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 *tcl_action_autoload_list = NULL; + Tcl_Interp* cinterp; @@ -728,6 +736,12 @@ weechat_tcl_timer_action_cb (void *data, int remaining_calls) &tcl_quiet, &tcl_action_remove_list); } + else if (data == &tcl_action_autoload_list) + { + plugin_script_action_autoload (weechat_tcl_plugin, + &tcl_quiet, + &tcl_action_autoload_list); + } } return WEECHAT_RC_OK; @@ -763,6 +777,14 @@ weechat_tcl_signal_script_action_cb (void *data, const char *signal, &weechat_tcl_timer_action_cb, &tcl_action_remove_list); } + else if (strcmp (signal, "tcl_script_autoload") == 0) + { + plugin_script_action_add (&tcl_action_autoload_list, + (const char *)signal_data); + weechat_hook_timer (1, 0, 1, + &weechat_tcl_timer_action_cb, + &tcl_action_autoload_list); + } } return WEECHAT_RC_OK; @@ -811,5 +833,13 @@ weechat_plugin_end (struct t_weechat_plugin *plugin) plugin_script_end (plugin, &tcl_scripts, &weechat_tcl_unload_all); tcl_quiet = 0; + /* free some data */ + if (tcl_action_install_list) + free (tcl_action_install_list); + if (tcl_action_remove_list) + free (tcl_action_remove_list); + if (tcl_action_autoload_list) + free (tcl_action_autoload_list); + return WEECHAT_RC_OK; } -- cgit v1.2.3