Development

Changeset 23182

You must first sign up to be able to contribute.

Changeset 23182

Show
Ignore:
Timestamp:
10/19/09 11:25:20 (5 months ago)
Author:
FabianLange
Message:

[lime] added support for colorized output under windows with ansicon (refs #7359)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/lime/trunk/lib/lime.php

    r19870 r23182  
    599599  static public $styles = array(); 
    600600 
    601   protected $force_colors = false; 
     601  protected $colorsSupported = false; 
    602602 
    603603  public function __construct($force_colors = false) 
    604604  { 
    605     $this->force_colors = $force_colors; 
     605    if ($force_colors) 
     606    { 
     607      $this->colorsSupported = true; 
     608    } 
     609    else 
     610    { 
     611      // colors are spported on windows with ansicon or on tty consoles 
     612      if (DIRECTORY_SEPARATOR == '\\') 
     613      { 
     614        $this->colorsSupported = null !== getenv('ANSICON'); 
     615      } 
     616      else 
     617      { 
     618        $this->colorsSupported = function_exists('posix_isatty') && @posix_isatty(STDOUT); 
     619      } 
     620    } 
    606621  } 
    607622 
     
    613628  public function colorize($text = '', $parameters = array()) 
    614629  { 
    615     // disable colors if not supported (windows or non tty console) 
    616     if (!$this->force_colors && (DIRECTORY_SEPARATOR == '\\' || !function_exists('posix_isatty') || !@posix_isatty(STDOUT))
     630 
     631    if (!$this->colorsSupported
    617632    { 
    618633      return $text; 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.