From 76ddbec17c6084ab3333e4d5fa177241af1a91bb Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 8 Aug 2019 20:32:40 +1000 Subject: aio: tty: allow setting echo set-only e.g. to disable echo on stdin: stdin tty echo 0 This allows disabling echo while otherwise keeping cooked mode. Setting input to cooked or raw will overwrite this setting Signed-off-by: Steve Bennett --- jim-aio.c | 2 +- jim-tty.c | 16 +++++++++++++++- jim_tcl.txt | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/jim-aio.c b/jim-aio.c index 5557797..ddfc486 100644 --- a/jim-aio.c +++ b/jim-aio.c @@ -1762,7 +1762,7 @@ static const jim_subcmd_type aio_command_table[] = { #endif #if defined(HAVE_TERMIOS_H) { "tty", - "?baud rate? ?data bits? ?stop bits? ?parity even|odd|none? ?handshake xonxoff|rtscts|none? ?input raw|cooked? ?output raw|cooked? ?vmin n? ?vtime n?", + "?baud rate? ?data bits? ?stop bits? ?parity even|odd|none? ?handshake xonxoff|rtscts|none? ?input raw|cooked? ?output raw|cooked? ?echo 0|1? ?vmin n? ?vtime n?", aio_cmd_tty, 0, -1, diff --git a/jim-tty.c b/jim-tty.c index 0ccab7b..5d9cee7 100644 --- a/jim-tty.c +++ b/jim-tty.c @@ -79,6 +79,7 @@ static const char * const tty_settings_names[] = { "stop", "vmin", "vtime", + "echo", NULL }; @@ -91,7 +92,8 @@ enum { OPT_PARITY, OPT_STOP, OPT_VMIN, - OPT_VTIME + OPT_VTIME, + OPT_ECHO }; @@ -319,6 +321,18 @@ badvalue: } break; + case OPT_ECHO: + if (Jim_GetLong(interp, valueObj, &l) != JIM_OK) { + goto badvalue; + } + if (l) { + tio.c_lflag |= ECHO; + } + else { + tio.c_lflag &= ~ECHO; + } + break; + } } diff --git a/jim_tcl.txt b/jim_tcl.txt index 01c33b4..26cfd93 100644 --- a/jim_tcl.txt +++ b/jim_tcl.txt @@ -60,6 +60,7 @@ Changes since 0.78 4. Add `signal block` to prevent delivery of signals 5. Add support for `file split` 6. Add support for `json::encode` and `json::decode` +7. `aio tty` now allows setting +echo+ without full +raw+ mode Changes between 0.77 and 0.78 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -4855,6 +4856,10 @@ aio +*output raw|cooked*+;; Output character processing. Typically CR -> CRNL is disabled in raw mode. + +*echo 0|1*+;; + Disable or enable echo on input. Note that this is a set-only value. + Setting +input+ to +raw+ or +cooked+ will overwrite this setting. + +*vmin* 'numchars'+;; Minimum number of characters to read. -- cgit v1.2.3