add: get_line

This commit is contained in:
Starnakin 2024-10-09 22:10:22 +02:00
parent 50b1487708
commit fc8bc6a495
3 changed files with 11 additions and 4 deletions

View File

@ -59,3 +59,4 @@ void terminal_set_default_bg_color(uint8_t fg_color);
void terminal_change_default_fg_color(uint8_t color);
uint8_t terminal_get_default_color(void);
uint8_t terminal_get_char(int column, int row);
char *get_line(void);

View File

@ -43,3 +43,11 @@ void keyboard_handler(struct registers *regs)
line_status = NEWLINE;
}
}
char *get_line(void)
{
while (line_status != NEWLINE)
;
line_status = READING;
return screen->line;
}

View File

@ -77,10 +77,9 @@ void auto_complete(void)
void shell_init(void)
{
char *line;
kprintf(PROMPT);
while (1) {
if (line_status != NEWLINE)
continue;
while ((line = get_line())) {
bool invalid = true;
for (unsigned i = 0; i < NB_CMDS; i++) {
if (!strncmp(cmds[i].name, screen->line,
@ -97,7 +96,6 @@ void shell_init(void)
kprintf(KERN_WARNING "invalid command: %s\n",
screen->line);
memset(screen->line, '\0', sizeof(screen->line));
line_status = READING;
kprintf(PROMPT);
}
}