Permalink
Browse files

Add API for getting ANSI status

  • Loading branch information...
1 parent 45f7bd6 commit ab7b1d7d2e1fa5f84437037bc1a6d3297ea38308 vrana committed Aug 8, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/console/PhutilConsoleFormatter.php
@@ -39,9 +39,7 @@ public static function disableANSI($disable) {
self::$disableANSI = $disable;
}
- public static function formatString($format /* ... */) {
- $colors = implode('|', array_keys(self::$colorCodes));
-
+ public static function getDisableANSI() {
if (self::$disableANSI === null) {
if (phutil_is_windows()) {
self::$disableANSI = true;
@@ -51,14 +49,19 @@ public static function formatString($format /* ... */) {
self::$disableANSI = false;
}
}
+ return self::$disableANSI;
+ }
+
+ public static function formatString($format /* ... */) {
+ $colors = implode('|', array_keys(self::$colorCodes));
// Sequence should be preceded by start-of-string or non-backslash
// escaping.
$bold_re = '/(?<=^|[^\\\\])\*\*(.*)\*\*/sU';
$underline_re = '/(?<=^|[^\\\\])__(.*)__/sU';
$invert_re = '/(?<=^|[^\\\\])##(.*)##/sU';
- if (self::$disableANSI) {
+ if (self::getDisableANSI()) {
$format = preg_replace($bold_re, '\1', $format);
$format = preg_replace($underline_re, '\1', $format);
$format = preg_replace($invert_re, '\1', $format);

0 comments on commit ab7b1d7

Please sign in to comment.