wip: fix the color change
This commit is contained in:
@ -4,22 +4,31 @@
|
||||
#include "utils.h"
|
||||
#include <stdint.h>
|
||||
|
||||
struct color {
|
||||
char *name;
|
||||
int value;
|
||||
};
|
||||
|
||||
void color_cmd(char *arg)
|
||||
{
|
||||
uint8_t tmp_color;
|
||||
static const char *colors[] = {
|
||||
"BLACK", "BLUE", "GREEN", "CYAN",
|
||||
"RED", "MAGENTA", "BROWN", "LIGHT_GREY",
|
||||
"DARK_GREY", "LIGHT_BLUE", "LIGHT_GREEN", "LIGHT_CYAN",
|
||||
"LIGHT_RED", "LIGHT_MAGENTA", "LIGHT_YELLOW", "WHITE",
|
||||
};
|
||||
static const struct color colors[] = {
|
||||
{"BLACK", 0x000000}, {"BLUE", 0x0000FF},
|
||||
{"GREEN", 0x008000}, {"CYAN", 0x00FFFF},
|
||||
{"RED", 0xFF0000}, {"MAGENTA", 0xFF00FF},
|
||||
{"BROWN", 0xA52A2A}, {"LIGHT_GREY", 0xD3D3D3},
|
||||
{"DARK_GREY", 0x555555}, {"LIGHT_BLUE", 0xADD8E6},
|
||||
{"LIGHT_GREEN", 0x90EE90}, {"LIGHT_CYAN", 0xE0FFFF},
|
||||
{"LIGHT_RED", 0xFF6666}, {"LIGHT_MAGENTA", 0xFF77FF},
|
||||
{"LIGHT_YELLOW", 0xFFFFE0}, {"WHITE", 0xFFFFFF}};
|
||||
|
||||
if (!arg)
|
||||
goto invalid;
|
||||
for (size_t i = 0; i < ARRAY_SIZE(colors); i++) {
|
||||
if (strcmp(colors[i], arg) == 0) {
|
||||
terminal_set_fg_color(i);
|
||||
terminal_refresh_color();
|
||||
if (strcmp(colors[i].name, arg) == 0) {
|
||||
terminal_set_fg_color(colors[i].value);
|
||||
kprintf("color: %s\n", colors[i].name);
|
||||
// terminal_refresh_color();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -28,8 +37,8 @@ invalid:
|
||||
kprintf(KERN_WARNING "Invalid argument\n");
|
||||
kprintf("Available colors: ");
|
||||
for (size_t i = 0; i < ARRAY_SIZE(colors); i++) {
|
||||
terminal_set_default_fg_color(i);
|
||||
kprintf(colors[i]);
|
||||
terminal_set_default_fg_color(colors[i].value);
|
||||
kprintf(colors[i].name);
|
||||
if (i != ARRAY_SIZE(colors) - 1)
|
||||
kprintf(", ");
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ static void terminal_new_line(void)
|
||||
|
||||
void terminal_refresh_color(void)
|
||||
{
|
||||
terminal_clear();
|
||||
// terminal_clear();
|
||||
for (uint32_t y = 0; y < VGA_HEIGHT; y++)
|
||||
for (uint32_t x = 0; x < VGA_WIDTH; x++)
|
||||
terminal_putentryat(
|
||||
|
||||
Reference in New Issue
Block a user