a10f6aac38
Change-Id: I4de3c9e17b4e569c32470ffd1c2061749d3184ed Reviewed-on: https://dart-review.googlesource.com/c/88439 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
36 lines
1.0 KiB
Dart
36 lines
1.0 KiB
Dart
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'dart:io';
|
|
|
|
/// Public for testing.
|
|
bool runningTests = false;
|
|
|
|
bool terminalSupportsAnsi() {
|
|
return !runningTests &&
|
|
!Platform.isWindows &&
|
|
stdioType(stdout) == StdioType.terminal;
|
|
}
|
|
|
|
class AnsiLogger {
|
|
final bool useAnsi;
|
|
|
|
AnsiLogger(this.useAnsi);
|
|
String get blue => _code('\u001b[34m');
|
|
String get bold => _code('\u001b[1m');
|
|
String get bullet => (runningTests || !Platform.isWindows) ? '•' : '-';
|
|
String get cyan => _code('\u001b[36m');
|
|
String get gray => _code('\u001b[1;30m');
|
|
String get green => _code('\u001b[32m');
|
|
String get magenta => _code('\u001b[35m');
|
|
String get noColor => _code('\u001b[39m');
|
|
String get none => _code('\u001b[0m');
|
|
|
|
String get red => _code('\u001b[31m');
|
|
|
|
String get yellow => _code('\u001b[33m');
|
|
|
|
String _code(String ansiCode) => useAnsi ? ansiCode : '';
|
|
}
|