From c9a9c627b6e2cb075cc962a7cafcf418bcbac63b Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 16 Mar 2017 18:04:14 -0700 Subject: [PATCH] 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. --- bin/flutter.ps1 | 34 ------------------- .../flutter_tools/lib/src/base/logger.dart | 10 +++--- 2 files changed, 6 insertions(+), 38 deletions(-) delete mode 100644 bin/flutter.ps1 diff --git a/bin/flutter.ps1 b/bin/flutter.ps1 deleted file mode 100644 index 8424379e53..0000000000 --- a/bin/flutter.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -# 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 diff --git a/packages/flutter_tools/lib/src/base/logger.dart b/packages/flutter_tools/lib/src/base/logger.dart index dd9d53af96..231ca02724 100644 --- a/packages/flutter_tools/lib/src/base/logger.dart +++ b/packages/flutter_tools/lib/src/base/logger.dart @@ -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';