From 217bd588c2c0edd4a390d48e3fef07882fc714a8 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Thu, 2 Jan 2025 16:12:35 +0100 Subject: [PATCH] terminal-util: regroup some functions --- src/basic/terminal-util.h | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/basic/terminal-util.h b/src/basic/terminal-util.h index fc7a22e6a5..6433c06907 100644 --- a/src/basic/terminal-util.h +++ b/src/basic/terminal-util.h @@ -64,19 +64,6 @@ typedef enum AcquireTerminalFlags { int acquire_terminal(const char *name, AcquireTerminalFlags flags, usec_t timeout); int release_terminal(void); -/* Limits the use of ANSI colors to a subset. */ -typedef enum ColorMode { - COLOR_OFF, /* No colors, monochrome output. */ - COLOR_16, /* Only the base 16 colors. */ - COLOR_256, /* Only 256 colors. */ - COLOR_24BIT, /* For truecolor or 24bit color support, no restriction. */ - _COLOR_MODE_MAX, - _COLOR_MODE_INVALID = -EINVAL, -} ColorMode; - -const char* color_mode_to_string(ColorMode m) _const_; -ColorMode color_mode_from_string(const char *s) _pure_; - int terminal_vhangup_fd(int fd); int terminal_vhangup(const char *tty); @@ -117,15 +104,29 @@ void reset_terminal_feature_caches(void); bool on_tty(void); bool getenv_terminal_is_dumb(void); bool terminal_is_dumb(void); -ColorMode get_color_mode(void); -bool underline_enabled(void); -bool dev_console_colors_enabled(void); +/* Limits the use of ANSI colors to a subset. */ +typedef enum ColorMode { + COLOR_OFF, /* No colors, monochrome output. */ + COLOR_16, /* Only the base 16 colors. */ + COLOR_256, /* Only 256 colors. */ + COLOR_24BIT, /* For truecolor or 24bit color support, no restriction. */ + _COLOR_MODE_MAX, + _COLOR_MODE_INVALID = -EINVAL, +} ColorMode; + +const char* color_mode_to_string(ColorMode m) _const_; +ColorMode color_mode_from_string(const char *s) _pure_; + +ColorMode get_color_mode(void); static inline bool colors_enabled(void) { /* Returns true if colors are considered supported on our stdout. */ return get_color_mode() != COLOR_OFF; } +bool underline_enabled(void); +bool dev_console_colors_enabled(void); + int get_ctty_devnr(pid_t pid, dev_t *ret); int get_ctty(pid_t, dev_t *ret_devnr, char **ret);