Compare commits

...

2 Commits

Author SHA1 Message Date
65a59534b4 Merge branch 'main' of git.chauvet.pro:starnakin/42_KFS 2024-09-17 13:58:10 +02:00
e316910581 feature: clear added to the shell 2024-09-17 13:57:52 +02:00
4 changed files with 21 additions and 1 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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')