Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import 'dart:io'; | |
| 6 | |
| 7 /// Public for testing. | |
| 8 bool runningTests = false; | |
| 9 | |
| 10 bool terminalSupportsAnsi() { | |
| 11 return !runningTests && | |
| 12 !Platform.isWindows && | |
|
karlklose
2017/03/24 09:08:08
Here is the detection code we use in fasta, which
devoncarew
2017/03/25 22:33:17
Thanks! Looks comprehensive. I know package:test a
| |
| 13 stdioType(stdout) == StdioType.TERMINAL; | |
| 14 } | |
| 15 | |
| 16 class AnsiLogger { | |
|
Brian Wilkerson
2017/03/23 17:09:51
Seems like this would be useful across multiple to
devoncarew
2017/03/25 22:33:17
Perhaps? I do like how lightweight our impl is, an
| |
| 17 final bool useAnsi; | |
| 18 | |
| 19 String get cyan => _code('\u001b[36m'); | |
| 20 String get green => _code('\u001b[32m'); | |
| 21 String get magenta => _code('\u001b[35m'); | |
| 22 String get red => _code('\u001b[31m'); | |
| 23 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 | |
| 34 String _code(String ansiCode) => useAnsi ? ansiCode : ''; | |
| 35 } | |
| OLD | NEW |