[PATCH libinput 4/4] test: highlight the various state machines with colors

Peter Hutterer peter.hutterer at who-t.net
Tue Mar 28 10:07:52 UTC 2017


Makes visual identification easier

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/libinput-util.h | 17 ++++++++++++++---
 test/litest.c       | 21 ++++++++++++++++++++-
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/libinput-util.h b/src/libinput-util.h
index 73af689..3fe0a02 100644
--- a/src/libinput-util.h
+++ b/src/libinput-util.h
@@ -53,9 +53,20 @@
 /* The HW DPI rate we normalize to before calculating pointer acceleration */
 #define DEFAULT_MOUSE_DPI 1000
 
-#define ANSI_HIGHLIGHT "\x1B[0;1;39m"
-#define ANSI_RED "\x1B[0;31m"
-#define ANSI_NORMAL "\x1B[0m"
+#define ANSI_HIGHLIGHT		"\x1B[0;1;39m"
+#define ANSI_RED		"\x1B[0;31m"
+#define ANSI_GREEN		"\x1B[0;32m"
+#define ANSI_YELLOW		"\x1B[0;33m"
+#define ANSI_BLUE		"\x1B[0;34m"
+#define ANSI_MAGENTA		"\x1B[0;35m"
+#define ANSI_CYAN		"\x1B[0;36m"
+#define ANSI_BRIGHT_RED		"\x1B[0;31;1m"
+#define ANSI_BRIGHT_GREEN	"\x1B[0;32;1m"
+#define ANSI_BRIGHT_YELLOW	"\x1B[0;33;1m"
+#define ANSI_BRIGHT_BLUE	"\x1B[0;34;1m"
+#define ANSI_BRIGHT_MAGENTA	"\x1B[0;35;1m"
+#define ANSI_BRIGHT_CYAN	"\x1B[0;36;1m"
+#define ANSI_NORMAL		"\x1B[0m"
 
 #define CASE_RETURN_STRING(a) case a: return #a
 
diff --git a/test/litest.c b/test/litest.c
index acba871..c7869e8 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -800,7 +800,7 @@ litest_log_handler(struct libinput *libinput,
 		break;
 	case LIBINPUT_LOG_PRIORITY_ERROR:
 		priority = "error";
-		color = ANSI_RED;
+		color = ANSI_BRIGHT_RED;
 		break;
 	case LIBINPUT_LOG_PRIORITY_DEBUG:
 		priority = "debug";
@@ -815,6 +815,25 @@ litest_log_handler(struct libinput *libinput,
 
 	if (had_newline)
 		fprintf(stderr, "%slitest %s ", color, priority);
+
+	if (strstr(format, "tap state:"))
+		color = ANSI_BLUE;
+	else if (strstr(format, "thumb state:"))
+		color = ANSI_YELLOW;
+	else if (strstr(format, "button state:"))
+		color = ANSI_MAGENTA;
+	else if (strstr(format, "touch-size:") ||
+		 strstr(format, "pressure:"))
+		color = ANSI_GREEN;
+	else if (strstr(format, "palm:") ||
+		 strstr(format, "thumb:"))
+		color = ANSI_CYAN;
+	else if (strstr(format, "edge state:"))
+		color = ANSI_BRIGHT_GREEN;
+
+	if (is_tty)
+		fprintf(stderr, "%s ", color);
+
 	vfprintf(stderr, format, args);
 	had_newline = strlen(format) >= 1 &&
 		      format[strlen(format) - 1] == '\n';
-- 
2.9.3



More information about the wayland-devel mailing list