]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - include/colors.h
2 * No copyright is claimed. This code is in the public domain; do with
5 * Authors: 2012 Ondrej Oprala <ooprala@redhat.com>
6 * 2012-2025 Karel Zak <kzak@redhat.com>
8 #ifndef UTIL_LINUX_COLORS_H
9 #define UTIL_LINUX_COLORS_H
14 #include "color-names.h"
18 UL_COLORMODE_AUTO
= 0,
23 __UL_NCOLORMODES
/* last */
26 #ifdef USE_COLORS_BY_DEFAULT
27 # define USAGE_COLORS_DEFAULT _("colors are enabled by default")
29 # define USAGE_COLORS_DEFAULT _("colors are disabled by default")
32 extern int colormode_from_string(const char *str
);
33 extern int colormode_or_err(const char *str
);
35 /* Initialize the global variable UL_COLOR_TERM_OK */
36 extern int colors_init(int mode
, const char *util_name
);
39 extern int colors_wanted(void);
41 /* Returns UL_COLORMODE_* */
42 extern int colors_mode(void);
44 /* temporary enable/disable colors */
45 extern void colors_off(void);
46 extern void colors_on(void);
50 extern void color_fenable(const char *seq
, FILE *f
);
52 extern void color_scheme_fenable(const char *name
, const char *dflt
, FILE *f
);
53 extern const char *color_scheme_get_sequence(const char *name
, const char *dflt
);
55 static inline void color_enable(const char *seq
)
57 color_fenable(seq
, stdout
);
60 static inline void color_scheme_enable(const char *name
, const char *dflt
)
62 color_scheme_fenable(name
, dflt
, stdout
);
65 /* Reset colors to default */
66 extern void color_fdisable(FILE *f
);
68 static inline void color_disable(void)
70 color_fdisable(stdout
);
73 const char *color_get_disable_sequence(void);
75 #endif /* UTIL_LINUX_COLORS_H */