feature: log level on kprintf (color)

fix: kprintf now uses concatenated strings for the flag
This commit is contained in:
2024-09-20 12:40:36 +02:00
parent 4cc1dba5f9
commit 2e41858c77
13 changed files with 99 additions and 81 deletions

View File

@ -32,19 +32,19 @@ static void help(void)
{
const size_t padding = 15;
kprintf(0, "%s\n", BORDER);
kprintf(0, " %s\n", HEADER);
kprintf(0, "%s\n", BORDER);
kprintf("%s\n", BORDER);
kprintf(" %s\n", HEADER);
kprintf("%s\n", BORDER);
for (size_t i = 0; i < sizeof(commands) / sizeof(commands[0]); i++) {
kprintf(0, " %s", commands[i].name);
kprintf(" %s", commands[i].name);
for (size_t j = 0; j < (padding - strlen(commands[i].name));
j++)
kprintf(0, " ");
kprintf(0, ": %s\n", commands[i].description);
kprintf(" ");
kprintf(": %s\n", commands[i].description);
}
kprintf(0, "%s\n", BORDER);
kprintf("%s\n", BORDER);
}
static void auto_complete(void)
@ -63,7 +63,7 @@ static void auto_complete(void)
return;
for (size_t i = len; last_match[i]; i++) {
screen->line[i] = last_match[i];
kprintf(0, "%c", screen->line[i]);
kprintf("%c", screen->line[i]);
}
}
@ -89,7 +89,7 @@ static void read_line(void)
} else if (ev.scan_code == KEY_TAB && i) {
auto_complete();
} else if (ev.c && i < size - 1) {
kprintf(0, "%c", ev.c);
kprintf("%c", ev.c);
buf[i++] = ev.c;
}
if (i >= size)
@ -97,14 +97,14 @@ static void read_line(void)
}
prev_scan_code = ev.scan_code;
}
kprintf(0, "\n");
kprintf("\n");
screen->line[i] = '\0';
}
void shell_init(void)
{
while (1) {
kprintf(0, PROMPT);
kprintf(PROMPT);
read_line();
bool invalid = true;
for (int i = 0; i < NB_CMDS; i++) {
@ -115,7 +115,7 @@ void shell_init(void)
}
}
if (invalid && screen->line[0])
kprintf(0, "invalid command: %s\n", screen->line);
kprintf("invalid command: %s\n", screen->line);
memset(screen->line, '\0', sizeof(screen->line));
}
}

View File

@ -3,5 +3,5 @@
void merdella(void)
{
kprintf(0, POOP);
kprintf(POOP);
}