diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2013-01-19 11:51:56 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2013-01-19 11:51:56 +0100 |
commit | 72b948fb1eaba1fc06de7325cc095f0889ce4d7f (patch) | |
tree | 4f53e793ddda10ca4ddcff9355a5c51953a389e6 /src/main.cpp | |
parent | a54b49f5a8858ae6603d0db56019adc3ce0dff90 (diff) | |
download | sciteco-72b948fb1eaba1fc06de7325cc095f0889ce4d7f.tar.gz |
allow <CTRL/C> to be typed; aborts last typed char
* CTRL/C will be a command so it is important to be able to type it directly
* aborting character processing is important because it allows aborting infinite loops
* since the loop interruption currently relies on SIGINT handling, there is only limited
support for XCurses and GTK - CTRL/C has to be typed in the terminal window.
later support for input queue polling might be added
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 2adb505..f5cd780 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,6 +23,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <signal.h> #include <glib.h> #include <glib/gprintf.h> @@ -51,6 +52,12 @@ namespace Flags { static gchar *mung_file = NULL; +sig_atomic_t sigint_occurred = FALSE; + +extern "C" { +static void sigint_handler(int signal); +} + void Interface::stdio_vmsg(MessageType type, const gchar *fmt, va_list ap) { @@ -160,6 +167,8 @@ main(int argc, char **argv) static GotoTable cmdline_goto_table; static QRegisterTable local_qregs; + signal(SIGINT, sigint_handler); + process_options(argc, argv); interface.ssm(SCI_SETCARETSTYLE, CARETSTYLE_BLOCK); @@ -213,3 +222,13 @@ main(int argc, char **argv) return 0; } + +/* + * Callbacks + */ + +static void +sigint_handler(int signal __attribute__((unused))) +{ + sigint_occurred = TRUE; +} |