Return colored string for readline action
@param string $string message
@param string|null $foreground_color Foreground color
@param string|null $background_color Background color
@return string Colored string
501001
public function getColoredStringReadLine(
        string $string,
        string $foreground_color = null,
        string $background_color = null
    ):string {
        $string = $this->resizeContent($string, 0);
        $colored_string = "";

        // Check if given foreground color found
        if (isset($this->foreground_colors[$foreground_color])) {
            $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m";
        }
        // Check if given background color found
        if (isset($this->background_colors[$background_color])) {
            $colored_string .= "\033[" . $this->background_colors[$background_color] . "m";
        }

        // Add string and end coloring
        $colored_string .=  $string . "\033[0m";

        return ($colored_string);
    }
7648
public static function line( $str, $color = null, $background = null ) 
	{
		if ( is_array( $str ) ) 
		{
			$str = implode( PHP_EOL, $str );
		}
		
		static::write( $str.PHP_EOL, $color, $background );
	}
547853
public static function colorize($string, $color)
    {
        if (isset(self::$colors[$color])) {
            return "\033[" . self::$colors[$color] . 'm' . $string . "\033[0m";
        }

        return $string;
    }
966845
public static function stringToValue($string)
	{
		if($string == '')
		{
			return $string;
		}
		if(is_float($string))
		{
			return (float) $string;
		}
		if(is_int($string))
		{
			return (int) $string;
		}
		if(strtolower($string) == 'true')
		{
			return true;
		}
		if(strtolower($string) == 'false')
		{
			return false;
		}
		if(strtolower($string) == 'null')
		{
			return NULL;
		}
		
		return $string;
	}
1304558
private String getInputFontColor(String backgroundColor) {

        if ((backgroundColor != null) && (backgroundColor.indexOf("#") == 0)) {
            // remove the "#" from the color string
            backgroundColor = backgroundColor.substring(1);
            int colorValue = 50001;
            try {
                // calculate int value of color
                colorValue = Integer.parseInt(backgroundColor, 16);
            } catch (NumberFormatException nf) {
                // this should never happen
            }
            if (colorValue < 50000) {
                // for dark colors set font color to white
                return "#FFFFFF";
            } else {
                // for other colors use black
                return "#000000";
            }
        }
        return "#000000";
    }
493533
public function prompt($string, $default = null) {
        if ($default !== null) {
            $suffix = (string) $default;
            $question = "<question>$string</question> [<yellow>$suffix</yellow>]: ";
        } else {
            $question = "<question>$string</question>: ";
        }

        $this->output->write($question);
        $input = $this->input->readLine();

        if (strlen($input) == 0) {
            $input = $default;
        }

        if ($input === null) {
            return $this->prompt($string, $default);
        }

        return $input;
    }
1152415
def color_string(color, string):
    
    if not color_available:
        return string

    return color + string + colorama.Fore.RESET
621614
public static function dump($string, $color = null, $debug = true)
    {
        if ($debug) {
            print self::formatOutput($string, $color);
            static::flush();
        }
    }
1012533
def console_get_char_foreground(
    con: tcod.console.Console, x: int, y: int
) -> Color:
    
    return Color._new_from_cdata(
        lib.TCOD_console_get_char_foreground(_console(con), x, y)
    )
787673
public static function getBackgroundCode($backgroundColour)
    {
        if (!isset(self::$background_colours[$backgroundColour])) {
            throw new \Exception('Invalid background colour.');
        }
        return "\033[" . self::$background_colours[$backgroundColour] . 'm';
    }
821300
public function getImageDataUri($string, $size = 64, $color = null, $backgroundColor = null)
    {
        return sprintf('data:%s;base64,%s', $this->generator->getMimeType(), base64_encode($this->getImageData($string, $size, $color, $backgroundColor)));
    }
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;
    }
448140
public static function fromHexString(string $string) : Colour
    {
        list($r, $g, $b) = ColourStringParser::parseHexString($string);

        return new self($r, $g, $b);
    }
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;
    }
1012487
private function getColoredString($string, $fgColor = null)
    {
        $colored = "";

        // Check if given foreground color found
        if (isset($this->fgColors[$fgColor])) {
            $colored .= "\033[" . $this->fgColors[$fgColor] . "m";
        }

        // Add string and end coloring
        $colored .= $string . "\033[0m";

        return $colored;
    }
655349
public function massColor(array $strings, string $color)
    {
        $len_array = count($strings);
        for ($i = 0; $i < $len_array; $i++) {
            $strings[$i] = $this->colorize->{$color}($strings[$i]);
        }
        return $strings;
    }
640403
public static function getNextWhitespace($string, $start = -1)
    {
        while ($start < (strlen($string) - 1) && !self::isWhitespace($string[$start + 1])) {
            $start++;
        }

        if ($start === (strlen($string) - 1)) {
            return false;
        }

        $start++;

        return $start;
    }