From 55f638bdc6507b3a2ce03290741f592934afaee7 Mon Sep 17 00:00:00 2001 From: Mark Lodato Date: Sun, 7 Mar 2010 11:52:46 -0500 Subject: grep: Colorize filename, line number, and separator Colorize the filename, line number, and separator in git grep output, as GNU grep does. The colors are customizable through color.grep.. The default is to only color the separator (in cyan), since this gives the biggest legibility increase without overwhelming the user with colors. GNU grep also defaults cyan for the separator, but defaults to magenta for the filename and to green for the line number, as well. There is one difference from GNU grep: When a binary file matches without -a, GNU grep does not color the in "Binary file matches", but we do. Like GNU grep, if --null is given, the null separators are not colored. For config.txt, use a a sub-list to describe the slots, rather than a single paragraph with parentheses, since this is much more readable. Remove the cast to int for `rm_eo - rm_so` since it is not necessary. Signed-off-by: Mark Lodato Signed-off-by: Junio C Hamano --- grep.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'grep.h') diff --git a/grep.h b/grep.h index 9703087996..36919ee217 100644 --- a/grep.h +++ b/grep.h @@ -84,7 +84,10 @@ struct grep_opt { int color; int max_depth; int funcname; + char color_filename[COLOR_MAXLEN]; + char color_lineno[COLOR_MAXLEN]; char color_match[COLOR_MAXLEN]; + char color_sep[COLOR_MAXLEN]; int regflags; unsigned pre_context; unsigned post_context; -- cgit v1.2.3 From 00588bb5cd4a7ff5e2b1ded97d4459bfe6aad6eb Mon Sep 17 00:00:00 2001 From: Mark Lodato Date: Sun, 7 Mar 2010 11:52:47 -0500 Subject: grep: Colorize selected, context, and function lines Colorize non-matching text of selected lines, context lines, and function name lines. The default for all three is no color, but they can be configured using color.grep.. The first two are similar to the corresponding options in GNU grep, except that GNU grep applies the color to the entire line, not just non-matching text. Signed-off-by: Mark Lodato Signed-off-by: Junio C Hamano --- grep.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'grep.h') diff --git a/grep.h b/grep.h index 36919ee217..2c4bdaca82 100644 --- a/grep.h +++ b/grep.h @@ -84,9 +84,12 @@ struct grep_opt { int color; int max_depth; int funcname; + char color_context[COLOR_MAXLEN]; char color_filename[COLOR_MAXLEN]; + char color_function[COLOR_MAXLEN]; char color_lineno[COLOR_MAXLEN]; char color_match[COLOR_MAXLEN]; + char color_selected[COLOR_MAXLEN]; char color_sep[COLOR_MAXLEN]; int regflags; unsigned pre_context; -- cgit v1.2.3