Add support for disabling default SIGINT and EOF behavior.

This patch adds support for `--disable-eof` and `--disable-sigint` to
the Editline configure script.  With either of these two switches the
`tty_special()` function bypasses the special TTY checks making it
possible to bind Ctrl-C and Ctrl-D to custom callbacks.  This can be
useful if you want to emulate a Cisco style CLI rather than traditional
UNIX.

The user can of course also redefine the VINTR and VEOF special terminal
control characters, but these configure script switches may be easier to
use for some.

Also, the CLI example has been updated to bind Ctrl-D, Ctrl-C and Ctrl-Z
for testing purposes.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2015-04-06 14:45:07 +02:00
parent a2bc89db64
commit 6a8556733a
5 changed files with 65 additions and 2 deletions

View File

@@ -924,10 +924,12 @@ static el_status_t emacs(int c)
static el_status_t tty_special(int c)
{
#ifdef CONFIG_SIGINT
if (c == rl_intr) {
el_intr_pending = SIGINT;
return CSsignal;
}
#endif
if (c == rl_quit) {
el_intr_pending = SIGQUIT;
return CSeof;
@@ -953,8 +955,10 @@ static el_status_t tty_special(int c)
return kill_line();
}
#ifdef CONFIG_EOF
if (c == rl_eof && rl_point == 0 && rl_end == 0)
return CSeof;
#endif
return CSdispatch;
}