Index: runtime/bin/stdio_android.cc |
diff --git a/runtime/bin/stdio_android.cc b/runtime/bin/stdio_android.cc |
index 8b264f814966242a6d3d5e94ca8f39cacc33ad22..e6b62501dab8d92405160c2f03bd07fa852599b3 100644 |
--- a/runtime/bin/stdio_android.cc |
+++ b/runtime/bin/stdio_android.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 |