feature: shell kb input is now working with interrupts (not clean tho, might need to change it)

This commit is contained in:
2024-10-09 20:26:44 +02:00
parent e5d7b80ed5
commit 50b1487708
7 changed files with 57 additions and 44 deletions

View File

@ -1,10 +1,45 @@
#include "drivers.h"
#include "interrupts.h"
#include "kprintf.h"
#include "shell.h"
#include "string.h"
#include "terminal.h"
#include <stdint.h>
extern struct screen *screen;
int line_status = READING;
void keyboard_handler(struct registers *regs)
{
size_t i = 0;
struct key_event ev;
(void)regs;
terminal_putchar(terminal_getkey().c);
ev = terminal_getkey();
char *buf = screen->line;
i = strlen(screen->line);
if (ev.c == '\n') {
kprintf("\n");
screen->line[i] = '\0';
line_status = NEWLINE;
return;
}
const size_t size = sizeof(screen->line);
if (ev.scan_code == KEY_BACKSPACE && i) {
buf[--i] = '\0';
move_cursor(LEFT);
terminal_putchar(' ');
move_cursor(LEFT);
} else if (ev.scan_code == KEY_TAB && i) {
auto_complete();
} else if (ev.c && i < size - 1) {
kprintf("%c", ev.c);
buf[i++] = ev.c;
}
if (i >= size) {
kprintf("\n");
screen->line[i] = '\0';
line_status = NEWLINE;
}
}