Explorar o código

cli: handle backspaces properly

Sergey Alirzaev %!s(int64=5) %!d(string=hai) anos
pai
achega
e1c1de6872
Modificáronse 1 ficheiros con 5 adicións e 5 borrados
  1. 5 5
      modules/SSH_Server/cli.c

+ 5 - 5
modules/SSH_Server/cli.c

@@ -310,13 +310,13 @@ void cli_getchar(cli_state_t *s, char incoming_char)
 		cli_input(s);
 		cli_input(s);
 		s->bufptr = 0;
 		s->bufptr = 0;
 	} else if( s->buf[s->bufptr] == '\b' || s->buf[s->bufptr] == 0x7f) {
 	} else if( s->buf[s->bufptr] == '\b' || s->buf[s->bufptr] == 0x7f) {
-		/* Backspace was pressed.	Erase the last
-		character in the string - if any. */
-			s->buf[s->bufptr] = '\0';
-		if( s->bufptr > 0 )
-		{
+		/* Backspace was pressed. Erase the last character in the string - if any. */
+		s->buf[s->bufptr] = '\0';
+		if (s->bufptr > 0) {
 			s->bufptr--;
 			s->bufptr--;
 			s->buf[s->bufptr] = '\0';
 			s->buf[s->bufptr] = '\0';
+			const char backspace[] = "\b \b";
+			s->send(s->num_connect, backspace, sizeof(backspace));
 		}
 		}
 	} else if (s->buf[s->bufptr] == 0x03){
 	} else if (s->buf[s->bufptr] == 0x03){
 		xTimerStop(s->RepeatSensorInfoTimer, 0);
 		xTimerStop(s->RepeatSensorInfoTimer, 0);