summaryrefslogtreecommitdiff
path: root/color.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-03-20 18:29:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-03-20 18:29:36 (GMT)
commitd7173d942ea897b67ac9ba3bab2a0cc374684ca6 (patch)
tree30470f05d89570e5d2e125feb140b4b3da630a39 /color.h
parent49559cad6cab8af548321249d320d9bb372d1859 (diff)
parent8b124135a97b593d50a90abcec231552b31c7ade (diff)
downloadgit-d7173d942ea897b67ac9ba3bab2a0cc374684ca6.zip
git-d7173d942ea897b67ac9ba3bab2a0cc374684ca6.tar.gz
git-d7173d942ea897b67ac9ba3bab2a0cc374684ca6.tar.bz2
Merge branch 'jc/color-attrs'
* jc/color-attrs: color: allow multiple attributes
Diffstat (limited to 'color.h')
-rw-r--r--color.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/color.h b/color.h
index 3cb4b7f..bcb28cf 100644
--- a/color.h
+++ b/color.h
@@ -1,8 +1,20 @@
#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,