Index: runtime/bin/stdio_macos.cc |
diff --git a/runtime/bin/stdio_macos.cc b/runtime/bin/stdio_macos.cc |
index 5ed3d7e4e11349dfe444b67c0c8f3923a9882585..37ac894583dcdcfa33580481f01ceaacf4484a22 100644 |
--- a/runtime/bin/stdio_macos.cc |
+++ b/runtime/bin/stdio_macos.cc |
@@ -83,6 +83,21 @@ bool Stdin::SetLineMode(bool enabled) { |
} |
+static bool TermHasXTerm() { |
+ const char* term = getenv("TERM"); |
+ if (term == NULL) { |
+ return false; |
+ } |
+ return strstr(term, "xterm") != NULL; |
+} |
+ |
+ |
+bool Stdin::AnsiSupported(bool* supported) { |
+ *supported = isatty(STDIN_FILENO) && TermHasXTerm(); |
+ return true; |
+} |
+ |
+ |
bool Stdout::GetTerminalSize(intptr_t fd, int size[2]) { |
struct winsize w; |
int status = NO_RETRY_EXPECTED(ioctl(fd, TIOCGWINSZ, &w)); |
@@ -94,6 +109,12 @@ bool Stdout::GetTerminalSize(intptr_t fd, int size[2]) { |
return false; |
} |
+ |
+bool Stdout::AnsiSupported(intptr_t fd, bool* supported) { |
+ *supported = isatty(fd) && TermHasXTerm(); |
+ return true; |
+} |
+ |
} // namespace bin |
} // namespace dart |