mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-12 05:49:56 -04:00
fix: terminal detection was wrong
This commit is contained in:
parent
fbe188e540
commit
3c3de6ce9e
@ -169,10 +169,10 @@ class terminal_windows : public terminal_ansi {
|
|||||||
|
|
||||||
bool is_fancy(std::ostream& os) const override {
|
bool is_fancy(std::ostream& os) const override {
|
||||||
if (&os == &std::cout) {
|
if (&os == &std::cout) {
|
||||||
return true;
|
return ::_isatty(::_fileno(stdout));
|
||||||
}
|
}
|
||||||
if (&os == &std::cerr) {
|
if (&os == &std::cerr) {
|
||||||
return true;
|
return ::_isatty(::_fileno(stderr));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -189,14 +189,17 @@ class terminal_posix : public terminal_ansi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool is_fancy(std::ostream& os) const override {
|
bool is_fancy(std::ostream& os) const override {
|
||||||
if (&os == &std::cout && !::isatty(::fileno(stdout))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (&os == &std::cerr && !::isatty(::fileno(stderr))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
auto term = ::getenv("TERM");
|
auto term = ::getenv("TERM");
|
||||||
return term && term[0] != '\0' && ::strcmp(term, "dumb") != 0;
|
if (!term || term[0] == '\0' || std::string_view(term) == "dumb") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (&os == &std::cout) {
|
||||||
|
return ::isatty(::fileno(stdout));
|
||||||
|
}
|
||||||
|
if (&os == &std::cerr) {
|
||||||
|
return ::isatty(::fileno(stderr));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user