Commit c9a9c627 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Remove nasty ANSI workaround for Windows (#8839)

The problem has been fixed upstream in the Dart VM.

This simplifies our setup instructions on Windows (will update the wiki).
Furthermore, this also means that going forward there is no diffrence between PowerShell and Cmd for the Flutter experience on Windows.
parent 2291a568
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This is a wrapper arround flutter.bat, which checks if the terminal supports
# ANSI codes to work around https://github.com/dart-lang/sdk/issues/28614.
$ErrorActionPreference = "Stop"
Add-Type -MemberDefinition @"
[DllImport("kernel32.dll", SetLastError=true)]
public static extern bool SetConsoleMode(IntPtr hConsoleHandle, int mode);
[DllImport("kernel32.dll", SetLastError=true)]
public static extern IntPtr GetStdHandle(int handle);
[DllImport("kernel32.dll", SetLastError=true)]
public static extern bool GetConsoleMode(IntPtr handle, out int mode);
"@ -Namespace Win32 -Name NativeMethods
If (Test-Path Env:\FLUTTER_ANSI_TERMINAL) { Remove-Item Env:\FLUTTER_ANSI_TERMINAL }
$stdout = [Win32.NativeMethods]::GetStdHandle(-11) # STD_OUTPUT_HANDLE
If ($stdout -ne -1) {
$mode = 0
If ([Win32.NativeMethods]::GetConsoleMode($stdout, [ref]$mode)) {
$mode = $mode -bor 4 # ENABLE_VIRTUAL_TERMINAL_PROCESSING
If ([Win32.NativeMethods]::SetConsoleMode($stdout, $mode)) {
$env:FLUTTER_ANSI_TERMINAL = "true"
}
}
}
# Cannot use $PSScriptRoot as that requires PowerShell 3 or newer
$scriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
& $scriptRoot\flutter.bat $args
exit $LastExitCode
......@@ -249,10 +249,12 @@ enum _LogType {
class AnsiTerminal {
AnsiTerminal() {
final String term = platform.environment['TERM'];
// FLUTTER_ANSI_TERMINAL is a work-around for https://github.com/dart-lang/sdk/issues/28614
final bool flutterAnsiTerm = platform.environment.containsKey('FLUTTER_ANSI_TERMINAL');
supportsColor = (term != null && term != 'dumb') || flutterAnsiTerm;
if (platform.isWindows) {
supportsColor = platform.ansiSupported;
} else {
final String term = platform.environment['TERM'];
supportsColor = (term != null && term != 'dumb');
}
}
static const String _bold = '\u001B[1m';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment