From 496f6a9ceddf8ffa642b702b39a31555227c9cf2 Mon Sep 17 00:00:00 2001 From: Christian Kroll Date: Sun, 28 Sep 2014 05:13:25 +0200 Subject: [PATCH] uart_commands.c: allow for complete line removal via Ctrl-U --- src/uart/uart_commands.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/uart/uart_commands.c b/src/uart/uart_commands.c index 40595fb..a0ed170 100644 --- a/src/uart/uart_commands.c +++ b/src/uart/uart_commands.c @@ -44,7 +44,7 @@ extern volatile unsigned char reverseMode; char const UART_STR_NOTIMPL[] PROGMEM = "Not implemented."CR; #endif -char const UART_STR_CLEARLINE[] PROGMEM = "\033[1`\033[2K"; +char const UART_STR_CLEARLINE[] PROGMEM = "\033[1`\033[J"; char const UART_STR_BACKSPACE[] PROGMEM = "\b \b"; char const UART_STR_PROMPT[] PROGMEM = "> "; char const UART_STR_MODE[] PROGMEM = "%d"CR; @@ -287,15 +287,20 @@ static bool uartcmd_read_until_enter(void) { break; case '\f': // Form Feed (Ctrl-L), reprints the line buffer UART_PUTS_P(UART_STR_CLEARLINE); // clear current line - UART_PUTS_P(UART_STR_PROMPT); // prompt + UART_PUTS_P(UART_STR_PROMPT); // output prompt g_rx_buffer[g_rx_index] = 0; // terminate input buffer UART_PUTS(g_rx_buffer); // finally reprint it break; + case 21: // NAK (Ctrl-U), clears the line buffer + UART_PUTS_P(UART_STR_CLEARLINE); // clear current line + UART_PUTS_P(UART_STR_PROMPT); // output prompt + uartcmd_clear_buffer(); // clear buffer + break; case 27: // ignore Esc break; default: - // We don't accept control chars except for \f, \b, \r and \n. - // We also limit the input to 7 bit ASCII. + // We don't accept control characters which are not handled + // above. We also limit the input to 7 bit ASCII. if ((uart_result < 0x20) || (uart_result > 0x7f)) { UART_PUTC('\a'); // complain via ASCII bell } else {