Skip to content

Commit

Permalink
Feature/add term env dumb to win32 (#1550)
Browse files Browse the repository at this point in the history
Add reading of TERM variable for win32 dumb terminals
  • Loading branch information
jhuels authored and jhasse committed Apr 16, 2019
1 parent 55279e6 commit a8bc2e1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/line_printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand Down

0 comments on commit a8bc2e1

Please sign in to comment.