diff options
-rw-r--r-- | src/basic/log.c | 2 | ||||
-rw-r--r-- | src/basic/terminal-util.c | 22 | ||||
-rw-r--r-- | src/basic/terminal-util.h | 1 | ||||
-rw-r--r-- | src/journal/journal-verify.c | 4 | ||||
-rw-r--r-- | src/shared/ask-password-api.c | 2 | ||||
-rw-r--r-- | src/shared/json.c | 8 | ||||
-rw-r--r-- | src/shared/logs-show.c | 4 |
7 files changed, 21 insertions, 22 deletions
diff --git a/src/basic/log.c b/src/basic/log.c index dd9c7db18b..7d10ea262b 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -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; } diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 2baf337ab8..0092e3a2f5 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -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(); } } diff --git a/src/basic/terminal-util.h b/src/basic/terminal-util.h index 81a84b9bba..11a24b26b7 100644 --- a/src/basic/terminal-util.h +++ b/src/basic/terminal-util.h @@ -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); diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c index 4abaec9caa..b308ab328b 100644 --- a/src/journal/journal-verify.c +++ b/src/journal/journal-verify.c @@ -41,7 +41,9 @@ static void draw_progress(uint64_t p, usec_t *last_usec) { fputs("\r", stdout); if (colors_enabled()) - fputs("\x1B[?25l" ANSI_HIGHLIGHT_GREEN, stdout); + fputs("\x1B[?25l", stdout); + + fputs(ansi_highlight_green(), stdout); for (i = 0; i < j; i++) fputs("\xe2\x96\x88", stdout); diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c index eea1434be9..c8ce17ad5b 100644 --- a/src/shared/ask-password-api.c +++ b/src/shared/ask-password-api.c @@ -481,7 +481,7 @@ int ask_password_tty( if (!(flags & ASK_PASSWORD_SILENT) && !(flags & ASK_PASSWORD_ECHO)) { if (use_color) - (void) loop_write(ttyfd, ANSI_GREY, STRLEN(ANSI_GREY), false); + (void) loop_write(ttyfd, ansi_grey(), strlen(ansi_grey()), false); (void) loop_write(ttyfd, PRESS_TAB, strlen(PRESS_TAB), false); press_tab_visible = true; } diff --git a/src/shared/json.c b/src/shared/json.c index 28fe482749..491586cc1f 100644 --- a/src/shared/json.c +++ b/src/shared/json.c @@ -1495,7 +1495,7 @@ static void json_format_string(FILE *f, const char *q, JsonFormatFlags flags) { fputc('"', f); if (flags & JSON_FORMAT_COLOR) - fputs(ANSI_GREEN, f); + fputs(ansi_green(), f); for (; *q; q++) switch (*q) { @@ -1557,7 +1557,7 @@ static int json_format(FILE *f, JsonVariant *v, JsonFormatFlags flags, const cha return -errno; if (flags & JSON_FORMAT_COLOR) - fputs(ANSI_HIGHLIGHT_BLUE, f); + fputs(ansi_highlight_blue(), f); fprintf(f, "%.*Le", DECIMAL_DIG, json_variant_real(v)); @@ -1570,7 +1570,7 @@ static int json_format(FILE *f, JsonVariant *v, JsonFormatFlags flags, const cha case JSON_VARIANT_INTEGER: if (flags & JSON_FORMAT_COLOR) - fputs(ANSI_HIGHLIGHT_BLUE, f); + fputs(ansi_highlight_blue(), f); fprintf(f, "%" PRIdMAX, json_variant_integer(v)); @@ -1580,7 +1580,7 @@ static int json_format(FILE *f, JsonVariant *v, JsonFormatFlags flags, const cha case JSON_VARIANT_UNSIGNED: if (flags & JSON_FORMAT_COLOR) - fputs(ANSI_HIGHLIGHT_BLUE, f); + fputs(ansi_highlight_blue(), f); fprintf(f, "%" PRIuMAX, json_variant_unsigned(v)); diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index bf574d32a5..fc43690372 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -67,7 +67,7 @@ static int print_catalog(FILE *f, sd_journal *j) { prefix = "--"; if (colors_enabled()) - newline = strjoina(ANSI_NORMAL "\n" ANSI_GREY, prefix, ANSI_NORMAL " " ANSI_GREEN); + newline = strjoina(ANSI_NORMAL "\n", ansi_grey(), prefix, ANSI_NORMAL " ", ansi_green()); else newline = strjoina("\n", prefix, " "); @@ -76,7 +76,7 @@ static int print_catalog(FILE *f, sd_journal *j) { return log_oom(); if (colors_enabled()) - fprintf(f, ANSI_GREY "%s" ANSI_NORMAL " " ANSI_GREEN, prefix); + fprintf(f, "%s%s %s%s", ansi_grey(), prefix, ANSI_NORMAL, ansi_green()); else fprintf(f, "%s ", prefix); |