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
356582
def bgblack(cls, string, auto=False):
        
        return cls.colorize('bgblack', string, auto=auto)
119075
def _colourise(text: str, colour: str) -> str:
    
    if COLOUR:
        text = style(text, fg=colour, bold=True)
    return text
252688
def uncolored(string = nil) # :yields:
      if block_given?
        yield.gsub(COLORED_REGEXP, '')
      elsif string
        string.gsub(COLORED_REGEXP, '')
      elsif respond_to?(:to_str)
        gsub(COLORED_REGEXP, '')
      else
        ''
      end
    end
173132
def bgblue(cls, string, auto=False):
        
        return cls.colorize('bgblue', string, auto=auto)
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)
603250
public void setAutoTextColor(final boolean AUTOMATIC) {
        if (null == autoTextColor) {
            _autoTextColor = AUTOMATIC;
            adjustTextColors();
            redraw();
        } else {
            autoTextColor.set(AUTOMATIC);
        }
    }
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
368446
def uncolor(string = nil) # :yields:
      if block_given?
        yield.to_str.gsub(COLORED_REGEXP, '')
      elsif string.respond_to?(:to_str)
        string.to_str.gsub(COLORED_REGEXP, '')
      elsif respond_to?(:to_str)
        to_str.gsub(COLORED_REGEXP, '')
      else
        ''
      end.extend(Term::ANSIColor)
    end
1321295
def bgyellow(cls, string, auto=False):
        
        return cls.colorize('bgyellow', string, auto=auto)
1103567
public static function fromRgbString(string $string) : Colour
    {
        list($r, $g, $b) = ColourStringParser::parseRgbString($string);

        return new self($r, $g, $b);
    }
870016
def colorize(text, ansi=True):
    
    if ansi:
        text = text.replace('^^', '\x00')
        for token, code in _ANSI_CODES:
            text = text.replace(token, code)
        text = text.replace('\x00', '^')
    else:
        text = strip_caret_codes(text)
    return text
1252922
def _make_color_fn(color):
	""""""
	def _color(text = ""):
		return (_color_sep + color + _color_sep2 + text +
			_color_sep + "default" + _color_sep2)
	return _color
972750
def create_color_method(color, code):
    

    def func(self, content=''):
        return self._apply_color(code, content)  # pylint: disable=protected-access

    setattr(Terminal, color, func)
529129
def colorize(string, stack):
  ''''''
  codes = optimize(stack)
  if len(codes):
    prefix = SEQ % ';'.join(map(str, codes))
    suffix = SEQ % STYLE.reset
    return prefix + string + suffix
  else:
    return string
1322242
def color(self, s, color=None, bold=False):
        
        if not self.enable:
            return s
        code_seq = []
        if color:
            code_seq += [30 + self.ColorIdxTable[color]]  # foreground color
        if bold:
            code_seq += [1]
        if not code_seq:
            return s
        start = "\x1b[%sm" % ";".join(map(str, code_seq))
        end = "\x1b[0m"
        while s[:1] == " ":  # move prefix spaces outside
            start = " " + start
            s = s[1:]
        while s[-1:] == " ":  # move postfix spaces outside
            end += " "
            s = s[:-1]
        return start + s + end
1130665
def output_colored(code, text, is_bold=False):
    
    if is_bold:
        code = '1;%s' % code

    return '\033[%sm%s\033[0m' % (code, text)
1363212
def black(cls, string, auto=False):
        
        return cls.colorize('black', string, auto=auto)