add: get_line
This commit is contained in:
parent
50b1487708
commit
fc8bc6a495
@ -59,3 +59,4 @@ void terminal_set_default_bg_color(uint8_t fg_color);
|
|||||||
void terminal_change_default_fg_color(uint8_t color);
|
void terminal_change_default_fg_color(uint8_t color);
|
||||||
uint8_t terminal_get_default_color(void);
|
uint8_t terminal_get_default_color(void);
|
||||||
uint8_t terminal_get_char(int column, int row);
|
uint8_t terminal_get_char(int column, int row);
|
||||||
|
char *get_line(void);
|
@ -43,3 +43,11 @@ void keyboard_handler(struct registers *regs)
|
|||||||
line_status = NEWLINE;
|
line_status = NEWLINE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *get_line(void)
|
||||||
|
{
|
||||||
|
while (line_status != NEWLINE)
|
||||||
|
;
|
||||||
|
line_status = READING;
|
||||||
|
return screen->line;
|
||||||
|
}
|
@ -77,10 +77,9 @@ void auto_complete(void)
|
|||||||
|
|
||||||
void shell_init(void)
|
void shell_init(void)
|
||||||
{
|
{
|
||||||
|
char *line;
|
||||||
kprintf(PROMPT);
|
kprintf(PROMPT);
|
||||||
while (1) {
|
while ((line = get_line())) {
|
||||||
if (line_status != NEWLINE)
|
|
||||||
continue;
|
|
||||||
bool invalid = true;
|
bool invalid = true;
|
||||||
for (unsigned i = 0; i < NB_CMDS; i++) {
|
for (unsigned i = 0; i < NB_CMDS; i++) {
|
||||||
if (!strncmp(cmds[i].name, screen->line,
|
if (!strncmp(cmds[i].name, screen->line,
|
||||||
@ -97,7 +96,6 @@ void shell_init(void)
|
|||||||
kprintf(KERN_WARNING "invalid command: %s\n",
|
kprintf(KERN_WARNING "invalid command: %s\n",
|
||||||
screen->line);
|
screen->line);
|
||||||
memset(screen->line, '\0', sizeof(screen->line));
|
memset(screen->line, '\0', sizeof(screen->line));
|
||||||
line_status = READING;
|
|
||||||
kprintf(PROMPT);
|
kprintf(PROMPT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user