bigbiff bigbiff | e60683a | 2013-02-22 20:55:50 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Ondrej Oprala <ooprala@redhat.com> |
| 3 | * |
| 4 | * This file may be distributed under the terms of the |
| 5 | * GNU Lesser General Public License. |
| 6 | */ |
| 7 | |
| 8 | #include "colors.h" |
| 9 | |
| 10 | static int ul_color_term_ok; |
| 11 | |
| 12 | int colors_init(void) |
| 13 | { |
| 14 | ul_color_term_ok = isatty(STDOUT_FILENO); |
| 15 | return ul_color_term_ok; |
| 16 | } |
| 17 | |
| 18 | void color_enable(const char *color_scheme) |
| 19 | { |
| 20 | if (ul_color_term_ok) |
| 21 | fputs(color_scheme, stdout); |
| 22 | } |
| 23 | |
| 24 | void color_disable(void) |
| 25 | { |
| 26 | if (ul_color_term_ok) |
| 27 | fputs(UL_COLOR_RESET, stdout); |
| 28 | } |