xonsh.color_tools

Tools for color handling in xonsh.

This includes Convert values between RGB hex codes and xterm-256 color codes. Parts of this file were originally forked from Micah Elliott http://MicahElliott.com Copyright (C) 2011 Micah Elliott. All rights reserved. WTFPL http://sam.zoy.org/wtfpl/

class xonsh.color_tools.COLORS[source]

constants

BOLD_GREEN = '{BOLD_GREEN}'
BOLD_RED = '{BOLD_RED}'
GREEN = '{GREEN}'
RED = '{RED}'
RESET = '{RESET}'
xonsh.color_tools.color_dist(x, y) float[source]
xonsh.color_tools.find_closest_color(x, palette)[source]
xonsh.color_tools.iscolor(s)[source]

Tests if a string is a valid color

xonsh.color_tools.make_palette(strings)[source]

Makes a color palette from a collection of strings.

xonsh.color_tools.rgb2short(rgb)

Find the closest ANSI 256 approximation to the given RGB value.

>>> rgb2short('123456')
('23', '005f5f')
>>> rgb2short('ffffff')
('231', 'ffffff')
>>> rgb2short('0DADD6') # vimeo logo
('38', '00afd7')
Parameters:
rgbHex code representing an RGB value, eg, ‘abcdef’
Returns:
Tuple of String between 0 and 255 (compatible with xterm) and
hex code (length-6).
xonsh.color_tools.rgb_to_256(rgb)[source]

Find the closest ANSI 256 approximation to the given RGB value.

>>> rgb2short('123456')
('23', '005f5f')
>>> rgb2short('ffffff')
('231', 'ffffff')
>>> rgb2short('0DADD6') # vimeo logo
('38', '00afd7')
Parameters:
rgbHex code representing an RGB value, eg, ‘abcdef’
Returns:
Tuple of String between 0 and 255 (compatible with xterm) and
hex code (length-6).
xonsh.color_tools.rgb_to_ints(rgb)[source]
xonsh.color_tools.short2rgb(short)[source]
xonsh.color_tools.short_to_ints(short)[source]

Coverts a short (256) color to a 3-tuple of ints.

xonsh.color_tools.warn_deprecated_no_color()[source]

Show a warning once if NO_COLOR was used instead of RESET.