projects
/
fw
/
openocd
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0d3a67b
)
server/telnet: Handle Ctrl+K
author
Brian Brooks
<brooks.brian@gmail.com>
Sun, 18 Oct 2020 13:37:09 +0000
(08:37 -0500)
committer
Antonio Borneo
<borneo.antonio@gmail.com>
Sat, 24 Oct 2020 22:25:33 +0000
(23:25 +0100)
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>
src/server/telnet_server.c
patch
|
blob
|
history
diff --git
a/src/server/telnet_server.c
b/src/server/telnet_server.c
index 0243c6328eb8205236eaaea6dbb7d3ee3edc4911..407ab68aefcd74d41d31f205e6e16fb3828cbef2 100644
(file)
--- 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);
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);
}
}
LOG_DEBUG("unhandled nonprintable: %2.2x", *buf_p);
}
}