Lines Matching refs:color
8 * Handles color output on (Linux) terminals
15 // these constants make IDE autocompletion easier, but color names can also be passed as strings
34 /** @var array known color names */
76 * enable color output
84 * disable color output
92 * @return bool is color support enabled?
100 * Convenience function to print a line in a given color
103 * @param string $color one of the available color names
108 public function ptln($line, $color, $channel = STDOUT)
110 $this->set($color, $channel);
116 * Returns the given text wrapped in the appropriate color and reset code
119 * @param string $color one of the available color names
123 public function wrap($text, $color)
125 return $this->getColorCode($color) . $text . $this->getColorCode('reset');
129 * Gets the appropriate terminal code for the given color
131 * @param string $color one of the available color names
132 * @return string color code
135 public function getColorCode($color)
140 if (!isset($this->colors[$color])) {
141 throw new Exception("No such color $color");
144 return $this->colors[$color];
148 * Set the given color for consecutive output
150 * @param string $color one of the supported color names
154 public function set($color, $channel = STDOUT)
156 fwrite($channel, $this->getColorCode($color));
160 * reset the terminal color