From 5ec8d9feb5301d5c485ca01f764d0842e1dcae5a Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Tue, 2 May 2017 23:46:47 +0100 Subject: [PATCH] highlight changes --- version.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/version.c b/version.c index 3c512a9ec..6432f864d 100644 --- a/version.c +++ b/version.c @@ -89,7 +89,7 @@ static const char *Notice = struct compile_options { const char *name; - int enabled; + bool enabled; }; /* These are sorted by the display string */ @@ -311,9 +311,9 @@ static struct compile_options comp_opts[] = { static void print_compile_options(void) { int i; - char c; int len; int used = 2; + bool tty = stdout ? isatty(fileno(stdout)) : false; printf(" "); for (i = 0; comp_opts[i].name; i++) @@ -325,8 +325,20 @@ static void print_compile_options(void) printf("\n "); } used += len; - c = comp_opts[i].enabled ? '+' : '-'; - printf("%c%s ", c, comp_opts[i].name); + if (comp_opts[i].enabled) + { + if (tty) + printf("\033[1;32m+%s\033[0m ", comp_opts[i].name); + else + printf("+%s ", comp_opts[i].name); + } + else + { + if (tty) + printf("\033[1;31m-%s\033[0m ", comp_opts[i].name); + else + printf("-%s ", comp_opts[i].name); + } } puts(""); } -- 2.40.0