From 7a4704d82644adb1fa3c5ec7c1eba162ee860d08 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 5 May 2014 16:22:43 +0200 Subject: lib/colors: support schemes customization * parse terminal-colors.d/*.scheme files, expected format is * supported color sequences: - color name (e.g. "red") - dir_colors compatible xx;yy (e.g. 01;31) where the sequence may contains control chars like \e \a ..etc. * scheme is parsed on demand Signed-off-by: Karel Zak --- include/colors.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'include/colors.h') diff --git a/include/colors.h b/include/colors.h index 392bf38f1..e8ab3951a 100644 --- a/include/colors.h +++ b/include/colors.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2012 Ondrej Oprala + * Copyright (C) 2012-2014 Karel Zak * * This file may be distributed under the terms of the * GNU Lesser General Public License. @@ -62,12 +63,18 @@ extern void colors_off(void); extern void colors_on(void); -/* Set the color to CLR_SCHEME */ -extern void color_fenable(const char *clr_scheme, FILE *f); +/* Set the color */ +extern void color_fenable(const char *seq, FILE *f); +extern void color_scheme_fenable(const char *name, const char *dflt, FILE *f); -static inline void color_enable(const char *clr_scheme) +static inline void color_enable(const char *seq) { - color_fenable(clr_scheme, stdout); + color_fenable(seq, stdout); +} + +static inline void color_scheme_enable(const char *name, const char *dflt) +{ + color_scheme_fenable(name, dflt, stdout); } /* Reset colors to default */ @@ -78,8 +85,8 @@ static inline void color_disable(void) color_fdisable(stdout); } - -extern const char *colorscheme_from_string(const char *str); +/* converts "red" to UL_COLOR_RED, etc. */ +extern const char *color_sequence_from_colorname(const char *str); #endif /* UTIL_LINUX_COLORS_H */ -- cgit v1.2.3-55-g7522