diff options
author | Karel Zak | 2014-05-05 16:22:43 +0200 |
---|---|---|
committer | Karel Zak | 2014-05-13 12:09:03 +0200 |
commit | 7a4704d82644adb1fa3c5ec7c1eba162ee860d08 (patch) | |
tree | a1704770ddcc5c8f0132eed4f7999ad85e6520f3 /include/colors.h | |
parent | lib/colors: allow to temporary disable colors (diff) | |
download | kernel-qcow2-util-linux-7a4704d82644adb1fa3c5ec7c1eba162ee860d08.tar.gz kernel-qcow2-util-linux-7a4704d82644adb1fa3c5ec7c1eba162ee860d08.tar.xz kernel-qcow2-util-linux-7a4704d82644adb1fa3c5ec7c1eba162ee860d08.zip |
lib/colors: support schemes customization
* parse terminal-colors.d/*.scheme files, expected format is
<name> <color-sequence>
* 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 <kzak@redhat.com>
Diffstat (limited to 'include/colors.h')
-rw-r--r-- | include/colors.h | 19 |
1 files changed, 13 insertions, 6 deletions
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 <ooprala@redhat.com> + * Copyright (C) 2012-2014 Karel Zak <kzak@redhat.com> * * 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 */ |