diff options
author | Tarek BOCHKATI <tarek.bouchkati@gmail.com> | 2021-08-17 13:29:56 +0100 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2021-08-30 13:53:48 +0000 |
commit | 70cd395f3f0b7f7974125ce6e728980e855626ea (patch) | |
tree | 9fa3b8e61d4d30d419c5e23d5fd4cb545a5a8210 /src/server/telnet_server.c | |
parent | efe944dfc9fa9041ec2e006b702e9830f60f04bc (diff) | |
download | riscv-openocd-70cd395f3f0b7f7974125ce6e728980e855626ea.zip riscv-openocd-70cd395f3f0b7f7974125ce6e728980e855626ea.tar.gz riscv-openocd-70cd395f3f0b7f7974125ce6e728980e855626ea.tar.bz2 |
server/telnet: support 'CTRL+C'
like in terminal 'CTRL+C':
- keeps the line content so the user can refer to it (like copy/paste)
- marks the line with '^C', as hint that the command was not executed
- permit the user to write a new command
Change-Id: Ib784c827d64fdc439a35db461d8387a62d3bfbbf
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6439
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Diffstat (limited to 'src/server/telnet_server.c')
-rw-r--r-- | src/server/telnet_server.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index 253591e..f7b3f64 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -718,6 +718,13 @@ static int telnet_input(struct connection *connection) t_con->line_cursor--; } t_con->state = TELNET_STATE_DATA; + } else if (*buf_p == CTRL('C')) { /* interrupt */ + /* print '^C' at line end, and display a new command prompt */ + telnet_move_cursor(connection, t_con->line_size); + telnet_write(connection, "^C\n\r", 4); + t_con->line_cursor = 0; + t_con->line_size = 0; + telnet_prompt(connection); } else if (*buf_p == CTRL('F')) { /* cursor right */ if (t_con->line_cursor < t_con->line_size) telnet_write(connection, t_con->line + t_con->line_cursor++, 1); |