fix(userland): Fix 'clear' command, backspace keycodes (0x7F/0x08), serial keyboard input & make run target

- Add 'clear' and 'cls' builtin handlers in LazyBox shell
- Output ANSI \033[2J\033[H sequence on tty_clear() to clear serial/UART terminals
- Support both ASCII 0x7F (DEL) and 0x08 (BS) for Backspace in shell and nano editor
- Connect 16550 serial input to keyboard_get_key() on x86_64 for headless terminals
- Add ANSI escape sequence decoding for arrow keys (Up/Down/Left/Right/Home/End/Del)
- Update Makefile 'make run' and 'make qemu' with -display none for smooth terminal execution
- Add 'make run-gui' target for optional graphical SDL/GTK window
This commit is contained in:
subhobhai943 committed 2026-08-18 12:14:40 +05:30
1 parent f5dbc1453c
commit 6ad90542ac
7 files changed
+118 -23

No files matched your search

+2 -1
View File
@@ -287,7 +287,8 @@ int nano_main(int argc, char** argv) {
}
break;
case '\b': // Backspace
case '\b': // Backspace (0x08)
case 0x7F: // DEL
if (nano_cursor_col > 0) {
memmove(&nano_lines[nano_cursor_row][nano_cursor_col - 1],
&nano_lines[nano_cursor_row][nano_cursor_col],
+4 -1
View File
@@ -287,6 +287,8 @@ static void shell_process(const char* cmd) {
int idx = (history_head - history_count + i + HISTORY_SIZE) % HISTORY_SIZE;
printk(" %2d: %s\n", i + 1, history[idx]);
}
} else if (strcmp(argv[0], "clear") == 0 || strcmp(argv[0], "cls") == 0) {
tty_clear();
} else if (strcmp(argv[0], "reboot") == 0) {
printk(ANSI_YELLOW "Rebooting...\n" ANSI_RESET);
pit_sleep(200);
@@ -392,7 +394,7 @@ void shell_run(void) {
printk("%s%s", prompt, cmd_buffer);
continue;
}
if (c == '\b') {
if (c == '\b' || (unsigned char)c == 0x7F || c == 0x08) {
if (cursor_pos > 0) {
for (size_t i = cursor_pos - 1; i < cmd_len - 1; i++) cmd_buffer[i] = cmd_buffer[i + 1];
cmd_len--;
@@ -400,6 +402,7 @@ void shell_run(void) {
cmd_buffer[cmd_len] = '\0';
redraw_line(prompt, cmd_buffer, cmd_len, cursor_pos);
}
continue;
} else if (c == '\t') {
if (cmd_len > 0) {
int matches = 0;