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