]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - include/colors.h
2 * SPDX-License-Identifier: LGPL-2.1-or-later
4 * Copyright (C) 2012 Ondrej Oprala <ooprala@redhat.com>
5 * Copyright (C) 2012-2014 Karel Zak <kzak@redhat.com>
7 * This file may be distributed under the terms of the
8 * GNU Lesser General Public License.
10 #ifndef UTIL_LINUX_COLORS_H
11 #define UTIL_LINUX_COLORS_H
16 #include "color-names.h"
20 UL_COLORMODE_AUTO
= 0,
25 __UL_NCOLORMODES
/* last */
28 #ifdef USE_COLORS_BY_DEFAULT
29 # define USAGE_COLORS_DEFAULT _("colors are enabled by default")
31 # define USAGE_COLORS_DEFAULT _("colors are disabled by default")
34 extern int colormode_from_string(const char *str
);
35 extern int colormode_or_err(const char *str
, const char *errmsg
);
37 /* Initialize the global variable UL_COLOR_TERM_OK */
38 extern int colors_init(int mode
, const char *util_name
);
41 extern int colors_wanted(void);
43 /* Returns UL_COLORMODE_* */
44 extern int colors_mode(void);
46 /* temporary enable/disable colors */
47 extern void colors_off(void);
48 extern void colors_on(void);
52 extern void color_fenable(const char *seq
, FILE *f
);
54 extern void color_scheme_fenable(const char *name
, const char *dflt
, FILE *f
);
55 extern const char *color_scheme_get_sequence(const char *name
, const char *dflt
);
57 static inline void color_enable(const char *seq
)
59 color_fenable(seq
, stdout
);
62 static inline void color_scheme_enable(const char *name
, const char *dflt
)
64 color_scheme_fenable(name
, dflt
, stdout
);
67 /* Reset colors to default */
68 extern void color_fdisable(FILE *f
);
70 static inline void color_disable(void)
72 color_fdisable(stdout
);
75 const char *color_get_disable_sequence(void);
77 #endif /* UTIL_LINUX_COLORS_H */