]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/terminal-util: rename our replacement highlight-yellow and test both the origin... 16556/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 23 Jul 2020 08:53:48 +0000 (10:53 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 30 Jul 2020 12:43:02 +0000 (14:43 +0200)
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

src/basic/terminal-util.h
src/test/test-terminal-util.c

index 9e824b0eee79c1bd49a8de694a5a03a616501803..42a129c7ace349d87bc5b6d62314f55482ed0a2a 100644 (file)
 #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);
index d7af369d330100f731f498bfae933adcdb351ea5..003257111afd393dbebb26823cb38bf35e5b42b2 100644 (file)
@@ -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 },