From 72b948fb1eaba1fc06de7325cc095f0889ce4d7f Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 19 Jan 2013 11:51:56 +0100 Subject: allow 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 --- src/main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/main.cpp') 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 #include #include +#include #include #include @@ -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; +} -- cgit v1.2.3