]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
terminal-util: regroup some functions
authorMike Yuan <me@yhndnzj.com>
Thu, 2 Jan 2025 15:12:35 +0000 (16:12 +0100)
committerMike Yuan <me@yhndnzj.com>
Thu, 2 Jan 2025 19:42:20 +0000 (20:42 +0100)
src/basic/terminal-util.h

index fc7a22e6a50d2a7dcebf59ca7765facf3af75f78..6433c0690748029dc9c046a871b3415bdcbfdc42 100644 (file)
@@ -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);