]>
Commit | Line | Data |
---|---|---|
dfa68ad1 OO |
1 | /* |
2 | * Copyright (C) 2012 Ondrej Oprala <ooprala@redhat.com> | |
7a4704d8 | 3 | * Copyright (C) 2012-2014 Karel Zak <kzak@redhat.com> |
dfa68ad1 OO |
4 | * |
5 | * This file may be distributed under the terms of the | |
6 | * GNU Lesser General Public License. | |
7 | */ | |
8 | #ifndef UTIL_LINUX_COLORS_H | |
9 | #define UTIL_LINUX_COLORS_H | |
10 | ||
11 | #include <stdio.h> | |
12 | #include <unistd.h> | |
13 | ||
0bef6f75 | 14 | #include "color-names.h" |
62dc0ee8 | 15 | |
a10c0434 KZ |
16 | /* --color[=WHEN] */ |
17 | enum colortmode { | |
18 | UL_COLORMODE_AUTO = 0, | |
19 | UL_COLORMODE_NEVER, | |
20 | UL_COLORMODE_ALWAYS, | |
d0c9ddc3 | 21 | UL_COLORMODE_UNDEF, |
a10c0434 KZ |
22 | |
23 | __UL_NCOLORMODES /* last */ | |
24 | }; | |
25 | ||
62eea9ce | 26 | #ifdef USE_COLORS_BY_DEFAULT |
25c7b43e | 27 | # define USAGE_COLORS_DEFAULT _("colors are enabled by default") |
62dc0ee8 | 28 | #else |
25c7b43e | 29 | # define USAGE_COLORS_DEFAULT _("colors are disabled by default") |
62dc0ee8 KZ |
30 | #endif |
31 | ||
a10c0434 | 32 | extern int colormode_from_string(const char *str); |
b7faf991 | 33 | extern int colormode_or_err(const char *str, const char *errmsg); |
a10c0434 | 34 | |
d0c9ddc3 OO |
35 | /* Initialize the global variable UL_COLOR_TERM_OK */ |
36 | extern int colors_init(int mode, const char *util_name); | |
dfa68ad1 | 37 | |
80a1712f KZ |
38 | /* Returns 1 or 0 */ |
39 | extern int colors_wanted(void); | |
40 | ||
e66a6627 KZ |
41 | /* temporary enable/disable colors */ |
42 | extern void colors_off(void); | |
43 | extern void colors_on(void); | |
44 | ||
45 | ||
7a4704d8 KZ |
46 | /* Set the color */ |
47 | extern void color_fenable(const char *seq, FILE *f); | |
b8731ebc | 48 | |
7a4704d8 | 49 | extern void color_scheme_fenable(const char *name, const char *dflt, FILE *f); |
b8731ebc | 50 | extern const char *color_scheme_get_sequence(const char *name, const char *dflt); |
80a1712f | 51 | |
7a4704d8 | 52 | static inline void color_enable(const char *seq) |
80a1712f | 53 | { |
7a4704d8 KZ |
54 | color_fenable(seq, stdout); |
55 | } | |
56 | ||
57 | static inline void color_scheme_enable(const char *name, const char *dflt) | |
58 | { | |
59 | color_scheme_fenable(name, dflt, stdout); | |
80a1712f | 60 | } |
dfa68ad1 OO |
61 | |
62 | /* Reset colors to default */ | |
80a1712f KZ |
63 | extern void color_fdisable(FILE *f); |
64 | ||
65 | static inline void color_disable(void) | |
66 | { | |
67 | color_fdisable(stdout); | |
68 | } | |
69 | ||
dfa68ad1 | 70 | #endif /* UTIL_LINUX_COLORS_H */ |