Returns ANSI color strings for pretty CLI output
@param {string} c
@param {boolean} bold
@param {string} msg
@returns {string} the ANSI color string
160329
function color(c, bold, msg) {
  return bold ? clic.xterm(c).bold(msg) : clic.xterm(c)(msg);
}
829134
public static function success($msg)
    {
        $msg = 'Success: ' . $msg;
        $space = strlen($msg) + 4;
        $out  = static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_GREEN) . PHP_EOL;
        $out .= static::colorize('  ' . $msg . '  ', Color::FG_WHITE, Color::AT_BOLD, Color::BG_GREEN) . PHP_EOL;
        $out .= static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_GREEN) . PHP_EOL;

        return $out;
    }
312454
def colorize(self, string, rgb=None, ansi=None, bg=None, ansi_bg=None):
        ''''''
        if not isinstance(string, str):
            string = str(string)
        if rgb is None and ansi is None:
            raise TerminalColorMapException(
                'colorize: must specify one named parameter: rgb or ansi')
        if rgb is not None and ansi is not None:
            raise TerminalColorMapException(
                'colorize: must specify only one named parameter: rgb or ansi')
        if bg is not None and ansi_bg is not None:
            raise TerminalColorMapException(
                'colorize: must specify only one named parameter: bg or ansi_bg')

        if rgb is not None:
            (closestAnsi, closestRgb) = self.convert(rgb)
        elif ansi is not None:
            (closestAnsi, closestRgb) = (ansi, self.colors[ansi])

        if bg is None and ansi_bg is None:
            return "\033[38;5;{ansiCode:d}m{string:s}\033[0m".format(ansiCode=closestAnsi, string=string)

        if bg is not None:
            (closestBgAnsi, unused) = self.convert(bg)
        elif ansi_bg is not None:
            (closestBgAnsi, unused) = (ansi_bg, self.colors[ansi_bg])

        return "\033[38;5;{ansiCode:d}m\033[48;5;{bf:d}m{string:s}\033[0m".format(ansiCode=closestAnsi, bf=closestBgAnsi, string=string)
478653
def _color_image_callback(self, image_msg):
        
        color_arr = self._process_image_msg(image_msg)
        self._cur_color_im = ColorImage(color_arr[:,:,::-1], self._frame)
1041983
def stringc(text, color):
    
    if has_colors:
        text = str(text)

        return "\033["+codeCodes[color]+"m"+text+"\033[0m"
    else:
        return text
1364940
def _colorformat(text):
    
    if text[0:1] == '#':
        col = text[1:]
        if col in ANSI_COLOR_NAMES:
            return col
        elif len(col) == 6:
            return col
        elif len(col) == 3:
            return col[0]*2 + col[1]*2 + col[2]*2
    elif text == '':
        return text

    raise ValueError('Wrong color format %r' % text)
715237
protected String colorString(int ir, int ig, int ib)
    {
    	return String.format("#%02x%02x%02x", ir, ig, ib);
    }
920050
def formatcolor(string, fg=None, bg=None):
    
    if fg is bg is None:
        return string

    temp = (['fg='+fg] if fg else []) +\
           (['bg='+bg] if bg else [])
    fmt = _color_format_parser._COLOR_DELIM.join(temp)

    return _color_format_parser._START_TOKEN + fmt +\
        _color_format_parser._FMT_TOKEN + string +\
        _color_format_parser._STOP_TOKEN
852742
def colorize(style, msg, resp):
    
    code = resp.status.split(maxsplit=1)[0]
    if code[0] == '2':
        # Put 2XX first, since it should be the common case
        msg = style.HTTP_SUCCESS(msg)
    elif code[0] == '1':
        msg = style.HTTP_INFO(msg)
    elif code == '304':
        msg = style.HTTP_NOT_MODIFIED(msg)
    elif code[0] == '3':
        msg = style.HTTP_REDIRECT(msg)
    elif code == '404':
        msg = style.HTTP_NOT_FOUND(msg)
    elif code[0] == '4':
        msg = style.HTTP_BAD_REQUEST(msg)
    else:
        # Any 5XX, or any other response
        msg = style.HTTP_SERVER_ERROR(msg)
    return msg
527999
def msg(self, message, title=None, title_color=None, color='BLUE', ident=0):
        '''
        
        '''
        if title and not title_color:
            title_color = color
        if title_color and not title:
            title_color = None

        self.__colored_output(title, message, title_color, color, ident=ident)
1127327
def cprint(text, fg=grey, bg=blackbg, w=norm, cr=False, encoding='utf8'):
    ''' 
    '''
    colorstart(fg, bg, w)
    out(text)
    colorend(cr)
129212
def _log_msg(self, msg, ok):
        ''''''
        if self._config['color']:
            CGREEN, CRED, CEND = '\033[92m', '\033[91m', '\033[0m'
        else:
            CGREEN = CRED = CEND = ''

        LOG_LEVELS = {False: logging.ERROR, True: logging.INFO}

        # pylint: disable=logging-not-lazy
        L.log(LOG_LEVELS[ok],
              '%35s %s' + CEND, msg, CGREEN + 'PASS' if ok else CRED + 'FAIL')
1016409
def _write_color_ansi (fp, text, color):
    """"""
    fp.write(esc_ansicolor(color))
    fp.write(text)
    fp.write(AnsiReset)
1044026
def ansi_print(text, fg, bg = nil, attr = nil)
      unless @out.tty?
        puts text
        return
      end

      colors = %w{black red green yellow blue magenta cyan white}
      attrs = %w{reset bold dim underscore blink reverse hidden}
      escape = "\033[%sm"
      fmt = []
      fmt << 30 + colors.index(fg.to_s) if fg
      fmt << 40 + colors.index(bg.to_s) if bg
      fmt << attrs.index(attr.to_s) if attr
      if fmt
        puts "#{escape % fmt.join(';')}#{text}#{escape % 0}"
      else
        puts text
      end
    end
735995
def _print(self, msg, color=None, arrow=False, indent=None):
        
        if color:
            msg = colored(msg, color)

        if arrow:
            msg = colored('===> ', 'blue') + msg

        if indent:
            msg = ('     ' * indent) + msg

        print(msg)

        return msg
476542
def console_writer(msg, tab=-1):
    
    tab += 1

    if isinstance(msg, Model):
        msg = fromstring(msg.render(encoding='utf-8'))

    print('%s`- %s: %s %s' % (
        '  ' * tab,
        click.style(msg.tag, bold=True),
        click.style(msg.text, fg='red') if msg.text is not None else '',
        click.style(repr(msg.attrib), fg='green', bold=True) if msg.attrib.keys() else ''
    ))
    for c in msg.getchildren():
        print('  %s`- %s: %s %s' % (
            '  ' * tab,
            click.style(c.tag, bold=True),
            click.style(c.text, fg='red') if c.text is not None else '',
            click.style(repr(c.attrib), fg='green', bold=True) if c.attrib.keys() else ''
        ))
        for sc in c.getchildren():
            tab += 1
            console_writer(sc, tab)
            tab -= 1
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