diff options
author | Ondrej Oprala | 2012-10-16 16:39:00 +0200 |
---|---|---|
committer | Karel Zak | 2012-10-16 16:39:00 +0200 |
commit | dfa68ad183617ef2a18e86ea7782c4e95c0f8e01 (patch) | |
tree | 32910ec412b43c5a26ed3527c012fd8b780e411d /lib/colors.c | |
parent | mount: add long options for -L and -U to man page (diff) | |
download | kernel-qcow2-util-linux-dfa68ad183617ef2a18e86ea7782c4e95c0f8e01.tar.gz kernel-qcow2-util-linux-dfa68ad183617ef2a18e86ea7782c4e95c0f8e01.tar.xz kernel-qcow2-util-linux-dfa68ad183617ef2a18e86ea7782c4e95c0f8e01.zip |
lib/color: add module for work with terminal colors
[kzak@redhat.com: - split from dmesg patch
- add more colors]
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/colors.c')
-rw-r--r-- | lib/colors.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/colors.c b/lib/colors.c new file mode 100644 index 000000000..bb9c057e1 --- /dev/null +++ b/lib/colors.c @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2012 Ondrej Oprala <ooprala@redhat.com> + * + * This file may be distributed under the terms of the + * GNU Lesser General Public License. + */ + +#include "colors.h" + +static int ul_color_term_ok; + +int colors_init(void) +{ + ul_color_term_ok = isatty(STDOUT_FILENO); + return ul_color_term_ok; +} + +void color_enable(const char *color_scheme) +{ + if (ul_color_term_ok) + fputs(color_scheme, stdout); +} + +void color_disable(void) +{ + if (ul_color_term_ok) + fputs(UL_COLOR_RESET, stdout); +} |