mirror of
https://github.com/troglobit/editline.git
synced 2025-09-18 02:08:08 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user