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

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

View File

@ -1,9 +1,6 @@
#include "keyboard.h"
#include "drivers.h"
#include "interrupts.h"
#include "kprintf.h"
#include "shell.h"
#include "string.h"
#include "terminal.h"
#include <stdbool.h>
#include <stdint.h>
@ -15,15 +12,15 @@ static struct key_event new_input = {};
void keyboard_handler(struct registers *regs)
{
(void)regs;
new_input_indicator = true;
new_input = terminal_getkey();
}
struct key_event get_key(void)
{
while (!new_input_indicator)
;
new_input_indicator = false;
return new_input;
}
}

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()