From a8bc2e15d5dce3f343850ea3a8fd4f36a42e0ed3 Mon Sep 17 00:00:00 2001 From: jhuels <40254454+jhuels@users.noreply.github.com> Date: Tue, 16 Apr 2019 14:07:03 -0700 Subject: Feature/add term env dumb to win32 (#1550) Add reading of TERM variable for win32 dumb terminals --- src/line_printer.cc | 14 +++++++++----- 1 file 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_) { -- cgit v0.12