chiark / gitweb /
systemctl: use underlines to seperate unit types in listing
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 17 Oct 2016 15:37:41 +0000 (11:37 -0400)
committerSven Eden <yamakuzure@gmx.net>
Wed, 5 Jul 2017 06:50:55 +0000 (08:50 +0200)
(printf("%.*s", -1, "…") is the same as not specifying the precision at all.)

v2: also underline highlighted (failing) units

Fixes #4137.

src/basic/terminal-util.h

index 561045871eae411c6c877b6f828dc7d6f92b815a..a55154472bd9dde7de8d0f91a0ad396646c471c5 100644 (file)
 #define ANSI_HIGHLIGHT_YELLOW "\x1B[0;1;33m"
 #define ANSI_HIGHLIGHT_BLUE "\x1B[0;1;34m"
 #define ANSI_HIGHLIGHT_UNDERLINE "\x1B[0;1;4m"
+#define ANSI_HIGHLIGHT_RED_UNDERLINE "\x1B[0;1;4;31m"
+#define ANSI_HIGHLIGHT_GREEN_UNDERLINE "\x1B[0;1;4;32m"
+#define ANSI_HIGHLIGHT_YELLOW_UNDERLINE "\x1B[0;1;4;33m"
+#define ANSI_HIGHLIGHT_BLUE_UNDERLINE "\x1B[0;1;4;34m"
 #define ANSI_NORMAL "\x1B[0m"
 
 #define ANSI_ERASE_TO_END_OF_LINE "\x1B[K"
@@ -125,6 +129,22 @@ static inline const char *ansi_highlight_blue(void) {
         return colors_enabled() ? ANSI_HIGHLIGHT_BLUE : "";
 }
 
+static inline const char *ansi_highlight_red_underline(void) {
+        return colors_enabled() ? ANSI_HIGHLIGHT_RED_UNDERLINE : "";
+}
+
+static inline const char *ansi_highlight_green_underline(void) {
+        return colors_enabled() ? ANSI_HIGHLIGHT_GREEN_UNDERLINE : "";
+}
+
+static inline const char *ansi_highlight_yellow_underline(void) {
+        return colors_enabled() ? ANSI_HIGHLIGHT_YELLOW_UNDERLINE : "";
+}
+
+static inline const char *ansi_highlight_blue_underline(void) {
+        return colors_enabled() ? ANSI_HIGHLIGHT_BLUE_UNDERLINE : "";
+}
+
 static inline const char *ansi_normal(void) {
         return colors_enabled() ? ANSI_NORMAL : "";
 }