Set background color of text
@param string $text
@param string $status
@return string
@throws Exception
198299
public static function colorize($text, $status)
    {
        $out = "";
        switch ($status) {
            case "SUCCESS":
                $out = "[42m"; //Green background
                break;
            case "FAILURE":
                $out = "[41m"; //Red background
                break;
            case "WARNING":
                $out = "[43m"; //Yellow background
                break;
            case "NOTE":
                $out = "[44m"; //Blue background
                break;
            default:
                throw new Exception("Invalid status: " . $status);
        }
        return chr(27) . "$out" . "$text" . chr(27) . "[0m" . PHP_EOL;
    }
1293997
public function setStatus($status)
    {
        if (
            !in_array(
                $status,
                array(
                    self::STATUS_SUCCESS,
                    self::STATUS_ERROR,
                    self::STATUS_FAIL,
                )
            )
        ) {
            throw new Doozr_Base_Response_Rest_Exception(

            );
        }

        $this->status = $status;
    }
45014
public function write($text, $params=array())
    {
        $color = (isset($params['color'])) ?  $params['color'] : array(0, 0, 0);
        $color = imagecolorallocate($this->edited, $color[0], $color[1], $color[2]);
        $size = (isset($params['size']))? $params['size'] : 5;
        $x = (isset($params['x']))? $params['x'] : 2;
        $y = (isset($params['y']))? $params['y'] : 2;


        imagestring($this->edited, $size, $x, $y, $text, $color);
    }
396063
public function colorize(string $startColor, string $text, string $endColor = self::NORMAL): string
    {
        if ($this->getEnableColoredOutput()) {
            return $startColor . $text . $endColor;
        }

        return $text;
    }
623660
public function setText(string $text)
    {
        PregHelper::assertValidUTF8(
            $text,
            RegExpException::class,
            "Regular expression error on checking source text"
        );
        $this->text = $text;
        $this->textAtCursor = null;
        $this->cursor = 0;
        return $this;
    }
720083
public function format($text)
    {
        $lines = explode("\n", $text);
        foreach ($lines as &$line) {
            $line = ($this->quote) . str_repeat(' ', $this->indent) . $line;
        }
        return Colour::colour(implode("\n", $lines), $this->foregroundColors, $this->backgroundColors);
    }
952876
public function apply($text)
    {
        $setCodes = array();
        $unsetCodes = array();
        if (null !== $this->foreground) {
            $setCodes[] = $this->foreground['set'];
            $unsetCodes[] = $this->foreground['unset'];
        }
        if (null !== $this->background) {
            $setCodes[] = $this->background['set'];
            $unsetCodes[] = $this->background['unset'];
        }
        if (count($this->options)) {
            foreach ($this->options as $option) {
                $setCodes[] = $option['set'];
                $unsetCodes[] = $option['unset'];
            }
        }
        if (0 === count($setCodes)) {
            return $text;
        }
        return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes));
    }
661336
private function color($text, $fg, $bg = null)
    {
        if ($this->getConfig('use-colors')) {
            
            $colors = [];
            
            if ($fg != 'none') {
                $colors[] = sprintf('fg=%s', $fg);
            }
            
            if ($bg && $bg != 'none') {
                $colors[] = sprintf('bg=%s', $bg);
            }
            
            if (!empty($colors)) {
                return sprintf('<%s>%s</>', implode(';', $colors), $text);
            }
        }
        
        return $text;
    }
1149106
public function colors(string $text): string
    {
        $text = \str_replace(['<eol>', '<eol/>', '</eol>', "\r\n", "\n"], '__PHP_EOL__', $text);

        if (!\preg_match_all('/<(\w+)>(.*?)<\/end>/', $text, $matches)) {
            return \str_replace('__PHP_EOL__', \PHP_EOL, $text);
        }

        $end  = "\033[0m";
        $text = \str_replace(['<end>', '</end>'], $end, $text);

        foreach ($matches[1] as $i => $method) {
            $part = \str_replace($end, '', $this->{$method}(''));
            $text = \str_replace("<$method>", $part, $text);
        }

        return \str_replace('__PHP_EOL__', \PHP_EOL, $text);
    }
1184696
def set_textcolor(self, color):
        """"""
        self.textcolor = color
        self.relabel()
        if callable(self.theme_color_callback):
            self.theme_color_callback(color, 'text')
1352466
public static function colorize($text, $fgcolor = null, $bgcolor = null)
    {
        $colors = '';
        if ($bgcolor) {
            $colors .= self::getBgColorString(self::getColorCode($bgcolor));
        }
        if ($fgcolor) {
            $colors .= self::getFgColorString(self::getColorCode($fgcolor));
        }
        if ($colors) {
            $text = $colors . $text . self::RESET;
        }
        return $text;
    }
1299729
public function setStatusCode($statusCode, $text = null)
    {
        // Fallback status code message if missing
        if (! empty($text)) {
            $statusText = $text;
        } elseif (! empty(self::$statusTexts[$statusCode])) {
            $statusText = self::$statusTexts[$statusCode];
        } else {
            $statusText = 'Undefined code';
        }

        // Set status code and text
        $this->statusCode = $statusCode;
        $this->statusText = $statusText;

        // Validate status code
        if ($this->isInvalid()) {
            throw new InvalidArgumentException(sprintf('The HTTP status code "%s" is not valid.', $statusCode));
        }

        return $this;
    }
20080
public function setText($text) {
        $this->text = $text;
        $this->font->setText($this->text);
    }
781992
public function setStatusString($status)
    {
        $status = \array_search(\strtolower($status), TicketMessageInterface::STATUSES);

        if ($status > 0) {
            $this->setStatus($status);
        }

        return $this;
    }
567048
public static function createIncorrectStatus($status, \Exception $e = null)
    {
        $message = 'Expected server status to be "OK", got "%s" instead';

        return new static(sprintf($message, $status), null, $e);
    }
69289
public static function color($text, $color)
    {
        if (isset(ShellTool::$colors[$color])) {
            return ShellTool::$colors[$color]['start'] . $text . ShellTool::$colors[$color]['close'];
        } else {
            return $text;
        }
    }
924536
public static function colorify($text)
    {
        $htmldecoded = htmlspecialchars($text);
        $boldSqBracket = preg_replace('/\[([a-zA-Z]+)\]/', '[<span style="color: #000; font-weight: bold;">${1}</span>]', $htmldecoded);
        $boldBracket = preg_replace('/\{([a-zA-Z_ ]+)\}/', '{<span style="color: #000; font-weight: bold;">${1}</span>}', $boldSqBracket);
        return str_replace(self::$_search, self::$_replace, $boldBracket);
    }