equal
deleted
inserted
replaced
780 return true; |
780 return true; |
781 } |
781 } |
782 |
782 |
783 function parse_shellcolor_string($str) |
783 function parse_shellcolor_string($str) |
784 { |
784 { |
|
785 // only compute this once (saves some CPU time) |
|
786 static $do_colors = null; |
|
787 if ( $do_colors === null ) |
|
788 { |
|
789 $do_colors = ( isset($_SERVER['TERM']) && $_SERVER['TERM'] != 'dumb' ); |
|
790 } |
|
791 |
785 $expr = '/<c ((?:[0-9]+)(?:;[0-9]+)*)>([\w\W]*?)<\/c>/'; |
792 $expr = '/<c ((?:[0-9]+)(?:;[0-9]+)*)>([\w\W]*?)<\/c>/'; |
786 while ( preg_match($expr, $str) ) |
793 while ( preg_match($expr, $str) ) |
787 $str = preg_replace($expr, "\x1B[\\1m\\2\x1B[0m", $str); |
794 $str = $do_colors ? preg_replace($expr, "\x1B[\\1m\\2\x1B[0m", $str) : preg_replace($expr, "\\2", $str); |
788 |
795 |
789 return $str; |
796 return $str; |
790 } |
797 } |
791 |
798 |