diff --git a/src/cprintf.c b/src/cprintf.c index c48c9ce..6f7a36a 100644 --- a/src/cprintf.c +++ b/src/cprintf.c @@ -33,6 +33,7 @@ #define true ((_Bool) + 1u) #define false ((_Bool) + 0u) #endif +char *cprintf_base_color = "254;228;208"; static void print_rgb_fg_color(const char *_Nonnull color) { /* @@ -153,7 +154,7 @@ static const char *cfprintf_print_fg_color(FILE *_Nonnull stream, const char *_N } else if (strcmp(color, "{white}") == 0) { fprintf(stream, "\033[37m"); } else if (strcmp(color, "{base}") == 0) { - fprintf(stream, "%s", CPRINTF_BASE_FG_COLOR); + fprintf(stream, "\033[1;38;2;%sm", cprintf_base_color); } else if (strcmp(color, "{underline}") == 0) { fprintf(stream, "\033[4m"); } else if (strcmp(color, "{highlight}") == 0) { @@ -205,7 +206,7 @@ static const char *cprintf_print_fg_color(const char *_Nonnull buf) } else if (strcmp(color, "{white}") == 0) { printf("\033[37m"); } else if (strcmp(color, "{base}") == 0) { - printf("%s", CPRINTF_BASE_FG_COLOR); + printf("\033[1;38;2;%sm", cprintf_base_color); } else if (strcmp(color, "{underline}") == 0) { printf("\033[4m"); } else if (strcmp(color, "{highlight}") == 0) { @@ -257,7 +258,7 @@ static const char *cfprintf_print_bg_color(FILE *_Nonnull stream, const char *_N } else if (strcmp(color, "[white]") == 0) { fprintf(stream, "\033[47m"); } else if (strcmp(color, "[base]") == 0) { - fprintf(stream, "%s", CPRINTF_BASE_BG_COLOR); + fprintf(stream, "\033[1;48;2;%sm", cprintf_base_color); } else if (strcmp(color, "[underline]") == 0) { fprintf(stream, "\033[4m"); } else if (strcmp(color, "[highlight]") == 0) { @@ -309,7 +310,7 @@ static const char *cprintf_print_bg_color(const char *_Nonnull buf) } else if (strcmp(color, "[white]") == 0) { printf("\033[47m"); } else if (strcmp(color, "[base]") == 0) { - printf("%s", CPRINTF_BASE_BG_COLOR); + printf("\033[1;48;2;%sm", cprintf_base_color); } else if (strcmp(color, "[underline]") == 0) { printf("\033[4m"); } else if (strcmp(color, "[highlight]") == 0) { diff --git a/src/include/cprintf.h b/src/include/cprintf.h index 2cf3843..d35318b 100644 --- a/src/include/cprintf.h +++ b/src/include/cprintf.h @@ -47,8 +47,7 @@ void __cfprintf(FILE *_Nonnull stream, const char *_Nonnull buf); // We call snprintf() twice, but never mind, it's fast enough. #define cprintf_get_bufsize(format, ...) (snprintf(NULL, 0, format, ##__VA_ARGS__) > 0 ? (size_t)snprintf(NULL, 0, format, ##__VA_ARGS__) + 514 : 0) // The `base` color. -#define CPRINTF_BASE_FG_COLOR "\033[1;38;2;254;228;208m" -#define CPRINTF_BASE_BG_COLOR "\033[1;48;2;254;228;208m" +extern char *cprintf_base_color; /* * cprintf() is a macro, * first, we get the size of the string to print, @@ -78,4 +77,4 @@ void __cfprintf(FILE *_Nonnull stream, const char *_Nonnull buf); } \ } #define CPRINTF_MAJOR 1 -#define CPRINTF_MINOR 3 +#define CPRINTF_MINOR 4