From f0175fe280bee86aa43cf4ca7bdfe6e9d0ec4816 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 15 Feb 2023 17:29:50 +0000 Subject: [PATCH] lib/colors: introduce color_get_disable_sequence() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Weißschuh --- include/colors.h | 2 ++ lib/colors.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/colors.h b/include/colors.h index d4ae4e4078..fe84d8bb90 100644 --- a/include/colors.h +++ b/include/colors.h @@ -70,4 +70,6 @@ static inline void color_disable(void) color_fdisable(stdout); } +const char *color_get_disable_sequence(void); + #endif /* UTIL_LINUX_COLORS_H */ diff --git a/lib/colors.c b/lib/colors.c index c4bc08d0fc..5f35392b9d 100644 --- a/lib/colors.c +++ b/lib/colors.c @@ -808,6 +808,17 @@ void color_fdisable(FILE *f) fputs(UL_COLOR_RESET, f); } +/* + * Get reset sequence + */ +const char *color_get_disable_sequence(void) +{ + if (!ul_colors.disabled && ul_colors.has_colors) + return UL_COLOR_RESET; + else + return ""; +} + /* * Parses @str to return UL_COLORMODE_* */ -- 2.47.2