From: Zbigniew Jędrzejewski-Szmek Date: Thu, 23 Jul 2020 08:53:48 +0000 (+0200) Subject: basic/terminal-util: rename our replacement highlight-yellow and test both the origin... X-Git-Tag: v247-rc1~452^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5ee27251cd77f4acf3a798b706d9074d37ef8f3f;p=thirdparty%2Fsystemd.git basic/terminal-util: rename our replacement highlight-yellow and test both the original and replacement The fact that we cannot use the "real" yellow color and need to use some other color is essentially a bug. In this particular case the issue is in urxvt, see a9009769de43b7f29d05017f4219e18c1e42a273. While we work around this by using a different color, let's not forget that this is just a (hopefullly temporary) workaround. https://bugzilla.redhat.com/show_bug.cgi?id=1859886 https://bugzilla.redhat.com/show_bug.cgi?id=1859889 https://bugzilla.redhat.com/show_bug.cgi?id=1859894 --- diff --git a/src/basic/terminal-util.h b/src/basic/terminal-util.h index 9e824b0eee7..42a129c7ace 100644 --- a/src/basic/terminal-util.h +++ b/src/basic/terminal-util.h @@ -33,16 +33,19 @@ #define ANSI_GREY "\x1B[0;38;5;245m" /* Bold/highlighted */ -#define ANSI_HIGHLIGHT_BLACK "\x1B[0;1;30m" -#define ANSI_HIGHLIGHT_RED "\x1B[0;1;31m" -#define ANSI_HIGHLIGHT_GREEN "\x1B[0;1;32m" -#define ANSI_HIGHLIGHT_YELLOW "\x1B[0;1;38;5;185m" -#define ANSI_HIGHLIGHT_BLUE "\x1B[0;1;34m" -#define ANSI_HIGHLIGHT_MAGENTA "\x1B[0;1;35m" -#define ANSI_HIGHLIGHT_CYAN "\x1B[0;1;36m" -#define ANSI_HIGHLIGHT_WHITE "\x1B[0;1;37m" -#define ANSI_HIGHLIGHT_GREY "\x1B[0;1;38;5;245m" -#define ANSI_HIGHLIGHT_YELLOW4 "\x1B[0;1;38;5;100m" +#define ANSI_HIGHLIGHT_BLACK "\x1B[0;1;30m" +#define ANSI_HIGHLIGHT_RED "\x1B[0;1;31m" +#define ANSI_HIGHLIGHT_GREEN "\x1B[0;1;32m" +#define _ANSI_HIGHLIGHT_YELLOW "\x1B[0;1;33m" /* This yellow is currently not displayed well by some terminals */ +#define ANSI_HIGHLIGHT_BLUE "\x1B[0;1;34m" +#define ANSI_HIGHLIGHT_MAGENTA "\x1B[0;1;35m" +#define ANSI_HIGHLIGHT_CYAN "\x1B[0;1;36m" +#define ANSI_HIGHLIGHT_WHITE "\x1B[0;1;37m" +#define ANSI_HIGHLIGHT_YELLOW4 "\x1B[0;1;38;5;100m" +#define ANSI_HIGHLIGHT_KHAKI3 "\x1B[0;1;38;5;185m" +#define ANSI_HIGHLIGHT_GREY "\x1B[0;1;38;5;245m" + +#define ANSI_HIGHLIGHT_YELLOW ANSI_HIGHLIGHT_KHAKI3 /* Replacement yellow that is more legible */ /* Underlined */ #define ANSI_GREY_UNDERLINE "\x1B[0;4;38;5;245m" @@ -170,6 +173,10 @@ DEFINE_ANSI_FUNC(highlight_cyan, HIGHLIGHT_CYAN); DEFINE_ANSI_FUNC(highlight_grey, HIGHLIGHT_GREY); DEFINE_ANSI_FUNC(highlight_white, HIGHLIGHT_WHITE); +static inline const char* _ansi_highlight_yellow(void) { + return colors_enabled() ? _ANSI_HIGHLIGHT_YELLOW : ""; +} + DEFINE_ANSI_FUNC_UNDERLINE(underline, UNDERLINE, NORMAL); DEFINE_ANSI_FUNC_UNDERLINE(highlight_underline, HIGHLIGHT_UNDERLINE, HIGHLIGHT); DEFINE_ANSI_FUNC_UNDERLINE(grey_underline, GREY_UNDERLINE, GREY); diff --git a/src/test/test-terminal-util.c b/src/test/test-terminal-util.c index d7af369d330..003257111af 100644 --- a/src/test/test-terminal-util.c +++ b/src/test/test-terminal-util.c @@ -111,7 +111,8 @@ static const Color colors[] = { { "highlight-black", ansi_highlight_black }, { "highlight-red", ansi_highlight_red }, { "highlight-green", ansi_highlight_green }, - { "highlight-yellow", ansi_highlight_yellow }, + { "highlight-yellow (original)", _ansi_highlight_yellow }, + { "highlight-yellow (replacement)", ansi_highlight_yellow }, { "highlight-blue", ansi_highlight_blue }, { "highlight-magenta", ansi_highlight_magenta }, { "highlight-cyan", ansi_highlight_cyan },