add: backspace work with vbe
This commit is contained in:
@ -2,7 +2,6 @@
|
||||
|
||||
#include "alloc.h"
|
||||
#include "commands.h"
|
||||
#include "ctype.h"
|
||||
#include "font.h"
|
||||
#include "kprintf.h"
|
||||
#include "shell.h"
|
||||
@ -58,7 +57,7 @@ void help_cmd(char *arg)
|
||||
kprintf("%s\n", BORDER);
|
||||
}
|
||||
|
||||
void auto_complete(void)
|
||||
static void auto_complete(void)
|
||||
{
|
||||
const size_t len = strlen(screen->line);
|
||||
int nb_matches = 0;
|
||||
@ -85,38 +84,36 @@ static char *get_line(void)
|
||||
{
|
||||
size_t i = 0;
|
||||
struct key_event ev;
|
||||
const size_t size = sizeof(screen->line);
|
||||
|
||||
while (1) {
|
||||
ev = get_key();
|
||||
if (!ev.scan_code)
|
||||
continue;
|
||||
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) {
|
||||
if (!i)
|
||||
continue;
|
||||
buf[--i] = '\0';
|
||||
move_cursor(LEFT);
|
||||
/* terminal_refresh(); */
|
||||
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)
|
||||
break;
|
||||
if (ev.scan_code == KEY_BACKSPACE) {
|
||||
if (!i)
|
||||
continue;
|
||||
terminal_remove_last_char();
|
||||
buf[--i] = '\0';
|
||||
} 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)
|
||||
break;
|
||||
}
|
||||
kprintf("\n");
|
||||
screen->line[i] = '\0';
|
||||
return screen->line;
|
||||
}
|
||||
|
||||
void shell_init()
|
||||
void shell_init(void)
|
||||
{
|
||||
while (1) {
|
||||
kprintf(PROMPT);
|
||||
|
Reference in New Issue
Block a user