Color-code entire string.

        :param str string: String to colorize.
        :param bool auto: Enable auto-color (dark/light terminal).

        :return: Class instance for colorized string.
        :rtype: Color
173132
def bgblue(cls, string, auto=False):
        
        return cls.colorize('bgblue', string, auto=auto)
342865
def :
    
    s=''
    for _t in text:
        if _t in kword:
            s += colorize(BgColor.Null, Base.Null, color, _t)
        else:
            s += _t
    return s
812153
def color(type, str)
      colors = {
        'pass'          => [:green], # 90,
        'fail'          => [:red], # 31,
        'bright pass'   => [:bold, :green], # 92,
        'bright fail'   => [:bold, :red], # 91,
        'bright yellow' => [:bold, :yellow], # 93,
        'pending'       => [:yellow], # 36,
        'suite'         => [], # 0,
        'error title'   => [], # 0,
        'error message' => [:red], # 31,
        'error stack'   => [:green], # 90,
        'checkmark'     => [:green], # 32,
        'fast'          => [:green], # 90,
        'medium'        => [:green], # 33,
        'slow'          => [:red], # 31,
        'green'         => [:green], # 32,
        'light'         => [:green], # 90,
        'diff gutter'   => [:green], # 90,
        'diff added'    => [:green], # 42,
        'diff removed'  => [:red]# 41
      }

      @context.knife.ui.color(str, *colors[type])
    end
368734
def write_color(string, name, style='normal', when='auto'):
    
    write(color(string, name, style, when))
1208193
def basic_color(code):
    
    def inner(text, rl=False):
        """ Every raw_input with color sequences should be called with
        rl=True to avoid readline messed up the length calculation
        """
        c = code
        if rl:
            return "\001\033[%sm\002%s\001\033[0m\002" % (c, text)
        else:
            return "\033[%sm%s\033[0m" % (c, text)
    return inner
1321295
def bgyellow(cls, string, auto=False):
        
        return cls.colorize('bgyellow', string, auto=auto)
603250
public void setAutoTextColor(final boolean AUTOMATIC) {
        if (null == autoTextColor) {
            _autoTextColor = AUTOMATIC;
            adjustTextColors();
            redraw();
        } else {
            autoTextColor.set(AUTOMATIC);
        }
    }
648017
def write(self, text: str):
        
        # Default color is NORMAL.
        last_color = (self._DARK_CODE, 0)
        # We use splitlines with keepends in order to keep the line breaks.
        # Then we split by using the console width.
        original_lines = text.splitlines(True)
        lines = self._split_lines(original_lines) if self._width_limit else original_lines

        # Print the new width-formatted lines.
        for line in lines:
            # Print indents only at line beginnings.
            if not self._in_line:
                self._writer.write(' ' * self.indents_sum)
            # Remove colors if needed.
            if not self._colors:
                for color_code in self._ANSI_REGEXP.findall(line):
                    line = line.replace(self._ANSI_COLOR_CODE % (color_code[0], int(color_code[1])), '')
            elif not self._ANSI_REGEXP.match(line):
                # Check if the line starts with a color. If not, we apply the color from the last line.
                line = self._ANSI_COLOR_CODE % (last_color[0], int(last_color[1])) + line
            # Print the final line.
            self._writer.write(line)
            # Update the in_line status.
            self._in_line = not line.endswith(self.LINE_SEP)
            # Update the last color used.
            if self._colors:
                last_color = self._ANSI_REGEXP.findall(line)[-1]

        # Update last position (if there was no line break in the end).
        if len(lines) > 0:
            last_line = lines[-1]
            if not last_line.endswith(self.LINE_SEP):
                # Strip the colors to figure out the real number of characters in the line.
                if self._colors:
                    for color_code in self._ANSI_REGEXP.findall(last_line):
                        last_line = last_line.replace(self._ANSI_COLOR_CODE % (color_code[0], int(color_code[1])), '')
                self._last_position += len(last_line)
            else:
                self._last_position = 0
                self._is_first_line = False
        else:
            self._last_position = 0

        # Reset colors for the next print.
        if self._colors and not text.endswith(self.NORMAL):
            self._writer.write(self.NORMAL)
1252922
def _make_color_fn(color):
	""""""
	def _color(text = ""):
		return (_color_sep + color + _color_sep2 + text +
			_color_sep + "default" + _color_sep2)
	return _color
1205487
public static function fromRgbaString(string $string) : TransparentColour
    {
        list($r, $g, $b, $a) = ColourStringParser::parseRgbaString($string);

        return new self(new Colour($r, $g, $b), $a);
    }
1297016
def bgwhite(cls, string, auto=False):
        
        return cls.colorize('bgwhite', string, auto=auto)
497002
def _wrap_with(color_code):
    '''
    '''
    def inner(text, bold=False):
        '''Inner color function.'''
        code = color_code
        if bold:
            code = flo("1;{code}")
        return flo('\033[{code}m{text}\033[0m')
    return inner
1119249
def format(self, *args, **kwargs):
        
        return self.__class__(super(ColorStr, self).format(*args, **kwargs), keep_tags=True)
286224
def color_validator(input_str):
    
    try:
        assert input_str in VALID_OVERRIDE_COLORS + ['']
        return input_str
    except AssertionError:
        raise ValidationError(
                'Expected colors are: ' +
                ', '.join(color for color in VALID_OVERRIDE_COLORS) +
                '. (Ctrl-C to exit)\n')
522187
def _colorize(self, msg, color=None, encode=False):
        
        
        # Valid colors
        colors = {
            'red':    '31',
            'green':  '32',
            'yellow': '33'
        }
        
        # No color specified or unsupported color
        if not color or not color in colors:
            return msg
        
        # The colorized string
        if encode:
            return u'\x1b[1;{}m{}\x1b[0m'.format(colors[color], msg)
        return '\x1b[1;{}m{}\x1b[0m'.format(colors[color], msg)
99516
def strip_color!(string)
      [@@mirc_color, @@rgb_color, @@ecma48_color].each do |pattern|
        string.gsub!(pattern, '')
      end
      # strip cancellation codes too if there are no formatting codes
      string.gsub!(@@normal) if !has_color?(string)
      return string
    end
1057899
def term_color(code):
    
    def inner(text, rl=False):
        """
        Every raw_input with color sequences should be called with
        rl=True to avoid readline messed up the length calculation
        """
        c = code
        if rl:
            return "\001\033[38;5;%sm\002%s\001\033[0m\002" % (c, text)
        else:
            return "\033[38;5;%sm%s\033[0m" % (c, text)
    return inner