From 5f0b72e53be917e1f8113500120c20ce7ad7dd38 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 24 Jun 2024 04:12:45 +0900 Subject: [PATCH] terminal-util: merge COLOR_ON with COLOR_24BIT Currently, we assume that there is no restriction on coloring when COLOR_24BIT. Let's merge the two values. Follow-up for a5efbf468c96190c9562bc8121eda32310dfd112. --- src/basic/terminal-util.c | 6 +++--- src/basic/terminal-util.h | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 787ae7abace..6712d7c89d8 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -1328,15 +1328,15 @@ static ColorMode parse_systemd_colors(void) { return COLOR_256; r = parse_boolean(e); if (r >= 0) - return r > 0 ? COLOR_ON : COLOR_OFF; + return r > 0 ? COLOR_24BIT : COLOR_OFF; return _COLOR_INVALID; } ColorMode get_color_mode(void) { /* Returns the mode used to choose output colors. The possible modes are COLOR_OFF for no colors, - * COLOR_16 for only the base 16 ANSI colors, COLOR_256 for more colors and COLOR_ON for unrestricted - * color output. For that we check $SYSTEMD_COLORS first (which is the explicit way to + * COLOR_16 for only the base 16 ANSI colors, COLOR_256 for more colors, and COLOR_24BIT for + * unrestricted color output. For that we check $SYSTEMD_COLORS first (which is the explicit way to * change the mode). If that didn't work we turn colors off unless we are on a TTY. And if we are on a TTY * we turn it off if $TERM is set to "dumb". There's one special tweak though: if we are PID 1 then we do not * check whether we are connected to a TTY, because we don't keep /dev/console open continuously due to fear diff --git a/src/basic/terminal-util.h b/src/basic/terminal-util.h index bdc46618c8f..addb69f7fae 100644 --- a/src/basic/terminal-util.h +++ b/src/basic/terminal-util.h @@ -122,16 +122,13 @@ typedef enum ColorMode { /* No colors, monochrome output. */ COLOR_OFF, - /* All colors, no restrictions. */ - COLOR_ON, - /* Only the base 16 colors. */ COLOR_16, /* Only 256 colors. */ COLOR_256, - /* For truecolor or 24bit color support. */ + /* For truecolor or 24bit color support, no restrictions. */ COLOR_24BIT, _COLOR_INVALID = -EINVAL,