Fix backspace emulation in the serial console and in fgets()
This commit is contained in:
parent
fe1f411bdc
commit
56bef77cce
@ -171,6 +171,11 @@ fgets(char *str, int size, FILE *fh)
|
||||
int ch = fgetc(fh);
|
||||
if (ch == EOF)
|
||||
return NULL;
|
||||
if (ch == '\b') {
|
||||
if (i > 0)
|
||||
i -= 2;
|
||||
continue;
|
||||
}
|
||||
str[i] = (char)ch;
|
||||
if (ch == '\n') {
|
||||
str[i + 1] = '\0';
|
||||
|
@ -91,6 +91,12 @@ void Serial_Putc(char ch)
|
||||
// Timeout!
|
||||
}
|
||||
outb(base + UART_OFFSET_DATA, ch);
|
||||
|
||||
if (ch == '\b') {
|
||||
Serial_Putc(0x1B);
|
||||
Serial_Putc('[');
|
||||
Serial_Putc('P');
|
||||
}
|
||||
}
|
||||
|
||||
void Serial_Puts(const char *str)
|
||||
|
Loading…
Reference in New Issue
Block a user