| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 /// Public for testing. | 7 /// Public for testing. |
| 8 bool runningTests = false; | 8 bool runningTests = false; |
| 9 | 9 |
| 10 bool terminalSupportsAnsi() { | 10 bool terminalSupportsAnsi() { |
| 11 return !runningTests && | 11 return !runningTests && |
| 12 !Platform.isWindows && | 12 !Platform.isWindows && |
| 13 stdioType(stdout) == StdioType.TERMINAL; | 13 stdioType(stdout) == StdioType.TERMINAL; |
| 14 } | 14 } |
| 15 | 15 |
| 16 class AnsiLogger { | 16 class AnsiLogger { |
| 17 final bool useAnsi; | 17 final bool useAnsi; |
| 18 | 18 |
| 19 AnsiLogger(this.useAnsi); |
| 20 String get blue => _code('\u001b[34m'); |
| 21 String get bold => _code('\u001b[1m'); |
| 22 String get bullet => (runningTests || !Platform.isWindows) ? '•' : '-'; |
| 19 String get cyan => _code('\u001b[36m'); | 23 String get cyan => _code('\u001b[36m'); |
| 24 String get gray => _code('\u001b[1;30m'); |
| 20 String get green => _code('\u001b[32m'); | 25 String get green => _code('\u001b[32m'); |
| 21 String get magenta => _code('\u001b[35m'); | 26 String get magenta => _code('\u001b[35m'); |
| 27 String get noColor => _code('\u001b[39m'); |
| 28 String get none => _code('\u001b[0m'); |
| 29 |
| 22 String get red => _code('\u001b[31m'); | 30 String get red => _code('\u001b[31m'); |
| 31 |
| 23 String get yellow => _code('\u001b[33m'); | 32 String get yellow => _code('\u001b[33m'); |
| 24 String get blue => _code('\u001b[34m'); | |
| 25 String get gray => _code('\u001b[1;30m'); | |
| 26 String get none => _code('\u001b[0m'); | |
| 27 String get noColor => _code('\u001b[39m'); | |
| 28 String get bold => _code('\u001b[1m'); | |
| 29 | |
| 30 AnsiLogger(this.useAnsi); | |
| 31 | |
| 32 String get bullet => (runningTests || !Platform.isWindows) ? '•' : '-'; | |
| 33 | 33 |
| 34 String _code(String ansiCode) => useAnsi ? ansiCode : ''; | 34 String _code(String ansiCode) => useAnsi ? ansiCode : ''; |
| 35 } | 35 } |
| OLD | NEW |