Add newline and backspace

This commit is contained in:
Robbe Van Herck 2020-01-09 16:53:06 +01:00
parent 2f3b34475b
commit 41e3953d2c
No known key found for this signature in database
GPG key ID: A66F76F7B81BD784
3 changed files with 19 additions and 0 deletions

View file

@ -31,6 +31,9 @@ typedef enum keycode_enum {
KEYCODE_SPACE = ' ', KEYCODE_SPACE = ' ',
KEYCODE_BACKSPACE = 0x08,
KEYCODE_NEWLINE = '\n',
KEYCODE_SHIFT_UP, KEYCODE_SHIFT_UP,
KEYCODE_SHIFT_DOWN, KEYCODE_SHIFT_DOWN,
KEYCODE_CAPS_UP, KEYCODE_CAPS_UP,

View file

@ -72,6 +72,10 @@ keycode get_keycode(unsigned char scancode) {
return KEYCODE_CAPS_DOWN; return KEYCODE_CAPS_DOWN;
case 0xba: case 0xba:
return KEYCODE_CAPS_UP; return KEYCODE_CAPS_UP;
case 0x0e:
return KEYCODE_BACKSPACE;
case 0x1c:
return KEYCODE_NEWLINE;
default: default:
return KEYCODE_UNKNOWN; return KEYCODE_UNKNOWN;
} }

View file

@ -76,6 +76,18 @@ void terminal_putchar(char c) {
terminal_row++; terminal_row++;
return; return;
} }
if (c == 0x08) {
if (terminal_column == 0) {
if(terminal_row != 0) {
terminal_row--;
terminal_column = VGA_WIDTH - 1;
}
} else {
terminal_column--;
}
terminal_putentryat(' ', terminal_color, terminal_column, terminal_row);
return;
}
terminal_putentryat(c, terminal_color, terminal_column, terminal_row); terminal_putentryat(c, terminal_color, terminal_column, terminal_row);
if (++terminal_column == VGA_WIDTH) { if (++terminal_column == VGA_WIDTH) {