summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjhuels <40254454+jhuels@users.noreply.github.com>2019-04-16 14:07:03 -0700
committerJan Niklas Hasse <jhasse@bixense.com>2019-04-16 23:07:03 +0200
commita8bc2e15d5dce3f343850ea3a8fd4f36a42e0ed3 (patch)
treef484ec4a8bc1380d9fe67a295eb9f745e1d090e4
parent55279e640d40020307fc39feed1bfef7815421d9 (diff)
downloadninja-a8bc2e15d5dce3f343850ea3a8fd4f36a42e0ed3.tar.gz
Feature/add term env dumb to win32 (#1550)
Add reading of TERM variable for win32 dumb terminals
-rw-r--r--src/line_printer.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/line_printer.cc b/src/line_printer.cc
index 953982a..55469d9 100644
--- a/src/line_printer.cc
+++ b/src/line_printer.cc
@@ -31,18 +31,22 @@
#include "util.h"
LinePrinter::LinePrinter() : have_blank_line_(true), console_locked_(false) {
-#ifndef _WIN32
const char* term = getenv("TERM");
+#ifndef _WIN32
smart_terminal_ = isatty(1) && term && string(term) != "dumb";
#else
// Disable output buffer. It'd be nice to use line buffering but
// MSDN says: "For some systems, [_IOLBF] provides line
// buffering. However, for Win32, the behavior is the same as _IOFBF
// - Full Buffering."
- setvbuf(stdout, NULL, _IONBF, 0);
- console_ = GetStdHandle(STD_OUTPUT_HANDLE);
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- smart_terminal_ = GetConsoleScreenBufferInfo(console_, &csbi);
+ if (term && string(term) == "dumb") {
+ smart_terminal_ = false;
+ } else {
+ setvbuf(stdout, NULL, _IONBF, 0);
+ console_ = GetStdHandle(STD_OUTPUT_HANDLE);
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ smart_terminal_ = GetConsoleScreenBufferInfo(console_, &csbi);
+ }
#endif
supports_color_ = smart_terminal_;
if (!supports_color_) {