built-in add -p: color the prompt and the help text
... just like the Perl version ;-) Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Dec 13, 2019 at 08:07 UTC
12c24cf850d280dd08dfe7361603b7089007fe3a
1 file changed
+8
-4
add-patch.c
+8
-4
@@ -334,9 +334,12 @@ static int patch_update_file(struct add_p_state *s)
334
strbuf_addstr(&s->buf, ",j");
335
if (hunk_index + 1 < s->hunk_nr)
336
strbuf_addstr(&s->buf, ",J");
337
- printf("(%"PRIuMAX"/%"PRIuMAX") ",
338
- (uintmax_t)hunk_index + 1, (uintmax_t)s->hunk_nr);
339
- printf(_("Stage this hunk [y,n,a,d%s,?]? "), s->buf.buf);
337
+ color_fprintf(stdout, s->s.prompt_color,
338
+ "(%"PRIuMAX"/%"PRIuMAX") ",
339
+ (uintmax_t)hunk_index + 1, (uintmax_t)s->hunk_nr);
340
+ color_fprintf(stdout, s->s.prompt_color,
341
+ _("Stage this hunk [y,n,a,d%s,?]? "),
342
+ s->buf.buf);
343
fflush(stdout);
344
if (strbuf_getline(&s->answer, stdin) == EOF)
345
break;
@@ -376,7 +379,8 @@ soft_increment:
379
else if (undecided_next >= 0 && s->answer.buf[0] == 'j')
380
hunk_index = undecided_next;
381
else
379
- puts(_(help_patch_text));
382
+ color_fprintf(stdout, s->s.help_color,
383
+ _(help_patch_text));
384
}
385
386
/* Any hunk to be used? */