diff options
Diffstat (limited to 'grep.c')
-rw-r--r-- | grep.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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); } |