Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1094)

Unified Diff: pkg/analyzer_cli/lib/src/ansi.dart

Issue 2775633002: Use ansi color in the dartanalyzer cli output. (Closed)
Patch Set: make tests more robust Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | pkg/analyzer_cli/lib/src/error_formatter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/lib/src/ansi.dart
diff --git a/pkg/analyzer_cli/lib/src/ansi.dart b/pkg/analyzer_cli/lib/src/ansi.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f068cd50e2195af7331568646c9b169589b5a100
--- /dev/null
+++ b/pkg/analyzer_cli/lib/src/ansi.dart
@@ -0,0 +1,35 @@
+// 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;
+
+ String get cyan => _code('\u001b[36m');
+ String get green => _code('\u001b[32m');
+ String get magenta => _code('\u001b[35m');
+ String get red => _code('\u001b[31m');
+ String get yellow => _code('\u001b[33m');
+ String get blue => _code('\u001b[34m');
+ String get gray => _code('\u001b[1;30m');
+ String get none => _code('\u001b[0m');
+ String get noColor => _code('\u001b[39m');
+ String get bold => _code('\u001b[1m');
+
+ AnsiLogger(this.useAnsi);
+
+ String get bullet => (runningTests || !Platform.isWindows) ? '•' : '-';
+
+ String _code(String ansiCode) => useAnsi ? ansiCode : '';
+}
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | pkg/analyzer_cli/lib/src/error_formatter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698