static volatile unsigned cached_lines = 0;
static volatile int cached_on_tty = -1;
-static volatile int cached_colors_enabled = -1;
static volatile int cached_color_mode = _COLOR_INVALID;
static volatile int cached_underline_enabled = -1;
cached_columns = 0;
cached_lines = 0;
- cached_colors_enabled = -1;
cached_color_mode = _COLOR_INVALID;
cached_underline_enabled = -1;
cached_on_tty = -1;
return cached_color_mode;
}
-bool colors_enabled(void) {
-
- /* Returns true if colors are considered supported on our stdout. */
-
- if (cached_colors_enabled < 0)
- cached_colors_enabled = get_color_mode() != COLOR_OFF;
-
- return cached_colors_enabled;
-}
-
bool dev_console_colors_enabled(void) {
_cleanup_free_ char *s = NULL;
ColorMode m;
bool on_tty(void);
bool terminal_is_dumb(void);
-bool colors_enabled(void);
ColorMode get_color_mode(void);
bool underline_enabled(void);
bool dev_console_colors_enabled(void);
+static inline bool colors_enabled(void) {
+
+ /* Returns true if colors are considered supported on our stdout. */
+ return get_color_mode() != COLOR_OFF;
+}
+
#define DEFINE_ANSI_FUNC(name, NAME) \
static inline const char *ansi_##name(void) { \
return colors_enabled() ? ANSI_##NAME : ""; \