From c4fea19abbbc59b81ed275683a49cbecb0e69472 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Sun, 22 Nov 2020 02:37:27 +0100 Subject: [PATCH] basic/term-util: extend $SYSTEMD_COLORS This commit extends $SYSTEMD_COLORS to an enum variable (compared to a simple boolean) which specifies the "colors mode". This means that, in addition to disabling colors altogether, it's now possible to restrict the console output to 16 or 256 colors only. --- man/less-variables.xml | 9 ++-- src/basic/terminal-util.c | 69 ++++++++++++++++++++++--------- src/basic/terminal-util.h | 87 ++++++++++++++++++++++++++++----------- 3 files changed, 119 insertions(+), 46 deletions(-) diff --git a/man/less-variables.xml b/man/less-variables.xml index 3b32673f39..3d8e200e44 100644 --- a/man/less-variables.xml +++ b/man/less-variables.xml @@ -94,10 +94,11 @@ $SYSTEMD_COLORS - The value must be a boolean. Controls whether colorized output should be - generated. This can be specified to override the decision that systemd makes based - on $TERM and what the console is connected to. - + Takes a boolean argument. When true, systemd and related utilities + will use colors in their output, otherwise the output will be monochrome. Additionally, the variable can + take one of the following special values: 16, 256 to restrict the use + of colors to the base 16 or 256 ANSI colors, respectively. This can be specified to override the automatic + decision based on $TERM and what the console is connected to.