svn: /phd/trunk/ package.xml phpdotnet/phd/BuildOptionsParser.php phpdotnet/phd/Config.php phpdotnet/phd/functions.php

From: Date: Wed, 07 Apr 2010 11:50:19 +0000
Subject: svn: /phd/trunk/ package.xml phpdotnet/phd/BuildOptionsParser.php phpdotnet/phd/Config.php phpdotnet/phd/functions.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-6327@lists.php.net to get a copy of this message
rquadling Wed, 07 Apr 2010 11:50:19 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=297613 Log: Re-enable coloured output on Windows, but not by default. Changed paths: U phd/trunk/package.xml U phd/trunk/phpdotnet/phd/BuildOptionsParser.php U phd/trunk/phpdotnet/phd/Config.php U phd/trunk/phpdotnet/phd/functions.php Modified: phd/trunk/package.xml =================================================================== --- phd/trunk/package.xml 2010-04-07 11:30:59 UTC (rev 297612) +++ phd/trunk/package.xml 2010-04-07 11:50:19 UTC (rev 297613) @@ -61,6 +61,7 @@ <notes> - Fixed #51346 - Extra whitespace when using &lt;type&gt; and plural (Daniel Egeberg) - Corrected grammar in Danish translation + fixed encoding (Daniel Egeberg) + - Allow colored output on Windows, but not by default (Richard Quadling) </notes> <contents> Modified: phd/trunk/phpdotnet/phd/BuildOptionsParser.php =================================================================== --- phd/trunk/phpdotnet/phd/BuildOptionsParser.php 2010-04-07 11:30:59 UTC (rev 297612) +++ phd/trunk/phpdotnet/phd/BuildOptionsParser.php 2010-04-07 11:50:19 UTC (rev 297613) @@ -4,6 +4,16 @@ class BuildOptionsParser { + public function __construct() + { + // By default, Windows does not support colors on the console. + // ANSICON by Jason Hood can be used to provide colors at the console. + // Color output can still be set via the command line parameters. + if('WIN' === strtoupper(substr(PHP_OS, 0, 3))) { + $this->option_color('color', 'off'); + } + } + public function getOptionList() { return array( @@ -229,15 +239,7 @@ } $val = self::boolval($v); if (is_bool($val)) { - if ($val && function_exists('posix_isatty')) { - Config::set_phd_info_color(posix_isatty(Config::phd_info_output()) ? '01;32' : false); // Bright (bold) green - Config::set_user_error_color(posix_isatty(Config::user_error_output()) ? '01;33' : false); // Bright (bold) yellow - Config::set_php_error_color(posix_isatty(Config::php_error_output()) ? '01;31' : false); // Bright (bold) red - } else { - Config::set_phd_info_color(false); - Config::set_user_error_color(false); - Config::set_php_error_color(false); - } + Config::setColor_output($val); } else { trigger_error("yes/no || on/off || true/false || 1/0 expected", E_USER_ERROR); } @@ -317,7 +319,7 @@ theme). (default: en) -c <bool> --color <bool> Enable color output when output is to a terminal - (default: true) + (default: true; On Windows the default is false) -C <filename> --css <filename> Link for an external CSS file. -g <classname> Modified: phd/trunk/phpdotnet/phd/Config.php =================================================================== --- phd/trunk/phpdotnet/phd/Config.php 2010-04-07 11:30:59 UTC (rev 297612) +++ phd/trunk/phpdotnet/phd/Config.php 2010-04-07 11:50:19 UTC (rev 297613) @@ -94,6 +94,30 @@ return $packageList; } + public static function setColor_output($color_output) + { + // Disable colored output if the terminal doesn't support colours + if ($color_output && function_exists('posix_isatty')) { + if (!posix_isatty(Config::phd_info_output())) { + Config::set_phd_info_color(false); + } + if (!posix_isatty(Config::phd_warning_output())) { + Config::set_phd_info_color(false); + } + if (!posix_isatty(Config::php_error_output())) { + Config::set_phd_info_color(false); + } + if (!posix_isatty(Config::user_error_output())) { + Config::set_phd_info_color(false); + } + } + self::$optionArray['color_output'] = $color_output; + } + + public static function set_color_output($color_output) + { + trigger_error('Use setColor_output()', E_USER_DEPRECATED); + } } /* Modified: phd/trunk/phpdotnet/phd/functions.php =================================================================== --- phd/trunk/phpdotnet/phd/functions.php 2010-04-07 11:30:59 UTC (rev 297612) +++ phd/trunk/phpdotnet/phd/functions.php 2010-04-07 11:50:19 UTC (rev 297613) @@ -50,8 +50,7 @@ /* {{{ Function to get a color escape sequence */ function term_color($text, $color) { - // Always disabled on Windows - return defined('PHP_WINDOWS_VERSION_BUILD') || $color === false ? $text : "\033[" . $color . "m" . $text . "\033[m"; + return Config::color_output() && $color !== false ? "\033[" . $color . "m" . $text . "\033[m" : $text; } /* }}} */

« previous php.doc.cvs (#6327) next »