aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp15
-rw-r--r--src/parser.cpp23
2 files changed, 36 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index aaedf14..bf25c73 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -419,6 +419,11 @@ main(int argc, char **argv)
} catch (Error &error) {
error.add_frame(new Error::ToplevelFrame());
throw; /* forward */
+ } catch (Quit) {
+ /*
+ * ^C invoked, quit hook should still
+ * be executed.
+ */
}
QRegisters::hook(QRegisters::HOOK_QUIT);
exit(EXIT_SUCCESS);
@@ -431,9 +436,15 @@ main(int argc, char **argv)
if (mung_file &&
g_file_test(mung_file, G_FILE_TEST_IS_REGULAR)) {
- Execute::file(mung_file, false);
+ try {
+ Execute::file(mung_file, false);
+ } catch (Quit) {
+ /*
+ * ^C invoked, quit hook should still
+ * be executed.
+ */
+ }
- /* FIXME: make quit immediate in batch/macro mode (non-UNDO)? */
if (quit_requested) {
QRegisters::hook(QRegisters::HOOK_QUIT);
exit(EXIT_SUCCESS);
diff --git a/src/parser.cpp b/src/parser.cpp
index 3541db1..85d455c 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -1916,6 +1916,29 @@ 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)
*/
case 'O':