From 5c55c289f761aa1e2efe969133038a39058db7d0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 3 Oct 2010 19:13:48 -0400 Subject: [PATCH] Adding support for uncoloured output for windows environments without ansicon. --- cake/console/console_output.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cake/console/console_output.php b/cake/console/console_output.php index 424df97cd..dd00f49e4 100644 --- a/cake/console/console_output.php +++ b/cake/console/console_output.php @@ -50,6 +50,13 @@ class ConsoleOutput { */ protected $_output; +/** + * Is set to true for consoles that can take pretty output. (Not windows). + * + * @var boolean + */ + protected $_prettyOutput = true; + /** * Constant for a newline. */ @@ -115,10 +122,17 @@ class ConsoleOutput { /** * Construct the output object. * + * Checks for a pretty console enviornment. Ansicon allows pretty consoles + * on windows, and is supported. + * * @return void */ public function __construct($stream = 'php://stdout') { $this->_output = fopen($stream, 'w'); + + if (DS == '\\') { + $this->_prettyOutput = (bool)env('ANSICON'); + } } /** @@ -143,6 +157,9 @@ class ConsoleOutput { * @return string String with color codes added. */ public function styleText($text) { + if (!$this->_prettyOutput) { + return strip_tags($text); + } return preg_replace_callback( '/<(?[a-z0-9-_]+)>(?.*)<\/(\1)>/i', array($this, '_replaceTags'), $text );