diff options
author | Brian Brooks <brooks.brian@gmail.com> | 2020-10-18 08:37:09 -0500 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2020-10-24 23:25:33 +0100 |
commit | 9e2a0effb2b7b933db00543f1e6879541707a2f3 (patch) | |
tree | 51b7a57dc97e7831c2f85ff4f0074062ff83fc60 /src | |
parent | 0d3a67b23f7848584a36712741252a73b03ae3a5 (diff) | |
download | riscv-openocd-9e2a0effb2b7b933db00543f1e6879541707a2f3.zip riscv-openocd-9e2a0effb2b7b933db00543f1e6879541707a2f3.tar.gz riscv-openocd-9e2a0effb2b7b933db00543f1e6879541707a2f3.tar.bz2 |
server/telnet: Handle Ctrl+K
Handle Ctrl+K shortcut which clears the line from the cursor position
to the end of line.
Change-Id: I2ecff5284473cef7c11cf9cb7e1c0c97d55f6c1c
Signed-off-by: Brian Brooks <brooks.brian@gmail.com>
Reviewed-on: http://openocd.zylin.com/5868
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/server/telnet_server.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index 0243c63..407ab68 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -538,7 +538,17 @@ static int telnet_input(struct connection *connection) telnet_move_cursor(connection, 0); else if (*buf_p == CTRL('E')) telnet_move_cursor(connection, t_con->line_size); - else + else if (*buf_p == CTRL('K')) { /* kill line to end */ + if (t_con->line_cursor < t_con->line_size) { + /* overwrite with space, until end of line, move back */ + for (size_t i = t_con->line_cursor; i < t_con->line_size; i++) + telnet_write(connection, " ", 1); + for (size_t i = t_con->line_cursor; i < t_con->line_size; i++) + telnet_write(connection, "\b", 1); + t_con->line[t_con->line_cursor] = '\0'; + t_con->line_size = t_con->line_cursor; + } + } else LOG_DEBUG("unhandled nonprintable: %2.2x", *buf_p); } } |