OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, 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 import 'dart:io'; |
| 6 |
| 7 final _cyan = _getSpecial('\u001b[36m'); |
| 8 final _green = _getSpecial('\u001b[32m'); |
| 9 final _magenta = _getSpecial('\u001b[35m'); |
| 10 final _red = _getSpecial('\u001b[31m'); |
| 11 final _yellow = _getSpecial('\u001b[33m'); |
| 12 final _blue = _getSpecial('\u001b[34m'); |
| 13 final _gray = _getSpecial('\u001b[1;30m'); |
| 14 final _none = _getSpecial('\u001b[0m'); |
| 15 final _noColor = _getSpecial('\u001b[39m'); |
| 16 final _bold = _getSpecial('\u001b[1m'); |
| 17 |
| 18 void done(Object message) { |
| 19 print(" ${green('(DONE)')} $message"); |
| 20 } |
| 21 |
| 22 void note(Object message) { |
| 23 print(" ${cyan('(NOTE)')} $message"); |
| 24 } |
| 25 |
| 26 void todo(Object message) { |
| 27 print("${red('(TODO)')} $message"); |
| 28 } |
| 29 |
| 30 String bold(text) => "$_bold$text$_none"; |
| 31 |
| 32 String cyan(text) => "$_cyan$text$_noColor"; |
| 33 |
| 34 String green(text) => "$_green$text$_noColor"; |
| 35 |
| 36 String red(text) => "$_red$text$_noColor"; |
| 37 |
| 38 /// Gets a "special" string (ANSI escape or Unicode). |
| 39 /// |
| 40 /// On Windows or when not printing to a terminal, returns something else since |
| 41 /// those aren't supported. |
| 42 String _getSpecial(String special, [String onWindows = '']) { |
| 43 if (Platform.operatingSystem == 'windows' || |
| 44 stdioType(stdout) != StdioType.TERMINAL) { |
| 45 return onWindows; |
| 46 } |
| 47 |
| 48 return special; |
| 49 } |
OLD | NEW |