Color-codes the keyword if colorization enabled
@param keyword a keyword to color-code using ANSI colors
@return the keyword, color-coded
352825
private String colorKeyword(String keyword) {
        if(colorize) {
            return ANSI.color(keyword, ANSI.BLUE);
        } else {
            return keyword;
        }
    }
697619
public DesignSpec setKeylinesColor(int color) {
        if (mKeylinesPaint.getColor() == color) {
            return this;
        }

        mKeylinesPaint.setColor(color);
        invalidateSelf();

        return this;
    }
1366432
private boolean match(String keyword, int fromIndex) {

        int match = 0;

        // 查找非空白字符。
        for (int index = fromIndex; index < length; index++) {

            char ch = pattern.charAt(index);

            if (!Character.isWhitespace(ch)) {
                match = index;
                break;
            }
        }

        // 匹配关键字内容。
        for (int index = 0; index < keyword.length(); index++) {

            char ch = pattern.charAt(match);

            if (ch != keyword.charAt(index)) {
                // 与关键字不匹配
                return false;
            }

            match++;
        }

        // 修改当前位置
        position = match;

        return true;
    }
341753
def colorize(text, color=None, **kwargs):
    
    style = None
    bg = None
    # ================ #
    # Keyword checking #
    # ================ #
    if 'style' in kwargs:
        if kwargs['style'] not in STYLE:
            raise WrongStyle('"{}" is wrong argument for {}'.format(kwargs['style'], 'style'))
        style = kwargs['style']

    if 'bg' in kwargs:
        if kwargs['bg'] not in BACKGROUND:
            raise WrongBackground('"{}" is wrong argument for {}'.format(kwargs['bg'], 'bg'))
        bg = kwargs['bg']

    if color not in COLOR:
        raise WrongColor('"{}" is wrong argument for {}'.format(color, 'color'))
    # ===================== #
    # Colorizing the string #
    # ===================== #
    if '\x1b[0m' not in text:
        text = '\x1b[' + ';'.join([str(STYLE[style]), str(COLOR[color]), str(BACKGROUND[bg])])\
               + 'm' + text + '\x1b[0m'
    else:
        lst = text.split('\x1b[0m')
        text = ''
        for x in lst:
            if not x.startswith('\x1b['):
                x = '\x1b[' + ';'.join([str(STYLE[style]), str(COLOR[color]), str(BACKGROUND[bg])])\
                     + 'm' + x + '\x1b[0m'
            else:
                x += '\x1b[0m'
            text += x
    return text
492754
public static String shorthandHexSingle(String color) {
		validateHexSingle(color);
		if (color.length() > 1
				&& Character.toUpperCase(color.charAt(0)) == Character
						.toUpperCase(color.charAt(1))) {
			color = color.substring(0, 1);
		}
		return color;
	}
978782
public static String toRGB(Color color)
    {
        String rgb = "#";
        rgb += formatAsHex( color.getRed() );
        rgb += formatAsHex( color.getGreen() );
        rgb += formatAsHex( color.getBlue() );
        return rgb;
    }
940688
public Color getFromRGB(final int red, final int green, final int blue) {
        return this.getFromString("#" + this.toHexString(red) + this.toHexString(green) + this
                        .toHexString(blue));
    }
877662
public static boolean match(String keyword, String mappingId) {
		if (mappingId.indexOf(keyword) != -1) { // match found!
			return true;
		}
		return false;
	}
301259
public static int getColor(GraphicFactory graphicFactory, String colorString) {
        return getColor(graphicFactory, colorString, null, null);
    }
138962
private String checkColor(String color) {

        if (color != null) {
            if (color.indexOf("#") == -1) {
                // add the "#" to the color string
                color = "#" + color;
            }
            int colLength = color.length();
            if ((colLength == 4) || (colLength == 7)) {
                return color;
            }
        }
        return "#FFFFFF";
    }
695263
private static String colorString(Color color) {
		return color.getRed() + "," + color.getGreen() + "," + color.getBlue()
				+ "," + color.getAlpha();
	}
745163
public static final String getRandomHexColor()
    {
        final int r = randomRGB();

        final int g = randomRGB();

        final int b = randomRGB();

        return rgbToBrowserHexColor(r, g, b);
    }
679598
public T textColor(int color) {

        if (view instanceof TextView) {
            TextView tv = (TextView) view;
            tv.setTextColor(color);
        }
        return self();
    }
1373997
public final void setHelperTextColor(@ColorInt final int color) {
        this.helperTextColor = color;

        if (!(Boolean) leftMessage.getTag()) {
            leftMessage.setTextColor(color);
        }

        if (!(Boolean) rightMessage.getTag()) {
            rightMessage.setTextColor(color);
        }
    }
1357605
public boolean addKeywords(String keywords) {
        try {
            return add(new Meta(Element.KEYWORDS, keywords));
		} catch (DocumentException de) {
            throw new ExceptionConverter(de);
        }
    }
47271
function ( color, errorMsg ) {
            if ( this.REG_RGB.test(color) || this.REG_HSL.test(color) ) {
                var typeName = color.match( /([a-z]+)\(/ );
                return this.TYPES[typeName[1].toUpperCase()];
            } else if ( this.REG_HEX.test(color) || this.REG_HEX3.test(color) ) {
                return this.TYPES.HEX;
            } else if ( typeof color === 'string' && this.KEYWORDS[color.toLowerCase()] ) {
                return 'keyword'
            } else {
                if ( errorMsg ) warning( errorMsg );
                return undefined;
            }
        }
750585
public final void addHelperTextColor(@ColorInt final int color) {
        if (!helperTextColors.contains(color)) {
            helperTextColors.add(color);
            verifyPasswordStrength();
        }
    }