This is an automated email from Gerrit.

Brian Brooks ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/5868

-- gerrit

commit abd02222378fafd42f5f4d16c27ffab3e799fdb5
Author: Brian Brooks <[email protected]>
Date:   Sun Oct 18 08:37:09 2020 -0500

    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 <[email protected]>

diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c
index 0243c63..3bf910b 100644
--- a/src/server/telnet_server.c
+++ b/src/server/telnet_server.c
@@ -373,6 +373,7 @@ static int telnet_input(struct connection *connection)
        unsigned char *buf_p;
        struct telnet_connection *t_con = connection->priv;
        struct command_context *command_context = connection->cmd_ctx;
+       size_t i;
 
        bytes_read = connection_read(connection, buffer, TELNET_BUFFER_SIZE);
 
@@ -402,7 +403,6 @@ static int telnet_input(struct connection *connection)
                                                        
t_con->line[t_con->line_size++] = *buf_p;
                                                        t_con->line_cursor++;
                                                } else {
-                                                       size_t i;
                                                        memmove(t_con->line + 
t_con->line_cursor + 1,
                                                                        
t_con->line + t_con->line_cursor,
                                                                        
t_con->line_size - t_con->line_cursor);
@@ -494,7 +494,6 @@ static int telnet_input(struct connection *connection)
                                                } else if ((*buf_p == 0x7f) || 
(*buf_p == 0x8)) {       /* delete character */
                                                        if (t_con->line_cursor 
> 0) {
                                                                if 
(t_con->line_cursor != t_con->line_size) {
-                                                                       size_t 
i;
                                                                        
telnet_write(connection, "\b", 1);
                                                                        
t_con->line_cursor--;
                                                                        
t_con->line_size--;
@@ -538,7 +537,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 (i = 
t_con->line_cursor; i < t_con->line_size; i++)
+                                                                       
telnet_write(connection, " ", 1);
+                                                               for (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);
                                        }
                                }
@@ -594,7 +603,6 @@ static int telnet_input(struct connection *connection)
                                        /* Remove character */
                                        if (*buf_p == '~') {
                                                if (t_con->line_cursor < 
t_con->line_size) {
-                                                       size_t i;
                                                        t_con->line_size--;
                                                        /* remove char from 
line buffer */
                                                        memmove(t_con->line + 
t_con->line_cursor,

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to