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

Unified Diff: runtime/bin/stdio_macos.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_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

Powered by Google App Engine
This is Rietveld 408576698