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

Unified Diff: lib/compiler/implementation/colors.dart

Issue 10331010: Add support for --no-colors to make it easier to integrate dart2js in the editor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add bug number. Created 8 years, 8 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 | « no previous file | lib/compiler/implementation/dart2js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/colors.dart
diff --git a/lib/compiler/implementation/colors.dart b/lib/compiler/implementation/colors.dart
index c39f08100415c19b2ef4d958bde01f3c1e31e671..dcabedbee1ec88c69fa40d7b6148a3fff0a925db 100644
--- a/lib/compiler/implementation/colors.dart
+++ b/lib/compiler/implementation/colors.dart
@@ -9,6 +9,17 @@ final String RED_COLOR = '\u001b[31m';
final String MAGENTA_COLOR = '\u001b[35m';
final String NO_COLOR = '\u001b[0m';
-String green(String string) => "${GREEN_COLOR}$string${NO_COLOR}";
-String red(String string) => "${RED_COLOR}$string${NO_COLOR}";
-String magenta(String string) => "${MAGENTA_COLOR}$string${NO_COLOR}";
+// BUG(2654): This is a fairly hacky way of turning of coloring used
+// in messages. It would be better if the coloring could be dealt with
+// entirely by the user of the compiler API, but that is not the case
+// today.
+bool enabled = true;
+
+String wrap(String string, String color)
+ => enabled ? "${color}$string${NO_COLOR}" : string;
+String green(String string)
+ => wrap(string, GREEN_COLOR);
+String red(String string)
+ => wrap(string, RED_COLOR);
+String magenta(String string)
+ => wrap(string, MAGENTA_COLOR);
« no previous file with comments | « no previous file | lib/compiler/implementation/dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698