OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, 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 library unittest.io; |
| 6 |
| 7 import 'dart:io'; |
| 8 |
| 9 /// Whether "special" strings such as Unicode characters or color escapes are |
| 10 /// safe to use. |
| 11 /// |
| 12 /// On Windows or when not printing to a terminal, only printable ASCII |
| 13 /// characters should be used. |
| 14 bool get canUseSpecialChars => |
| 15 Platform.operatingSystem != 'windows' && |
| 16 stdioType(stdout) == StdioType.TERMINAL; |
| 17 |
| 18 /// Gets a "special" string (ANSI escape or Unicode). |
| 19 /// |
| 20 /// On Windows or when not printing to a terminal, returns something else since |
| 21 /// those aren't supported. |
| 22 String getSpecial(String special, [String onWindows = '']) => |
| 23 canUseSpecialChars ? special : onWindows; |
OLD | NEW |