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

Unified Diff: runtime/bin/platform_win.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/platform_win.cc
diff --git a/runtime/bin/platform_win.cc b/runtime/bin/platform_win.cc
index 14f1a1f2458618d48eb7358302ffe4652dd53c69..53293024268d10d64ac94f5734632f3716d447ab 100644
--- a/runtime/bin/platform_win.cc
+++ b/runtime/bin/platform_win.cc
@@ -83,23 +83,18 @@ class PlatformWin {
SetConsoleOutputCP(CP_UTF8);
SetConsoleCP(CP_UTF8);
- ansi_supported_ = true;
+ // Try to set the bits for ANSI support, but swallow any failures.
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD out_mode;
if ((out != INVALID_HANDLE_VALUE) && GetConsoleMode(out, &out_mode)) {
const DWORD request = out_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
- ansi_supported_ = ansi_supported_ && SetConsoleMode(out, request);
- } else {
- ansi_supported_ = false;
+ SetConsoleMode(out, request);
}
-
HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
DWORD in_mode;
if ((in != INVALID_HANDLE_VALUE) && GetConsoleMode(in, &in_mode)) {
const DWORD request = in_mode | ENABLE_VIRTUAL_TERMINAL_INPUT;
- ansi_supported_ = ansi_supported_ && SetConsoleMode(in, request);
- } else {
- ansi_supported_ = false;
+ SetConsoleMode(in, request);
}
}
@@ -108,13 +103,10 @@ class PlatformWin {
RestoreConsoleLocked();
}
- static bool ansi_supported() { return ansi_supported_; }
-
private:
static Mutex* platform_win_mutex_;
static int saved_output_cp_;
static int saved_input_cp_;
- static bool ansi_supported_;
static void RestoreConsoleLocked() {
// STD_OUTPUT_HANDLE and STD_INPUT_HANDLE may have been closed or
@@ -179,7 +171,6 @@ class PlatformWin {
int PlatformWin::saved_output_cp_ = -1;
int PlatformWin::saved_input_cp_ = -1;
Mutex* PlatformWin::platform_win_mutex_ = NULL;
-bool PlatformWin::ansi_supported_ = false;
bool Platform::Initialize() {
PlatformWin::InitOnce();
@@ -276,11 +267,6 @@ const char* Platform::ResolveExecutablePath() {
}
-bool Platform::AnsiSupported() {
- return PlatformWin::ansi_supported();
-}
-
-
void Platform::Exit(int exit_code) {
// TODO(zra): Remove once VM shuts down cleanly.
::dart::private_flag_windows_run_tls_destructors = false;
« no previous file with comments | « runtime/bin/platform_unsupported.cc ('k') | runtime/bin/stdio.h » ('j') | runtime/bin/stdio.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698