diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2011-03-23 23:20:24 +0000 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2011-03-23 23:20:24 +0000 |
commit | 9f0ef4953d153aaed45166050797e97545b96954 (patch) | |
tree | 87e48ace622fe2ce3f476d2703548814a99d6753 | |
parent | a71f68dd5718a77d5a97fc6d8e2fcd816657bb3b (diff) | |
download | termo-9f0ef4953d153aaed45166050797e97545b96954.tar.gz termo-9f0ef4953d153aaed45166050797e97545b96954.tar.xz termo-9f0ef4953d153aaed45166050797e97545b96954.zip |
Don't steal Ctrl-C from the kernel by default (so leave SIGINT enabled); add a flag to take it if required
-rw-r--r-- | termkey.c | 7 | ||||
-rw-r--r-- | termkey.h.in | 1 | ||||
-rw-r--r-- | termkey_new.3 | 3 |
3 files changed, 10 insertions, 1 deletions
@@ -278,7 +278,12 @@ static TermKey *termkey_new_full(int fd, int flags, size_t buffsize, int waittim tk->restore_termios_valid = 1; termios.c_iflag &= ~(IXON|INLCR|ICRNL); - termios.c_lflag &= ~(ICANON|ECHO|ISIG); + termios.c_lflag &= ~(ICANON|ECHO); + + termios.c_cc[VQUIT] = 0; + termios.c_cc[VSUSP] = 0; + if(flags & TERMKEY_FLAG_CTRLC) + termios.c_cc[VINTR] = 0; tcsetattr(fd, TCSANOW, &termios); } diff --git a/termkey.h.in b/termkey.h.in index 8e3cad1..0cfbb52 100644 --- a/termkey.h.in +++ b/termkey.h.in @@ -139,6 +139,7 @@ enum { TERMKEY_FLAG_UTF8 = 1 << 3, // Input is definitely UTF-8 TERMKEY_FLAG_NOTERMIOS = 1 << 4, // Do not make initial termios calls on construction TERMKEY_FLAG_SPACESYMBOL = 1 << 5, // Space is symbolic rather than Unicode + TERMKEY_FLAG_CTRLC = 1 << 6, // Allow Ctrl-C to be read as normal, disabling SIGINT }; void termkey_check_version(int major, int minor); diff --git a/termkey_new.3 b/termkey_new.3 index c1742fc..38e23b8 100644 --- a/termkey_new.3 +++ b/termkey_new.3 @@ -41,6 +41,9 @@ device, do not call the \fBtcsetattr\fP() \fBtermios\fP function on it to set it .TP .B TERMKEY_FLAG_SPACESYMBOL Report space as being a symbolic key rather than a Unicode codepoint. +.TP +.B TERMKEY_FLAG_CTRLC +Disable the \fBSIGINT\fP behaviour of \fICtrl-C\fP. If this flag is provided, then \fICtrl-C\fP will be available as a normal keypress, rather than sending the process group a \fBSIGINT\fP. This flag only takes effect without \fBTERMKEY_FLAG_NOTERMIOS\fP; with it, none of the signal keys are disabled anyway. .PP When the constructor is invoked, it attempts to detect if the current locale is UTF-8 aware or not, and sets either the \fBTERMKEY_FLAG_UTF8\fP or \fBTERMKEY_FLAG_RAW\fP flag. One of these two bits will always be in effect. The current flags in effect can be obtained by \fBtermkey_get_flags\fP(). .SH VERSION CHECK MACRO |