diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-02-16 00:44:33 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-02-16 00:44:33 +0100 |
commit | 4db7f46808502e3a667d442d7a77f83f4593650b (patch) | |
tree | baab2f9d0a6194960f3e29694cf5e23699ea64d2 /src/main.cpp | |
parent | 51aaeb062bf8f7e032b591832acd19901fca94c0 (diff) | |
download | sciteco-4db7f46808502e3a667d442d7a77f83f4593650b.tar.gz |
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.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 15 |
1 files changed, 13 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); |