Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/grep.c b/grep.c
index 42e915d762..b641305ff6 100644
--- a/grep.c
+++ b/grep.c
@@ -529,6 +529,7 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
const char *name, unsigned lno, char sign)
{
int rest = eol - bol;
+ char *line_color = NULL;
if (opt->pre_context || opt->post_context) {
if (opt->last_shown == 0) {
@@ -560,12 +561,18 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
int ch = *eol;
int eflags = 0;
+ if (sign == ':')
+ line_color = opt->color_selected;
+ else if (sign == '-')
+ line_color = opt->color_context;
+ else if (sign == '=')
+ line_color = opt->color_function;
*eol = '\0';
while (next_match(opt, bol, eol, ctx, &match, eflags)) {
if (match.rm_so == match.rm_eo)
break;
- opt->output(opt, bol, match.rm_so);
+ output_color(opt, bol, match.rm_so, line_color);
output_color(opt, bol + match.rm_so,
match.rm_eo - match.rm_so,
opt->color_match);
@@ -575,7 +582,7 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
}
*eol = ch;
}
- opt->output(opt, bol, rest);
+ output_color(opt, bol, rest, line_color);
opt->output(opt, "\n", 1);
}