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
770586
def white(cls, string, auto=False):
        
        return cls.colorize('white', string, auto=auto)
1308544
def running_as_string(self, add_colour=True):
        '''

        '''
        with self._mutex:
            if self.running:
                result = 'Running', ['bold', 'green']
            else:
                result = 'Stopped', ['reset']
        if add_colour:
            return utils.build_attr_string(result[1], supported=add_colour) + \
                    result[0] + utils.build_attr_string('reset', supported=add_colour)
        else:
            return result[0]
448140
public static function fromHexString(string $string) : Colour
    {
        list($r, $g, $b) = ColourStringParser::parseHexString($string);

        return new self($r, $g, $b);
    }
1297016
def bgwhite(cls, string, auto=False):
        
        return cls.colorize('bgwhite', string, auto=auto)
119075
def _colourise(text: str, colour: str) -> str:
    
    if COLOUR:
        text = style(text, fg=colour, bold=True)
    return text
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
332761
def colorize(string, color, *args, **kwargs):
    
    string = string.format(*args, **kwargs)
    return color + string + colorama.Fore.RESET
956144
def set_color(string, *colors)
      if colors.compact.empty?
        string
      elsif colors.all? { |color| color.is_a?(Symbol) }
        ansi_colors = colors.map { |color| lookup_color(color) }
        "#{ansi_colors.join}#{string}#{CLEAR}"
      end
    end
249107
def color(string, name, style='normal', when='auto'):
    
    if name not in colors:
        from .text import oxford_comma
        raise ValueError("unknown color '{}'.\nknown colors are: {}".format(
            name, oxford_comma(["'{}'".format(x) for x in sorted(colors)])))

    if style not in styles:
        from .text import oxford_comma
        raise ValueError("unknown style '{}'.\nknown styles are: {}".format(
            style, oxford_comma(["'{}'".format(x) for x in sorted(styles)])))

    prefix = '\033[%d;%dm' % (styles[style], colors[name])
    suffix = '\033[%d;%dm' % (styles['normal'], colors['normal'])
    color_string = prefix + string + suffix

    if when == 'always':
        return color_string
    elif when == 'auto':
        return color_string if sys.stdout.isatty() else string
    elif when == 'never':
        return string
    else:
        raise ValueError("when must be one of: 'always', 'auto', 'never'")
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);
    }
722324
def highlight(string, fg=None, bg=None, indices=[], end='\n',
              target=sys.stdout):
    
    if not string or not indices or (fg is bg is None):
        return

    p = 0

    # The lambda syntax is necessary to support both Python 2 and 3
    for k, g in itertools.groupby(enumerate(sorted(indices)),
                                  lambda x: x[0]-x[1]):
        tmp = list(map(operator.itemgetter(1), g))
        s, e = tmp[0], tmp[-1]+1
        target.write(string[p:s])
        target.flush()  # Needed for Python 3.x
        _color_manager.set_color(fg, bg)
        target.write(string[s:e])
        target.flush()  # Needed for Python 3.x
        _color_manager.set_defaults()
        p = e

    if p < len(string):
        target.write(string[p:])

    target.write(end)
453997
def use_color(setting):
    
    if setting not in COLOR_CHOICES:
        raise InvalidColorSetting(setting)

    return (
        setting == 'always' or
        (setting == 'auto' and sys.stdout.isatty() and terminal_supports_color)
    )
1252922
def _make_color_fn(color):
	""""""
	def _color(text = ""):
		return (_color_sep + color + _color_sep2 + text +
			_color_sep + "default" + _color_sep2)
	return _color
307458
function highlightAuto(value, options) {
  var result
  var sheet
  var config

  if (options) {
    if (options.subset) {
      sheet = options.sheet
      config = {subset: options.subset}
    } else {
      sheet = options
    }
  }

  if (!sheet) {
    sheet = SHEET
  }

  result = auto.call(this, value, config)

  result.value = all(sheet, result.value)

  if (result.secondBest) {
    result.secondBest.value = all(sheet, result.secondBest.value)
  }

  return result
}
1305548
def color(name, string = nil, &block)
      attribute = Attribute[name] or raise ArgumentError, "unknown attribute #{name.inspect}"
      result = ''
      result << "\e[#{attribute.code}m" if Term::ANSIColor.coloring?
      if block_given?
        result << yield.to_s
      elsif string.respond_to?(:to_str)
        result << string.to_str
      elsif respond_to?(:to_str)
        result << to_str
      else
        return result #only switch on
      end
      result << "\e[0m" if Term::ANSIColor.coloring?
      result.extend(Term::ANSIColor)
    end
479238
function string_to_color(str) {
	// Generate a Hash for the String
	var hash = function(word) {
		var h = 0;
		for (var i = 0; i < word.length; i++) {
			h = word.charCodeAt(i) + ((h << 5) - h);
		}
		return h;
	};

	// Change the darkness or lightness
	var shade = function(color, prc) {
		var num = parseInt(color, 16),
		    amt = Math.round(2.55 * prc),
		    R = (num >> 16) + amt,
		    G = (num >> 8 & 0x00FF) + amt,
		    B = (num & 0x0000FF) + amt;
		return (0x1000000 + (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 +
			(G < 255 ? G < 1 ? 0 : G : 255) * 0x100 +
			(B < 255 ? B < 1 ? 0 : B : 255))
			.toString(16)
			.slice(1);
	};

	// Convert init to an RGBA
	var int_to_rgba = function(i) {
		var color = ((i >> 24) & 0xFF).toString(16) +
			((i >> 16) & 0xFF).toString(16) +
			((i >> 8) & 0xFF).toString(16) +
			(i & 0xFF).toString(16);
		return color;
	};

	return shade(
		int_to_rgba(hash(str)),
		-10
	);
}
311704
def recolorize(string)
      level = 0
      string.gsub(/\e\[(\d+(?:;\d+)*)m/) do
        "".tap do |buffer|
          codes = $1.split(";").map(&:to_i)

          classes = []
          while code = codes.shift
            case code
            when 0
              classes.clear
              buffer << ("</span>" * level)
              level = 0
            when 1..5, 9, 30..37
              classes << "term-fg#{code}"
            when 38
              if codes[0] == 5
                codes.shift
                if codes[0]
                  classes << "term-fgx#{codes.shift}"
                end
              end
            when 40..47
              classes << "term-bg#{code}"
            when 48
              if codes[0] == 5
                codes.shift
                if codes[0]
                  classes << "term-bgx#{codes.shift}"
                end
              end
            when 90..97
              classes << "term-fgi#{code}"
            when 100..107
              classes << "term-bgi#{code}"
            end
          end

          if classes.any?
            level += 1
            buffer << %{<span class=#{classes.map { |klass| klass }.join(" ").encode(:xml => :attr)}>}
          end
        end
      end << ("</span>" * level)
    end