Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(601)

Unified Diff: runtime/bin/stdio_android.cc

Issue 2753233002: [dart:io] Move Platform.ansiSupported to {Stdin,Stdout}.supportsAnsiEscapes (Closed)
Patch Set: Fix typo Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698