Add GIT_COLOR_BOLD_* and GIT_COLOR_BG_*
Add GIT_COLOR_BOLD_* macros to set both bold and the color in one sequence. This saves two characters of output ("ESC [ m", minus ";") and makes the code more readable. Add the remaining GIT_COLOR_BG_* macros to make the list complete. The white and black colors are not included since they look bad on most terminals. Signed-off-by: Mark Lodato <lodatom@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Mark Lodato committed
Mar 7, 2010 at 11:52 UTC
758df17ab07a58e5b0f8effdf2d1b71fe8d79f1d
3 files changed
+18
-7
builtin-grep.c
+1
-1
@@ -871,7 +871,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
871
opt.regflags = REG_NEWLINE;
872
opt.max_depth = -1;
873
874
- strcpy(opt.color_match, GIT_COLOR_RED GIT_COLOR_BOLD);
874
+ strcpy(opt.color_match, GIT_COLOR_BOLD_RED);
875
opt.color = -1;
876
git_config(grep_config, &opt);
877
if (opt.color == -1)
color.h
+11
@@ -18,7 +18,18 @@
18
#define GIT_COLOR_BLUE "\033[34m"
19
#define GIT_COLOR_MAGENTA "\033[35m"
20
#define GIT_COLOR_CYAN "\033[36m"
21
+#define GIT_COLOR_BOLD_RED "\033[1;31m"
22
+#define GIT_COLOR_BOLD_GREEN "\033[1;32m"
23
+#define GIT_COLOR_BOLD_YELLOW "\033[1;33m"
24
+#define GIT_COLOR_BOLD_BLUE "\033[1;34m"
25
+#define GIT_COLOR_BOLD_MAGENTA "\033[1;35m"
26
+#define GIT_COLOR_BOLD_CYAN "\033[1;36m"
27
#define GIT_COLOR_BG_RED "\033[41m"
28
+#define GIT_COLOR_BG_GREEN "\033[42m"
29
+#define GIT_COLOR_BG_YELLOW "\033[43m"
30
+#define GIT_COLOR_BG_BLUE "\033[44m"
31
+#define GIT_COLOR_BG_MAGENTA "\033[45m"
32
+#define GIT_COLOR_BG_CYAN "\033[46m"
33
34
/*
35
* This variable stores the value of color.ui
graph.c
+6
-6
@@ -80,12 +80,12 @@ static char column_colors[][COLOR_MAXLEN] = {
80
GIT_COLOR_BLUE,
81
GIT_COLOR_MAGENTA,
82
GIT_COLOR_CYAN,
83
- GIT_COLOR_BOLD GIT_COLOR_RED,
84
- GIT_COLOR_BOLD GIT_COLOR_GREEN,
85
- GIT_COLOR_BOLD GIT_COLOR_YELLOW,
86
- GIT_COLOR_BOLD GIT_COLOR_BLUE,
87
- GIT_COLOR_BOLD GIT_COLOR_MAGENTA,
88
- GIT_COLOR_BOLD GIT_COLOR_CYAN,
83
+ GIT_COLOR_BOLD_RED,
84
+ GIT_COLOR_BOLD_GREEN,
85
+ GIT_COLOR_BOLD_YELLOW,
86
+ GIT_COLOR_BOLD_BLUE,
87
+ GIT_COLOR_BOLD_MAGENTA,
88
+ GIT_COLOR_BOLD_CYAN,
89
};
90
91
#define COLUMN_COLORS_MAX (ARRAY_SIZE(column_colors))