diff --git a/headers/shell.h b/headers/shell.h index da0c8c0..e676f0f 100644 --- a/headers/shell.h +++ b/headers/shell.h @@ -49,13 +49,14 @@ typedef enum { POWEROFF, HALT, STACK, + CLEAR, ECHO, COLOR, MERDELLA, ERROR } CMD_TOK; +void shell_init(void); void reboot(void); void halt(void); -void shell_init(void); void print_stack(void); diff --git a/headers/terminal.h b/headers/terminal.h index 8997c65..a08c7f3 100644 --- a/headers/terminal.h +++ b/headers/terminal.h @@ -46,6 +46,7 @@ int terminal_write(const char *data, size_t size); int terminal_writestring(const char *data); int terminal_writelong(long number); void terminal_set_screen(int pos); +void terminal_clear(void); struct key_event terminal_getkey(void); void update_cursor(void); void move_cursor(int direction); diff --git a/src/shell/exec.c b/src/shell/exec.c index 17f0137..4924047 100644 --- a/src/shell/exec.c +++ b/src/shell/exec.c @@ -31,6 +31,8 @@ static CMD_TOK find_command(char *line) command = HALT; else if (!strcmp(line, "stack")) command = STACK; + else if (!strcmp(line, "clear")) + command = CLEAR; else if (!strcmp(line, "echo")) command = ECHO; else if (!strcmp(line, "color")) @@ -100,6 +102,9 @@ void shell_init(void) case STACK: print_stack(); break; + case CLEAR: + terminal_clear(); + break; case ECHO: kprintf(0, "echoing\n"); break; diff --git a/src/terminal/put.c b/src/terminal/put.c index 877009d..81e31de 100644 --- a/src/terminal/put.c +++ b/src/terminal/put.c @@ -76,6 +76,19 @@ static void terminal_new_line(void) terminal_scroll(); } +void terminal_clear(void) +{ + for (size_t y = 0; y < VGA_HEIGHT; y++) { + for (size_t x = 0; x < VGA_WIDTH; x++) { + const size_t index = y * VGA_WIDTH + x; + TERM_BUF[index] = vga_entry(' ', VGA_COLOR_WHITE); + } + } + memcpy(screen->buffer, TERM_BUF, sizeof(screen->buffer)); + screen->column = 0; + screen->row = 0; +} + int terminal_putchar(char c) { if (c == '\r')