Index: lib/src/io.dart |
diff --git a/lib/src/io.dart b/lib/src/io.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b279f3ee0ed62abbf51846a3d5684890847b5772 |
--- /dev/null |
+++ b/lib/src/io.dart |
@@ -0,0 +1,23 @@ |
+// Copyright (c) 2015, 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. |
+ |
+library unittest.io; |
+ |
+import 'dart:io'; |
+ |
+/// Whether "special" strings such as Unicode characters or color escapes are |
+/// safe to use. |
+/// |
+/// On Windows or when not printing to a terminal, only printable ASCII |
+/// characters should be used. |
+bool get canUseSpecialChars => |
+ Platform.operatingSystem != 'windows' && |
+ stdioType(stdout) == StdioType.TERMINAL; |
+ |
+/// Gets a "special" string (ANSI escape or Unicode). |
+/// |
+/// On Windows or when not printing to a terminal, returns something else since |
+/// those aren't supported. |
+String getSpecial(String special, [String onWindows = '']) => |
+ canUseSpecialChars ? special : onWindows; |