tree-wide: avoid direct use of color macros

This commit is contained in:
rnhmjoj
2020-12-15 19:29:42 +01:00
parent c4fea19abb
commit 25e4608b8b
7 changed files with 21 additions and 22 deletions
+1 -1
View File
@@ -404,7 +404,7 @@ static int write_to_console(
if (show_location) {
const char *lon = "", *loff = "";
if (log_get_show_color()) {
lon = ANSI_HIGHLIGHT_YELLOW4;
lon = ansi_highlight_yellow4();
loff = ANSI_NORMAL;
}
+9 -13
View File
@@ -165,8 +165,7 @@ int ask_char(char *ret, const char *replies, const char *fmt, ...) {
char c;
bool need_nl = true;
if (colors_enabled())
fputs(ANSI_HIGHLIGHT, stdout);
fputs(ansi_highlight(), stdout);
putchar('\r');
@@ -174,8 +173,7 @@ int ask_char(char *ret, const char *replies, const char *fmt, ...) {
vprintf(fmt, ap);
va_end(ap);
if (colors_enabled())
fputs(ANSI_NORMAL, stdout);
fputs(ansi_normal(), stdout);
fflush(stdout);
@@ -214,15 +212,13 @@ int ask_string(char **ret, const char *text, ...) {
assert(ret);
assert(text);
if (colors_enabled())
fputs(ANSI_HIGHLIGHT, stdout);
fputs(ansi_highlight(), stdout);
va_start(ap, text);
vprintf(text, ap);
va_end(ap);
if (colors_enabled())
fputs(ANSI_NORMAL, stdout);
fputs(ansi_normal(), stdout);
fflush(stdout);
@@ -1384,7 +1380,7 @@ void get_log_colors(int priority, const char **on, const char **off, const char
if (priority <= LOG_ERR) {
if (on)
*on = ANSI_HIGHLIGHT_RED;
*on = ansi_highlight_red();
if (off)
*off = ANSI_NORMAL;
if (highlight)
@@ -1392,7 +1388,7 @@ void get_log_colors(int priority, const char **on, const char **off, const char
} else if (priority <= LOG_WARNING) {
if (on)
*on = ANSI_HIGHLIGHT_YELLOW;
*on = ansi_highlight_yellow();
if (off)
*off = ANSI_NORMAL;
if (highlight)
@@ -1404,14 +1400,14 @@ void get_log_colors(int priority, const char **on, const char **off, const char
if (off)
*off = ANSI_NORMAL;
if (highlight)
*highlight = ANSI_HIGHLIGHT_RED;
*highlight = ansi_highlight_red();
} else if (priority >= LOG_DEBUG) {
if (on)
*on = ANSI_GREY;
*on = ansi_grey();
if (off)
*off = ANSI_NORMAL;
if (highlight)
*highlight = ANSI_HIGHLIGHT_RED;
*highlight = ansi_highlight_red();
}
}
+1
View File
@@ -208,6 +208,7 @@ DEFINE_ANSI_FUNC(highlight_black, HIGHLIGHT_BLACK);
DEFINE_ANSI_FUNC(highlight_red, HIGHLIGHT_RED);
DEFINE_ANSI_FUNC(highlight_green, HIGHLIGHT_GREEN);
DEFINE_ANSI_FUNC_256(highlight_yellow, HIGHLIGHT_YELLOW, HIGHLIGHT_YELLOW_FALLBACK);
DEFINE_ANSI_FUNC_256(highlight_yellow4, HIGHLIGHT_YELLOW4, HIGHLIGHT_YELLOW_FALLBACK);
DEFINE_ANSI_FUNC(highlight_blue, HIGHLIGHT_BLUE);
DEFINE_ANSI_FUNC(highlight_magenta, HIGHLIGHT_MAGENTA);
DEFINE_ANSI_FUNC(highlight_cyan, HIGHLIGHT_CYAN);