From 4db7f46808502e3a667d442d7a77f83f4593650b Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 16 Feb 2016 00:44:33 +0100 Subject: implemented ^C command * acts like exit(3) -- ie. the program is terminated immediately but the quit hook (aka SciTECO's atexit() handlers) will still run. * for "compatibility" with classic TECOs. Can also be used as a shorter variant of "-EX$$" but working from every macro level. * disallowed in interactive mode to avoid typing it accidentally. --- src/parser.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 3541db1..85d455c 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1915,6 +1915,29 @@ State * StateControl::custom(gchar chr) { switch (String::toupper(chr)) { + /*$ + * ^C -- Exit program immediately + * + * Lets the top-level macro return immediately + * regardless of the current macro invocation frame. + * This command is only allowed in batch mode, + * so it is not invoked accidentally when using + * the CTRL+C immediate editing command to + * interrupt long running operations. + * When using \fB^C\fP in a munged file, + * interactive mode is never started, so it behaves + * effectively just like \(lq-EX\fB$$\fP\(rq + * (when executed in the top-level macro at least). + * + * The \fBquit\fP hook is still executed. + */ + case 'C': + BEGIN_EXEC(&States::start); + if (undo.enabled) + throw Error("<^C> not allowed in interactive mode"); + quit_requested = true; + throw Quit(); + /*$ * ^O -- Set radix to 8 (octal) */ -- cgit v1.2.3