fix: backspace printing + clean a few warnings/junk code
This commit is contained in:
		@ -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,13 +12,13 @@ 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;
 | 
			
		||||
 | 
			
		||||
@ -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()
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user