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>
This commit is contained in:
parent
0d3a67b23f
commit
9e2a0effb2
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue