author | Junio C Hamano <gitster@pobox.com> | |
Sat, 20 Mar 2010 18:29:36 +0000 (11:29 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 20 Mar 2010 18:29:36 +0000 (11:29 -0700) |
* jc/color-attrs:
color: allow multiple attributes
color: allow multiple attributes
1 | 2 | |||
---|---|---|---|---|
color.c | patch | | diff1 | | diff2 | | blob | history |
color.h | patch | | diff1 | | diff2 | | blob | history |
t/t4026-color.sh | patch | | diff1 | | diff2 | | blob | history |
diff --cc color.c
Simple merge
diff --cc color.h
index 3cb4b7fc890880b0fcf19a11c6bc7de6b10d6e8d,e2988f4e93f95ece2a1b0721fa8a17aa3f030756..bcb28cf10f2cbef11d9dba0e5a7f3f0515cbbd70
+++ b/color.h
#ifndef COLOR_H
#define COLOR_H
- /* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */
- #define COLOR_MAXLEN 24
+ /* 2 + (2 * num_attrs) + 8 + 1 + 8 + 'm' + NUL */
+ /* "\033[1;2;4;5;7;38;5;2xx;48;5;2xxm\0" */
+ /*
+ * The maximum length of ANSI color sequence we would generate:
+ * - leading ESC '[' 2
+ * - attr + ';' 2 * 8 (e.g. "1;")
+ * - fg color + ';' 9 (e.g. "38;5;2xx;")
+ * - fg color + ';' 9 (e.g. "48;5;2xx;")
+ * - terminating 'm' NUL 2
+ *
+ * The above overcounts attr (we only use 5 not 8) and one semicolon
+ * but it is close enough.
+ */
+ #define COLOR_MAXLEN 40
+/*
+ * IMPORTANT: Due to the way these color codes are emulated on Windows,
+ * write them only using printf(), fprintf(), and fputs(). In particular,
+ * do not use puts() or write().
+ */
+#define GIT_COLOR_NORMAL ""
+#define GIT_COLOR_RESET "\033[m"
+#define GIT_COLOR_BOLD "\033[1m"
+#define GIT_COLOR_RED "\033[31m"
+#define GIT_COLOR_GREEN "\033[32m"
+#define GIT_COLOR_YELLOW "\033[33m"
+#define GIT_COLOR_BLUE "\033[34m"
+#define GIT_COLOR_MAGENTA "\033[35m"
+#define GIT_COLOR_CYAN "\033[36m"
+#define GIT_COLOR_BG_RED "\033[41m"
+
/*
* This variable stores the value of color.ui
*/
diff --cc t/t4026-color.sh
Simple merge