From 811b864045f1c440fe21a56802e7e20981578d6f Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 5 Dec 2018 14:54:20 -0600 Subject: Emit "FAILED: " in red if terminal supports ANSI color output --- src/build.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/build.cc b/src/build.cc index b392803..c1a88e9 100644 --- a/src/build.cc +++ b/src/build.cc @@ -138,7 +138,10 @@ void BuildStatus::BuildEdgeFinished(Edge* edge, o != edge->outputs_.end(); ++o) outputs += (*o)->path() + " "; - printer_.PrintOnNewLine("FAILED: " + outputs + "\n"); + if (printer_.supports_color()) + printer_.PrintOnNewLine("\x1B[31m" "FAILED: " "\x1B[0m" + outputs + "\n"); + else + printer_.PrintOnNewLine("FAILED: " + outputs + "\n"); printer_.PrintOnNewLine(edge->EvaluateCommand() + "\n"); } -- cgit v0.12 From 342b939bd3f32c43cf49825aa4ec7d8a8ba4cffd Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sun, 9 Dec 2018 21:53:23 -0600 Subject: Unset suports_color_ if SetConsoleMode fails on WIN32 --- src/line_printer.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/line_printer.cc b/src/line_printer.cc index 953982a..1f8eee1 100644 --- a/src/line_printer.cc +++ b/src/line_printer.cc @@ -54,7 +54,9 @@ LinePrinter::LinePrinter() : have_blank_line_(true), console_locked_(false) { if (supports_color_) { DWORD mode; if (GetConsoleMode(console_, &mode)) { - SetConsoleMode(console_, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING); + if (!SetConsoleMode(console_, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING)) { + supports_color_ = false; + } } } #endif -- cgit v0.12 From 85038a5947183e0ead7bd81d7b481228e1e0d13a Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Mon, 4 Feb 2019 17:02:15 -0600 Subject: Add braces to clarify conditional scope --- src/build.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/build.cc b/src/build.cc index c1a88e9..386fa65 100644 --- a/src/build.cc +++ b/src/build.cc @@ -138,10 +138,11 @@ void BuildStatus::BuildEdgeFinished(Edge* edge, o != edge->outputs_.end(); ++o) outputs += (*o)->path() + " "; - if (printer_.supports_color()) + if (printer_.supports_color()) { printer_.PrintOnNewLine("\x1B[31m" "FAILED: " "\x1B[0m" + outputs + "\n"); - else + } else { printer_.PrintOnNewLine("FAILED: " + outputs + "\n"); + } printer_.PrintOnNewLine(edge->EvaluateCommand() + "\n"); } -- cgit v0.12