feat(terminal): add BLACK color support

This commit is contained in:
Marcus Holland-Moritz 2025-05-28 09:29:43 +02:00
parent baa01a88e2
commit b57c3808e7
3 changed files with 10 additions and 0 deletions

View File

@ -36,6 +36,7 @@ namespace dwarfs {
enum class termcolor {
NORMAL,
BLACK,
RED,
GREEN,
YELLOW,
@ -44,6 +45,7 @@ enum class termcolor {
CYAN,
WHITE,
GRAY,
BOLD_BLACK,
BOLD_RED,
BOLD_GREEN,
BOLD_YELLOW,
@ -52,6 +54,7 @@ enum class termcolor {
BOLD_CYAN,
BOLD_WHITE,
BOLD_GRAY,
DIM_BLACK,
DIM_RED,
DIM_GREEN,
DIM_YELLOW,
@ -74,6 +77,7 @@ class terminal {
virtual bool is_fancy() const = 0;
virtual std::string_view
color(termcolor color, termstyle style = termstyle::NORMAL) const = 0;
virtual std::string_view bgcolor(termcolor color) const = 0;
virtual std::string
colored(std::string text, termcolor color, bool enable = true,
termstyle style = termstyle::NORMAL) const = 0;

View File

@ -140,6 +140,7 @@ std::string_view terminal_ansi::color_impl(termcolor color, termstyle style) {
// clang-format off
colors = {{
"\033[0m",
"\033[30m",
"\033[31m",
"\033[32m",
"\033[33m",
@ -148,6 +149,7 @@ std::string_view terminal_ansi::color_impl(termcolor color, termstyle style) {
"\033[36m",
"\033[37m",
"\033[90m",
"\033[1;30m",
"\033[1;31m",
"\033[1;32m",
"\033[1;33m",
@ -156,6 +158,7 @@ std::string_view terminal_ansi::color_impl(termcolor color, termstyle style) {
"\033[1;36m",
"\033[1;37m",
"\033[1;90m",
"\033[2;30m",
"\033[2;31m",
"\033[2;32m",
"\033[2;33m",

View File

@ -233,6 +233,7 @@ std::string_view test_terminal::color(termcolor color, termstyle style) const {
// clang-format off
colors = {{
"<normal>",
"<black>",
"<red>",
"<green>",
"<yellow>",
@ -241,6 +242,7 @@ std::string_view test_terminal::color(termcolor color, termstyle style) const {
"<cyan>",
"<white>",
"<gray>",
"<bold-black>",
"<bold-red>",
"<bold-green>",
"<bold-yellow>",
@ -249,6 +251,7 @@ std::string_view test_terminal::color(termcolor color, termstyle style) const {
"<bold-cyan>",
"<bold-white>",
"<bold-gray>",
"<dim-black>",
"<dim-red>",
"<dim-green>",
"<dim-yellow>",