fix: backspace printing + clean a few warnings/junk code

This commit is contained in:
2024-10-09 23:24:56 +02:00
parent 06ade25a46
commit 29b59c474d
2 changed files with 6 additions and 7 deletions

View File

@ -82,14 +82,15 @@ static char *get_line(void)
while (1) {
ev = get_key();
// kprintf("%d %d\n", ev.scan_code, ev.c);
if (ev.c == '\n')
break;
char *buf = screen->line;
i = strlen(screen->line);
const size_t size = sizeof(screen->line);
if (ev.scan_code) {
if (ev.scan_code == KEY_BACKSPACE && i) {
if (ev.scan_code == KEY_BACKSPACE) {
if (!i)
continue;
buf[--i] = '\0';
move_cursor(LEFT);
terminal_putchar(' ');
@ -106,6 +107,7 @@ static char *get_line(void)
}
kprintf("\n");
screen->line[i] = '\0';
return screen->line;
}
void shell_init()