From 5b93d9bb89bdc4c7a1d5d99d98d6698348ef4fc0 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Mon, 26 Aug 2024 20:14:51 +0200 Subject: [PATCH] [scripting] Added the "document.scripting.sleep_on_error" boolean option. Refs #319 When enabled elinks sleeps 3 seconds in case of error without terminal. Enabled is the default. --- src/scripting/scripting.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/scripting/scripting.c b/src/scripting/scripting.c index 931ab7db9..2b4d7caf3 100644 --- a/src/scripting/scripting.c +++ b/src/scripting/scripting.c @@ -44,7 +44,10 @@ report_scripting_error(struct module *module, struct session *ses, if (term == NULL) { usrerror(gettext("[%s error] %s"), gettext(module->name), msg); - sleep(3); + + if (get_opt_bool("document.scripting.sleep_on_error", NULL)) { + sleep(3); + } return; } @@ -66,6 +69,17 @@ report_scripting_error(struct module *module, struct session *ses, } #endif +static union option_info scripting_options[] = { + INIT_OPT_TREE("document", N_("Scripting"), + "scripting", OPT_ZERO, + N_("Document scripting options.")), + + INIT_OPT_BOOL("document.scripting", N_("Sleep on errors"), + "sleep_on_error", OPT_ZERO, 1, + N_("In case of errors in scripts an error message is shown. If this option is enabled ELinks also sleeps for 3 seconds.")), + + NULL_OPTION_INFO, +}; static struct module *scripting_modules[] = { #ifdef CONFIG_SCRIPTING_LUA @@ -91,7 +105,7 @@ static struct module *scripting_modules[] = { struct module scripting_module = struct_module( /* name: */ N_("Scripting"), - /* options: */ NULL, + /* options: */ scripting_options, /* events: */ NULL, /* submodules: */ scripting_modules, /* data: */ NULL,