API Documentation

color.py

Sub-module providing color functions.

References, - https://en.wikipedia.org/wiki/Color_difference - http://www.easyrgb.com/en/math.php - Measuring Colour by R.W.G. Hunt and M.R. Pointer

rgb_to_xyz(red, green, blue)[source]

Convert standard RGB color to XYZ color.

Parameters
  • red – RGB value of Red.

  • green – RGB value of Green.

  • blue – RGB value of Blue.

Returns

Tuple (X, Y, Z) representing XYZ color

Return type

tuple

D65/2° standard illuminant

xyz_to_lab(x_val, y_val, z_val)[source]

Convert XYZ color to CIE-Lab color.

Parameters
  • x_val – XYZ value of X.

  • y_val – XYZ value of Y.

  • z_val – XYZ value of Z.

Returns

Tuple (L, a, b) representing CIE-Lab color

Return type

tuple

D65/2° standard illuminant

rgb_to_lab[source]

Convert RGB color to CIE-Lab color.

Parameters
  • red – RGB value of Red.

  • green – RGB value of Green.

  • blue – RGB value of Blue.

Returns

Tuple (L, a, b) representing CIE-Lab color

Return type

tuple

D65/2° standard illuminant

dist_rgb(rgb1, rgb2)[source]

Determine distance between two rgb colors.

Parameters
  • rgb1 (tuple) – RGB color definition

  • rgb2 (tuple) – RGB color definition

Returns

Square of the distance between provided colors

Return type

float

This works by treating RGB colors as coordinates in three dimensional space and finding the closest point within the configured color range using the formula:

d^2 = (r2 - r1)^2 + (g2 - g1)^2 + (b2 - b1)^2

For efficiency, the square of the distance is returned which is sufficient for comparisons

dist_rgb_weighted(rgb1, rgb2)[source]

Determine the weighted distance between two rgb colors.

Parameters
  • rgb1 (tuple) – RGB color definition

  • rgb2 (tuple) – RGB color definition

Returns

Square of the distance between provided colors

Return type

float

Similar to a standard distance formula, the values are weighted to approximate human perception of color differences

For efficiency, the square of the distance is returned which is sufficient for comparisons

dist_cie76(rgb1, rgb2)[source]

Determine distance between two rgb colors using the CIE94 algorithm.

Parameters
  • rgb1 (tuple) – RGB color definition

  • rgb2 (tuple) – RGB color definition

Returns

Square of the distance between provided colors

Return type

float

For efficiency, the square of the distance is returned which is sufficient for comparisons

dist_cie94(rgb1, rgb2)[source]

Determine distance between two rgb colors using the CIE94 algorithm.

Parameters
  • rgb1 (tuple) – RGB color definition

  • rgb2 (tuple) – RGB color definition

Returns

Square of the distance between provided colors

Return type

float

For efficiency, the square of the distance is returned which is sufficient for comparisons

dist_cie2000(rgb1, rgb2)[source]

Determine distance between two rgb colors using the CIE2000 algorithm.

Parameters
  • rgb1 (tuple) – RGB color definition

  • rgb2 (tuple) – RGB color definition

Returns

Square of the distance between provided colors

Return type

float

For efficiency, the square of the distance is returned which is sufficient for comparisons

colorspace.py

References,

class RGBColor[source]

Create new instance of RGBColor(red, green, blue)

X11_COLORNAMES_TO_RGB = {'aliceblue': RGBColor(red=240, green=248, blue=255), 'antiquewhite': RGBColor(red=250, green=235, blue=215), 'antiquewhite1': RGBColor(red=255, green=239, blue=219), 'antiquewhite2': RGBColor(red=238, green=223, blue=204), 'antiquewhite3': RGBColor(red=205, green=192, blue=176), 'antiquewhite4': RGBColor(red=139, green=131, blue=120), 'aqua': RGBColor(red=0, green=255, blue=255), 'aquamarine': RGBColor(red=127, green=255, blue=212), 'aquamarine1': RGBColor(red=127, green=255, blue=212), 'aquamarine2': RGBColor(red=118, green=238, blue=198), 'aquamarine3': RGBColor(red=102, green=205, blue=170), 'aquamarine4': RGBColor(red=69, green=139, blue=116), 'azure': RGBColor(red=240, green=255, blue=255), 'azure1': RGBColor(red=240, green=255, blue=255), 'azure2': RGBColor(red=224, green=238, blue=238), 'azure3': RGBColor(red=193, green=205, blue=205), 'azure4': RGBColor(red=131, green=139, blue=139), 'beige': RGBColor(red=245, green=245, blue=220), 'bisque': RGBColor(red=255, green=228, blue=196), 'bisque1': RGBColor(red=255, green=228, blue=196), 'bisque2': RGBColor(red=238, green=213, blue=183), 'bisque3': RGBColor(red=205, green=183, blue=158), 'bisque4': RGBColor(red=139, green=125, blue=107), 'black': RGBColor(red=0, green=0, blue=0), 'blanchedalmond': RGBColor(red=255, green=235, blue=205), 'blue': RGBColor(red=0, green=0, blue=255), 'blue1': RGBColor(red=0, green=0, blue=255), 'blue2': RGBColor(red=0, green=0, blue=238), 'blue3': RGBColor(red=0, green=0, blue=205), 'blue4': RGBColor(red=0, green=0, blue=139), 'blueviolet': RGBColor(red=138, green=43, blue=226), 'brown': RGBColor(red=165, green=42, blue=42), 'brown1': RGBColor(red=255, green=64, blue=64), 'brown2': RGBColor(red=238, green=59, blue=59), 'brown3': RGBColor(red=205, green=51, blue=51), 'brown4': RGBColor(red=139, green=35, blue=35), 'burlywood': RGBColor(red=222, green=184, blue=135), 'burlywood1': RGBColor(red=255, green=211, blue=155), 'burlywood2': RGBColor(red=238, green=197, blue=145), 'burlywood3': RGBColor(red=205, green=170, blue=125), 'burlywood4': RGBColor(red=139, green=115, blue=85), 'cadetblue': RGBColor(red=95, green=158, blue=160), 'cadetblue1': RGBColor(red=152, green=245, blue=255), 'cadetblue2': RGBColor(red=142, green=229, blue=238), 'cadetblue3': RGBColor(red=122, green=197, blue=205), 'cadetblue4': RGBColor(red=83, green=134, blue=139), 'chartreuse': RGBColor(red=127, green=255, blue=0), 'chartreuse1': RGBColor(red=127, green=255, blue=0), 'chartreuse2': RGBColor(red=118, green=238, blue=0), 'chartreuse3': RGBColor(red=102, green=205, blue=0), 'chartreuse4': RGBColor(red=69, green=139, blue=0), 'chocolate': RGBColor(red=210, green=105, blue=30), 'chocolate1': RGBColor(red=255, green=127, blue=36), 'chocolate2': RGBColor(red=238, green=118, blue=33), 'chocolate3': RGBColor(red=205, green=102, blue=29), 'chocolate4': RGBColor(red=139, green=69, blue=19), 'coral': RGBColor(red=255, green=127, blue=80), 'coral1': RGBColor(red=255, green=114, blue=86), 'coral2': RGBColor(red=238, green=106, blue=80), 'coral3': RGBColor(red=205, green=91, blue=69), 'coral4': RGBColor(red=139, green=62, blue=47), 'cornflowerblue': RGBColor(red=100, green=149, blue=237), 'cornsilk': RGBColor(red=255, green=248, blue=220), 'cornsilk1': RGBColor(red=255, green=248, blue=220), 'cornsilk2': RGBColor(red=238, green=232, blue=205), 'cornsilk3': RGBColor(red=205, green=200, blue=177), 'cornsilk4': RGBColor(red=139, green=136, blue=120), 'crimson': RGBColor(red=220, green=20, blue=60), 'cyan': RGBColor(red=0, green=255, blue=255), 'cyan1': RGBColor(red=0, green=255, blue=255), 'cyan2': RGBColor(red=0, green=238, blue=238), 'cyan3': RGBColor(red=0, green=205, blue=205), 'cyan4': RGBColor(red=0, green=139, blue=139), 'darkblue': RGBColor(red=0, green=0, blue=139), 'darkcyan': RGBColor(red=0, green=139, blue=139), 'darkgoldenrod': RGBColor(red=184, green=134, blue=11), 'darkgoldenrod1': RGBColor(red=255, green=185, blue=15), 'darkgoldenrod2': RGBColor(red=238, green=173, blue=14), 'darkgoldenrod3': RGBColor(red=205, green=149, blue=12), 'darkgoldenrod4': RGBColor(red=139, green=101, blue=8), 'darkgray': RGBColor(red=169, green=169, blue=169), 'darkgreen': RGBColor(red=0, green=100, blue=0), 'darkgrey': RGBColor(red=169, green=169, blue=169), 'darkkhaki': RGBColor(red=189, green=183, blue=107), 'darkmagenta': RGBColor(red=139, green=0, blue=139), 'darkolivegreen': RGBColor(red=85, green=107, blue=47), 'darkolivegreen1': RGBColor(red=202, green=255, blue=112), 'darkolivegreen2': RGBColor(red=188, green=238, blue=104), 'darkolivegreen3': RGBColor(red=162, green=205, blue=90), 'darkolivegreen4': RGBColor(red=110, green=139, blue=61), 'darkorange': RGBColor(red=255, green=140, blue=0), 'darkorange1': RGBColor(red=255, green=127, blue=0), 'darkorange2': RGBColor(red=238, green=118, blue=0), 'darkorange3': RGBColor(red=205, green=102, blue=0), 'darkorange4': RGBColor(red=139, green=69, blue=0), 'darkorchid': RGBColor(red=153, green=50, blue=204), 'darkorchid1': RGBColor(red=191, green=62, blue=255), 'darkorchid2': RGBColor(red=178, green=58, blue=238), 'darkorchid3': RGBColor(red=154, green=50, blue=205), 'darkorchid4': RGBColor(red=104, green=34, blue=139), 'darkred': RGBColor(red=139, green=0, blue=0), 'darksalmon': RGBColor(red=233, green=150, blue=122), 'darkseagreen': RGBColor(red=143, green=188, blue=143), 'darkseagreen1': RGBColor(red=193, green=255, blue=193), 'darkseagreen2': RGBColor(red=180, green=238, blue=180), 'darkseagreen3': RGBColor(red=155, green=205, blue=155), 'darkseagreen4': RGBColor(red=105, green=139, blue=105), 'darkslateblue': RGBColor(red=72, green=61, blue=139), 'darkslategray': RGBColor(red=47, green=79, blue=79), 'darkslategray1': RGBColor(red=151, green=255, blue=255), 'darkslategray2': RGBColor(red=141, green=238, blue=238), 'darkslategray3': RGBColor(red=121, green=205, blue=205), 'darkslategray4': RGBColor(red=82, green=139, blue=139), 'darkslategrey': RGBColor(red=47, green=79, blue=79), 'darkturquoise': RGBColor(red=0, green=206, blue=209), 'darkviolet': RGBColor(red=148, green=0, blue=211), 'deeppink': RGBColor(red=255, green=20, blue=147), 'deeppink1': RGBColor(red=255, green=20, blue=147), 'deeppink2': RGBColor(red=238, green=18, blue=137), 'deeppink3': RGBColor(red=205, green=16, blue=118), 'deeppink4': RGBColor(red=139, green=10, blue=80), 'deepskyblue': RGBColor(red=0, green=191, blue=255), 'deepskyblue1': RGBColor(red=0, green=191, blue=255), 'deepskyblue2': RGBColor(red=0, green=178, blue=238), 'deepskyblue3': RGBColor(red=0, green=154, blue=205), 'deepskyblue4': RGBColor(red=0, green=104, blue=139), 'dimgray': RGBColor(red=105, green=105, blue=105), 'dimgrey': RGBColor(red=105, green=105, blue=105), 'dodgerblue': RGBColor(red=30, green=144, blue=255), 'dodgerblue1': RGBColor(red=30, green=144, blue=255), 'dodgerblue2': RGBColor(red=28, green=134, blue=238), 'dodgerblue3': RGBColor(red=24, green=116, blue=205), 'dodgerblue4': RGBColor(red=16, green=78, blue=139), 'firebrick': RGBColor(red=178, green=34, blue=34), 'firebrick1': RGBColor(red=255, green=48, blue=48), 'firebrick2': RGBColor(red=238, green=44, blue=44), 'firebrick3': RGBColor(red=205, green=38, blue=38), 'firebrick4': RGBColor(red=139, green=26, blue=26), 'floralwhite': RGBColor(red=255, green=250, blue=240), 'forestgreen': RGBColor(red=34, green=139, blue=34), 'fuchsia': RGBColor(red=255, green=0, blue=255), 'gainsboro': RGBColor(red=220, green=220, blue=220), 'ghostwhite': RGBColor(red=248, green=248, blue=255), 'gold': RGBColor(red=255, green=215, blue=0), 'gold1': RGBColor(red=255, green=215, blue=0), 'gold2': RGBColor(red=238, green=201, blue=0), 'gold3': RGBColor(red=205, green=173, blue=0), 'gold4': RGBColor(red=139, green=117, blue=0), 'goldenrod': RGBColor(red=218, green=165, blue=32), 'goldenrod1': RGBColor(red=255, green=193, blue=37), 'goldenrod2': RGBColor(red=238, green=180, blue=34), 'goldenrod3': RGBColor(red=205, green=155, blue=29), 'goldenrod4': RGBColor(red=139, green=105, blue=20), 'gray': RGBColor(red=190, green=190, blue=190), 'gray0': RGBColor(red=0, green=0, blue=0), 'gray1': RGBColor(red=3, green=3, blue=3), 'gray10': RGBColor(red=26, green=26, blue=26), 'gray100': RGBColor(red=255, green=255, blue=255), 'gray11': RGBColor(red=28, green=28, blue=28), 'gray12': RGBColor(red=31, green=31, blue=31), 'gray13': RGBColor(red=33, green=33, blue=33), 'gray14': RGBColor(red=36, green=36, blue=36), 'gray15': RGBColor(red=38, green=38, blue=38), 'gray16': RGBColor(red=41, green=41, blue=41), 'gray17': RGBColor(red=43, green=43, blue=43), 'gray18': RGBColor(red=46, green=46, blue=46), 'gray19': RGBColor(red=48, green=48, blue=48), 'gray2': RGBColor(red=5, green=5, blue=5), 'gray20': RGBColor(red=51, green=51, blue=51), 'gray21': RGBColor(red=54, green=54, blue=54), 'gray22': RGBColor(red=56, green=56, blue=56), 'gray23': RGBColor(red=59, green=59, blue=59), 'gray24': RGBColor(red=61, green=61, blue=61), 'gray25': RGBColor(red=64, green=64, blue=64), 'gray26': RGBColor(red=66, green=66, blue=66), 'gray27': RGBColor(red=69, green=69, blue=69), 'gray28': RGBColor(red=71, green=71, blue=71), 'gray29': RGBColor(red=74, green=74, blue=74), 'gray3': RGBColor(red=8, green=8, blue=8), 'gray30': RGBColor(red=77, green=77, blue=77), 'gray31': RGBColor(red=79, green=79, blue=79), 'gray32': RGBColor(red=82, green=82, blue=82), 'gray33': RGBColor(red=84, green=84, blue=84), 'gray34': RGBColor(red=87, green=87, blue=87), 'gray35': RGBColor(red=89, green=89, blue=89), 'gray36': RGBColor(red=92, green=92, blue=92), 'gray37': RGBColor(red=94, green=94, blue=94), 'gray38': RGBColor(red=97, green=97, blue=97), 'gray39': RGBColor(red=99, green=99, blue=99), 'gray4': RGBColor(red=10, green=10, blue=10), 'gray40': RGBColor(red=102, green=102, blue=102), 'gray41': RGBColor(red=105, green=105, blue=105), 'gray42': RGBColor(red=107, green=107, blue=107), 'gray43': RGBColor(red=110, green=110, blue=110), 'gray44': RGBColor(red=112, green=112, blue=112), 'gray45': RGBColor(red=115, green=115, blue=115), 'gray46': RGBColor(red=117, green=117, blue=117), 'gray47': RGBColor(red=120, green=120, blue=120), 'gray48': RGBColor(red=122, green=122, blue=122), 'gray49': RGBColor(red=125, green=125, blue=125), 'gray5': RGBColor(red=13, green=13, blue=13), 'gray50': RGBColor(red=127, green=127, blue=127), 'gray51': RGBColor(red=130, green=130, blue=130), 'gray52': RGBColor(red=133, green=133, blue=133), 'gray53': RGBColor(red=135, green=135, blue=135), 'gray54': RGBColor(red=138, green=138, blue=138), 'gray55': RGBColor(red=140, green=140, blue=140), 'gray56': RGBColor(red=143, green=143, blue=143), 'gray57': RGBColor(red=145, green=145, blue=145), 'gray58': RGBColor(red=148, green=148, blue=148), 'gray59': RGBColor(red=150, green=150, blue=150), 'gray6': RGBColor(red=15, green=15, blue=15), 'gray60': RGBColor(red=153, green=153, blue=153), 'gray61': RGBColor(red=156, green=156, blue=156), 'gray62': RGBColor(red=158, green=158, blue=158), 'gray63': RGBColor(red=161, green=161, blue=161), 'gray64': RGBColor(red=163, green=163, blue=163), 'gray65': RGBColor(red=166, green=166, blue=166), 'gray66': RGBColor(red=168, green=168, blue=168), 'gray67': RGBColor(red=171, green=171, blue=171), 'gray68': RGBColor(red=173, green=173, blue=173), 'gray69': RGBColor(red=176, green=176, blue=176), 'gray7': RGBColor(red=18, green=18, blue=18), 'gray70': RGBColor(red=179, green=179, blue=179), 'gray71': RGBColor(red=181, green=181, blue=181), 'gray72': RGBColor(red=184, green=184, blue=184), 'gray73': RGBColor(red=186, green=186, blue=186), 'gray74': RGBColor(red=189, green=189, blue=189), 'gray75': RGBColor(red=191, green=191, blue=191), 'gray76': RGBColor(red=194, green=194, blue=194), 'gray77': RGBColor(red=196, green=196, blue=196), 'gray78': RGBColor(red=199, green=199, blue=199), 'gray79': RGBColor(red=201, green=201, blue=201), 'gray8': RGBColor(red=20, green=20, blue=20), 'gray80': RGBColor(red=204, green=204, blue=204), 'gray81': RGBColor(red=207, green=207, blue=207), 'gray82': RGBColor(red=209, green=209, blue=209), 'gray83': RGBColor(red=212, green=212, blue=212), 'gray84': RGBColor(red=214, green=214, blue=214), 'gray85': RGBColor(red=217, green=217, blue=217), 'gray86': RGBColor(red=219, green=219, blue=219), 'gray87': RGBColor(red=222, green=222, blue=222), 'gray88': RGBColor(red=224, green=224, blue=224), 'gray89': RGBColor(red=227, green=227, blue=227), 'gray9': RGBColor(red=23, green=23, blue=23), 'gray90': RGBColor(red=229, green=229, blue=229), 'gray91': RGBColor(red=232, green=232, blue=232), 'gray92': RGBColor(red=235, green=235, blue=235), 'gray93': RGBColor(red=237, green=237, blue=237), 'gray94': RGBColor(red=240, green=240, blue=240), 'gray95': RGBColor(red=242, green=242, blue=242), 'gray96': RGBColor(red=245, green=245, blue=245), 'gray97': RGBColor(red=247, green=247, blue=247), 'gray98': RGBColor(red=250, green=250, blue=250), 'gray99': RGBColor(red=252, green=252, blue=252), 'green': RGBColor(red=0, green=255, blue=0), 'green1': RGBColor(red=0, green=255, blue=0), 'green2': RGBColor(red=0, green=238, blue=0), 'green3': RGBColor(red=0, green=205, blue=0), 'green4': RGBColor(red=0, green=139, blue=0), 'greenyellow': RGBColor(red=173, green=255, blue=47), 'grey': RGBColor(red=190, green=190, blue=190), 'grey0': RGBColor(red=0, green=0, blue=0), 'grey1': RGBColor(red=3, green=3, blue=3), 'grey10': RGBColor(red=26, green=26, blue=26), 'grey100': RGBColor(red=255, green=255, blue=255), 'grey11': RGBColor(red=28, green=28, blue=28), 'grey12': RGBColor(red=31, green=31, blue=31), 'grey13': RGBColor(red=33, green=33, blue=33), 'grey14': RGBColor(red=36, green=36, blue=36), 'grey15': RGBColor(red=38, green=38, blue=38), 'grey16': RGBColor(red=41, green=41, blue=41), 'grey17': RGBColor(red=43, green=43, blue=43), 'grey18': RGBColor(red=46, green=46, blue=46), 'grey19': RGBColor(red=48, green=48, blue=48), 'grey2': RGBColor(red=5, green=5, blue=5), 'grey20': RGBColor(red=51, green=51, blue=51), 'grey21': RGBColor(red=54, green=54, blue=54), 'grey22': RGBColor(red=56, green=56, blue=56), 'grey23': RGBColor(red=59, green=59, blue=59), 'grey24': RGBColor(red=61, green=61, blue=61), 'grey25': RGBColor(red=64, green=64, blue=64), 'grey26': RGBColor(red=66, green=66, blue=66), 'grey27': RGBColor(red=69, green=69, blue=69), 'grey28': RGBColor(red=71, green=71, blue=71), 'grey29': RGBColor(red=74, green=74, blue=74), 'grey3': RGBColor(red=8, green=8, blue=8), 'grey30': RGBColor(red=77, green=77, blue=77), 'grey31': RGBColor(red=79, green=79, blue=79), 'grey32': RGBColor(red=82, green=82, blue=82), 'grey33': RGBColor(red=84, green=84, blue=84), 'grey34': RGBColor(red=87, green=87, blue=87), 'grey35': RGBColor(red=89, green=89, blue=89), 'grey36': RGBColor(red=92, green=92, blue=92), 'grey37': RGBColor(red=94, green=94, blue=94), 'grey38': RGBColor(red=97, green=97, blue=97), 'grey39': RGBColor(red=99, green=99, blue=99), 'grey4': RGBColor(red=10, green=10, blue=10), 'grey40': RGBColor(red=102, green=102, blue=102), 'grey41': RGBColor(red=105, green=105, blue=105), 'grey42': RGBColor(red=107, green=107, blue=107), 'grey43': RGBColor(red=110, green=110, blue=110), 'grey44': RGBColor(red=112, green=112, blue=112), 'grey45': RGBColor(red=115, green=115, blue=115), 'grey46': RGBColor(red=117, green=117, blue=117), 'grey47': RGBColor(red=120, green=120, blue=120), 'grey48': RGBColor(red=122, green=122, blue=122), 'grey49': RGBColor(red=125, green=125, blue=125), 'grey5': RGBColor(red=13, green=13, blue=13), 'grey50': RGBColor(red=127, green=127, blue=127), 'grey51': RGBColor(red=130, green=130, blue=130), 'grey52': RGBColor(red=133, green=133, blue=133), 'grey53': RGBColor(red=135, green=135, blue=135), 'grey54': RGBColor(red=138, green=138, blue=138), 'grey55': RGBColor(red=140, green=140, blue=140), 'grey56': RGBColor(red=143, green=143, blue=143), 'grey57': RGBColor(red=145, green=145, blue=145), 'grey58': RGBColor(red=148, green=148, blue=148), 'grey59': RGBColor(red=150, green=150, blue=150), 'grey6': RGBColor(red=15, green=15, blue=15), 'grey60': RGBColor(red=153, green=153, blue=153), 'grey61': RGBColor(red=156, green=156, blue=156), 'grey62': RGBColor(red=158, green=158, blue=158), 'grey63': RGBColor(red=161, green=161, blue=161), 'grey64': RGBColor(red=163, green=163, blue=163), 'grey65': RGBColor(red=166, green=166, blue=166), 'grey66': RGBColor(red=168, green=168, blue=168), 'grey67': RGBColor(red=171, green=171, blue=171), 'grey68': RGBColor(red=173, green=173, blue=173), 'grey69': RGBColor(red=176, green=176, blue=176), 'grey7': RGBColor(red=18, green=18, blue=18), 'grey70': RGBColor(red=179, green=179, blue=179), 'grey71': RGBColor(red=181, green=181, blue=181), 'grey72': RGBColor(red=184, green=184, blue=184), 'grey73': RGBColor(red=186, green=186, blue=186), 'grey74': RGBColor(red=189, green=189, blue=189), 'grey75': RGBColor(red=191, green=191, blue=191), 'grey76': RGBColor(red=194, green=194, blue=194), 'grey77': RGBColor(red=196, green=196, blue=196), 'grey78': RGBColor(red=199, green=199, blue=199), 'grey79': RGBColor(red=201, green=201, blue=201), 'grey8': RGBColor(red=20, green=20, blue=20), 'grey80': RGBColor(red=204, green=204, blue=204), 'grey81': RGBColor(red=207, green=207, blue=207), 'grey82': RGBColor(red=209, green=209, blue=209), 'grey83': RGBColor(red=212, green=212, blue=212), 'grey84': RGBColor(red=214, green=214, blue=214), 'grey85': RGBColor(red=217, green=217, blue=217), 'grey86': RGBColor(red=219, green=219, blue=219), 'grey87': RGBColor(red=222, green=222, blue=222), 'grey88': RGBColor(red=224, green=224, blue=224), 'grey89': RGBColor(red=227, green=227, blue=227), 'grey9': RGBColor(red=23, green=23, blue=23), 'grey90': RGBColor(red=229, green=229, blue=229), 'grey91': RGBColor(red=232, green=232, blue=232), 'grey92': RGBColor(red=235, green=235, blue=235), 'grey93': RGBColor(red=237, green=237, blue=237), 'grey94': RGBColor(red=240, green=240, blue=240), 'grey95': RGBColor(red=242, green=242, blue=242), 'grey96': RGBColor(red=245, green=245, blue=245), 'grey97': RGBColor(red=247, green=247, blue=247), 'grey98': RGBColor(red=250, green=250, blue=250), 'grey99': RGBColor(red=252, green=252, blue=252), 'honeydew': RGBColor(red=240, green=255, blue=240), 'honeydew1': RGBColor(red=240, green=255, blue=240), 'honeydew2': RGBColor(red=224, green=238, blue=224), 'honeydew3': RGBColor(red=193, green=205, blue=193), 'honeydew4': RGBColor(red=131, green=139, blue=131), 'hotpink': RGBColor(red=255, green=105, blue=180), 'hotpink1': RGBColor(red=255, green=110, blue=180), 'hotpink2': RGBColor(red=238, green=106, blue=167), 'hotpink3': RGBColor(red=205, green=96, blue=144), 'hotpink4': RGBColor(red=139, green=58, blue=98), 'indianred': RGBColor(red=205, green=92, blue=92), 'indianred1': RGBColor(red=255, green=106, blue=106), 'indianred2': RGBColor(red=238, green=99, blue=99), 'indianred3': RGBColor(red=205, green=85, blue=85), 'indianred4': RGBColor(red=139, green=58, blue=58), 'indigo': RGBColor(red=75, green=0, blue=130), 'ivory': RGBColor(red=255, green=255, blue=240), 'ivory1': RGBColor(red=255, green=255, blue=240), 'ivory2': RGBColor(red=238, green=238, blue=224), 'ivory3': RGBColor(red=205, green=205, blue=193), 'ivory4': RGBColor(red=139, green=139, blue=131), 'khaki': RGBColor(red=240, green=230, blue=140), 'khaki1': RGBColor(red=255, green=246, blue=143), 'khaki2': RGBColor(red=238, green=230, blue=133), 'khaki3': RGBColor(red=205, green=198, blue=115), 'khaki4': RGBColor(red=139, green=134, blue=78), 'lavender': RGBColor(red=230, green=230, blue=250), 'lavenderblush': RGBColor(red=255, green=240, blue=245), 'lavenderblush1': RGBColor(red=255, green=240, blue=245), 'lavenderblush2': RGBColor(red=238, green=224, blue=229), 'lavenderblush3': RGBColor(red=205, green=193, blue=197), 'lavenderblush4': RGBColor(red=139, green=131, blue=134), 'lawngreen': RGBColor(red=124, green=252, blue=0), 'lemonchiffon': RGBColor(red=255, green=250, blue=205), 'lemonchiffon1': RGBColor(red=255, green=250, blue=205), 'lemonchiffon2': RGBColor(red=238, green=233, blue=191), 'lemonchiffon3': RGBColor(red=205, green=201, blue=165), 'lemonchiffon4': RGBColor(red=139, green=137, blue=112), 'lightblue': RGBColor(red=173, green=216, blue=230), 'lightblue1': RGBColor(red=191, green=239, blue=255), 'lightblue2': RGBColor(red=178, green=223, blue=238), 'lightblue3': RGBColor(red=154, green=192, blue=205), 'lightblue4': RGBColor(red=104, green=131, blue=139), 'lightcoral': RGBColor(red=240, green=128, blue=128), 'lightcyan': RGBColor(red=224, green=255, blue=255), 'lightcyan1': RGBColor(red=224, green=255, blue=255), 'lightcyan2': RGBColor(red=209, green=238, blue=238), 'lightcyan3': RGBColor(red=180, green=205, blue=205), 'lightcyan4': RGBColor(red=122, green=139, blue=139), 'lightgoldenrod': RGBColor(red=238, green=221, blue=130), 'lightgoldenrod1': RGBColor(red=255, green=236, blue=139), 'lightgoldenrod2': RGBColor(red=238, green=220, blue=130), 'lightgoldenrod3': RGBColor(red=205, green=190, blue=112), 'lightgoldenrod4': RGBColor(red=139, green=129, blue=76), 'lightgoldenrodyellow': RGBColor(red=250, green=250, blue=210), 'lightgray': RGBColor(red=211, green=211, blue=211), 'lightgreen': RGBColor(red=144, green=238, blue=144), 'lightgrey': RGBColor(red=211, green=211, blue=211), 'lightpink': RGBColor(red=255, green=182, blue=193), 'lightpink1': RGBColor(red=255, green=174, blue=185), 'lightpink2': RGBColor(red=238, green=162, blue=173), 'lightpink3': RGBColor(red=205, green=140, blue=149), 'lightpink4': RGBColor(red=139, green=95, blue=101), 'lightsalmon': RGBColor(red=255, green=160, blue=122), 'lightsalmon1': RGBColor(red=255, green=160, blue=122), 'lightsalmon2': RGBColor(red=238, green=149, blue=114), 'lightsalmon3': RGBColor(red=205, green=129, blue=98), 'lightsalmon4': RGBColor(red=139, green=87, blue=66), 'lightseagreen': RGBColor(red=32, green=178, blue=170), 'lightskyblue': RGBColor(red=135, green=206, blue=250), 'lightskyblue1': RGBColor(red=176, green=226, blue=255), 'lightskyblue2': RGBColor(red=164, green=211, blue=238), 'lightskyblue3': RGBColor(red=141, green=182, blue=205), 'lightskyblue4': RGBColor(red=96, green=123, blue=139), 'lightslateblue': RGBColor(red=132, green=112, blue=255), 'lightslategray': RGBColor(red=119, green=136, blue=153), 'lightslategrey': RGBColor(red=119, green=136, blue=153), 'lightsteelblue': RGBColor(red=176, green=196, blue=222), 'lightsteelblue1': RGBColor(red=202, green=225, blue=255), 'lightsteelblue2': RGBColor(red=188, green=210, blue=238), 'lightsteelblue3': RGBColor(red=162, green=181, blue=205), 'lightsteelblue4': RGBColor(red=110, green=123, blue=139), 'lightyellow': RGBColor(red=255, green=255, blue=224), 'lightyellow1': RGBColor(red=255, green=255, blue=224), 'lightyellow2': RGBColor(red=238, green=238, blue=209), 'lightyellow3': RGBColor(red=205, green=205, blue=180), 'lightyellow4': RGBColor(red=139, green=139, blue=122), 'lime': RGBColor(red=0, green=255, blue=0), 'limegreen': RGBColor(red=50, green=205, blue=50), 'linen': RGBColor(red=250, green=240, blue=230), 'magenta': RGBColor(red=255, green=0, blue=255), 'magenta1': RGBColor(red=255, green=0, blue=255), 'magenta2': RGBColor(red=238, green=0, blue=238), 'magenta3': RGBColor(red=205, green=0, blue=205), 'magenta4': RGBColor(red=139, green=0, blue=139), 'maroon': RGBColor(red=176, green=48, blue=96), 'maroon1': RGBColor(red=255, green=52, blue=179), 'maroon2': RGBColor(red=238, green=48, blue=167), 'maroon3': RGBColor(red=205, green=41, blue=144), 'maroon4': RGBColor(red=139, green=28, blue=98), 'mediumaquamarine': RGBColor(red=102, green=205, blue=170), 'mediumblue': RGBColor(red=0, green=0, blue=205), 'mediumorchid': RGBColor(red=186, green=85, blue=211), 'mediumorchid1': RGBColor(red=224, green=102, blue=255), 'mediumorchid2': RGBColor(red=209, green=95, blue=238), 'mediumorchid3': RGBColor(red=180, green=82, blue=205), 'mediumorchid4': RGBColor(red=122, green=55, blue=139), 'mediumpurple': RGBColor(red=147, green=112, blue=219), 'mediumpurple1': RGBColor(red=171, green=130, blue=255), 'mediumpurple2': RGBColor(red=159, green=121, blue=238), 'mediumpurple3': RGBColor(red=137, green=104, blue=205), 'mediumpurple4': RGBColor(red=93, green=71, blue=139), 'mediumseagreen': RGBColor(red=60, green=179, blue=113), 'mediumslateblue': RGBColor(red=123, green=104, blue=238), 'mediumspringgreen': RGBColor(red=0, green=250, blue=154), 'mediumturquoise': RGBColor(red=72, green=209, blue=204), 'mediumvioletred': RGBColor(red=199, green=21, blue=133), 'midnightblue': RGBColor(red=25, green=25, blue=112), 'mintcream': RGBColor(red=245, green=255, blue=250), 'mistyrose': RGBColor(red=255, green=228, blue=225), 'mistyrose1': RGBColor(red=255, green=228, blue=225), 'mistyrose2': RGBColor(red=238, green=213, blue=210), 'mistyrose3': RGBColor(red=205, green=183, blue=181), 'mistyrose4': RGBColor(red=139, green=125, blue=123), 'moccasin': RGBColor(red=255, green=228, blue=181), 'navajowhite': RGBColor(red=255, green=222, blue=173), 'navajowhite1': RGBColor(red=255, green=222, blue=173), 'navajowhite2': RGBColor(red=238, green=207, blue=161), 'navajowhite3': RGBColor(red=205, green=179, blue=139), 'navajowhite4': RGBColor(red=139, green=121, blue=94), 'navy': RGBColor(red=0, green=0, blue=128), 'navyblue': RGBColor(red=0, green=0, blue=128), 'oldlace': RGBColor(red=253, green=245, blue=230), 'olive': RGBColor(red=128, green=128, blue=0), 'olivedrab': RGBColor(red=107, green=142, blue=35), 'olivedrab1': RGBColor(red=192, green=255, blue=62), 'olivedrab2': RGBColor(red=179, green=238, blue=58), 'olivedrab3': RGBColor(red=154, green=205, blue=50), 'olivedrab4': RGBColor(red=105, green=139, blue=34), 'orange': RGBColor(red=255, green=165, blue=0), 'orange1': RGBColor(red=255, green=165, blue=0), 'orange2': RGBColor(red=238, green=154, blue=0), 'orange3': RGBColor(red=205, green=133, blue=0), 'orange4': RGBColor(red=139, green=90, blue=0), 'orangered': RGBColor(red=255, green=69, blue=0), 'orangered1': RGBColor(red=255, green=69, blue=0), 'orangered2': RGBColor(red=238, green=64, blue=0), 'orangered3': RGBColor(red=205, green=55, blue=0), 'orangered4': RGBColor(red=139, green=37, blue=0), 'orchid': RGBColor(red=218, green=112, blue=214), 'orchid1': RGBColor(red=255, green=131, blue=250), 'orchid2': RGBColor(red=238, green=122, blue=233), 'orchid3': RGBColor(red=205, green=105, blue=201), 'orchid4': RGBColor(red=139, green=71, blue=137), 'palegoldenrod': RGBColor(red=238, green=232, blue=170), 'palegreen': RGBColor(red=152, green=251, blue=152), 'palegreen1': RGBColor(red=154, green=255, blue=154), 'palegreen2': RGBColor(red=144, green=238, blue=144), 'palegreen3': RGBColor(red=124, green=205, blue=124), 'palegreen4': RGBColor(red=84, green=139, blue=84), 'paleturquoise': RGBColor(red=175, green=238, blue=238), 'paleturquoise1': RGBColor(red=187, green=255, blue=255), 'paleturquoise2': RGBColor(red=174, green=238, blue=238), 'paleturquoise3': RGBColor(red=150, green=205, blue=205), 'paleturquoise4': RGBColor(red=102, green=139, blue=139), 'palevioletred': RGBColor(red=219, green=112, blue=147), 'palevioletred1': RGBColor(red=255, green=130, blue=171), 'palevioletred2': RGBColor(red=238, green=121, blue=159), 'palevioletred3': RGBColor(red=205, green=104, blue=137), 'palevioletred4': RGBColor(red=139, green=71, blue=93), 'papayawhip': RGBColor(red=255, green=239, blue=213), 'peachpuff': RGBColor(red=255, green=218, blue=185), 'peachpuff1': RGBColor(red=255, green=218, blue=185), 'peachpuff2': RGBColor(red=238, green=203, blue=173), 'peachpuff3': RGBColor(red=205, green=175, blue=149), 'peachpuff4': RGBColor(red=139, green=119, blue=101), 'peru': RGBColor(red=205, green=133, blue=63), 'pink': RGBColor(red=255, green=192, blue=203), 'pink1': RGBColor(red=255, green=181, blue=197), 'pink2': RGBColor(red=238, green=169, blue=184), 'pink3': RGBColor(red=205, green=145, blue=158), 'pink4': RGBColor(red=139, green=99, blue=108), 'plum': RGBColor(red=221, green=160, blue=221), 'plum1': RGBColor(red=255, green=187, blue=255), 'plum2': RGBColor(red=238, green=174, blue=238), 'plum3': RGBColor(red=205, green=150, blue=205), 'plum4': RGBColor(red=139, green=102, blue=139), 'powderblue': RGBColor(red=176, green=224, blue=230), 'purple': RGBColor(red=160, green=32, blue=240), 'purple1': RGBColor(red=155, green=48, blue=255), 'purple2': RGBColor(red=145, green=44, blue=238), 'purple3': RGBColor(red=125, green=38, blue=205), 'purple4': RGBColor(red=85, green=26, blue=139), 'rebeccapurple': RGBColor(red=102, green=51, blue=153), 'red': RGBColor(red=255, green=0, blue=0), 'red1': RGBColor(red=255, green=0, blue=0), 'red2': RGBColor(red=238, green=0, blue=0), 'red3': RGBColor(red=205, green=0, blue=0), 'red4': RGBColor(red=139, green=0, blue=0), 'rosybrown': RGBColor(red=188, green=143, blue=143), 'rosybrown1': RGBColor(red=255, green=193, blue=193), 'rosybrown2': RGBColor(red=238, green=180, blue=180), 'rosybrown3': RGBColor(red=205, green=155, blue=155), 'rosybrown4': RGBColor(red=139, green=105, blue=105), 'royalblue': RGBColor(red=65, green=105, blue=225), 'royalblue1': RGBColor(red=72, green=118, blue=255), 'royalblue2': RGBColor(red=67, green=110, blue=238), 'royalblue3': RGBColor(red=58, green=95, blue=205), 'royalblue4': RGBColor(red=39, green=64, blue=139), 'saddlebrown': RGBColor(red=139, green=69, blue=19), 'salmon': RGBColor(red=250, green=128, blue=114), 'salmon1': RGBColor(red=255, green=140, blue=105), 'salmon2': RGBColor(red=238, green=130, blue=98), 'salmon3': RGBColor(red=205, green=112, blue=84), 'salmon4': RGBColor(red=139, green=76, blue=57), 'sandybrown': RGBColor(red=244, green=164, blue=96), 'seagreen': RGBColor(red=46, green=139, blue=87), 'seagreen1': RGBColor(red=84, green=255, blue=159), 'seagreen2': RGBColor(red=78, green=238, blue=148), 'seagreen3': RGBColor(red=67, green=205, blue=128), 'seagreen4': RGBColor(red=46, green=139, blue=87), 'seashell': RGBColor(red=255, green=245, blue=238), 'seashell1': RGBColor(red=255, green=245, blue=238), 'seashell2': RGBColor(red=238, green=229, blue=222), 'seashell3': RGBColor(red=205, green=197, blue=191), 'seashell4': RGBColor(red=139, green=134, blue=130), 'sienna': RGBColor(red=160, green=82, blue=45), 'sienna1': RGBColor(red=255, green=130, blue=71), 'sienna2': RGBColor(red=238, green=121, blue=66), 'sienna3': RGBColor(red=205, green=104, blue=57), 'sienna4': RGBColor(red=139, green=71, blue=38), 'silver': RGBColor(red=192, green=192, blue=192), 'skyblue': RGBColor(red=135, green=206, blue=235), 'skyblue1': RGBColor(red=135, green=206, blue=255), 'skyblue2': RGBColor(red=126, green=192, blue=238), 'skyblue3': RGBColor(red=108, green=166, blue=205), 'skyblue4': RGBColor(red=74, green=112, blue=139), 'slateblue': RGBColor(red=106, green=90, blue=205), 'slateblue1': RGBColor(red=131, green=111, blue=255), 'slateblue2': RGBColor(red=122, green=103, blue=238), 'slateblue3': RGBColor(red=105, green=89, blue=205), 'slateblue4': RGBColor(red=71, green=60, blue=139), 'slategray': RGBColor(red=112, green=128, blue=144), 'slategray1': RGBColor(red=198, green=226, blue=255), 'slategray2': RGBColor(red=185, green=211, blue=238), 'slategray3': RGBColor(red=159, green=182, blue=205), 'slategray4': RGBColor(red=108, green=123, blue=139), 'slategrey': RGBColor(red=112, green=128, blue=144), 'snow': RGBColor(red=255, green=250, blue=250), 'snow1': RGBColor(red=255, green=250, blue=250), 'snow2': RGBColor(red=238, green=233, blue=233), 'snow3': RGBColor(red=205, green=201, blue=201), 'snow4': RGBColor(red=139, green=137, blue=137), 'springgreen': RGBColor(red=0, green=255, blue=127), 'springgreen1': RGBColor(red=0, green=255, blue=127), 'springgreen2': RGBColor(red=0, green=238, blue=118), 'springgreen3': RGBColor(red=0, green=205, blue=102), 'springgreen4': RGBColor(red=0, green=139, blue=69), 'steelblue': RGBColor(red=70, green=130, blue=180), 'steelblue1': RGBColor(red=99, green=184, blue=255), 'steelblue2': RGBColor(red=92, green=172, blue=238), 'steelblue3': RGBColor(red=79, green=148, blue=205), 'steelblue4': RGBColor(red=54, green=100, blue=139), 'tan': RGBColor(red=210, green=180, blue=140), 'tan1': RGBColor(red=255, green=165, blue=79), 'tan2': RGBColor(red=238, green=154, blue=73), 'tan3': RGBColor(red=205, green=133, blue=63), 'tan4': RGBColor(red=139, green=90, blue=43), 'teal': RGBColor(red=0, green=128, blue=128), 'thistle': RGBColor(red=216, green=191, blue=216), 'thistle1': RGBColor(red=255, green=225, blue=255), 'thistle2': RGBColor(red=238, green=210, blue=238), 'thistle3': RGBColor(red=205, green=181, blue=205), 'thistle4': RGBColor(red=139, green=123, blue=139), 'tomato': RGBColor(red=255, green=99, blue=71), 'tomato1': RGBColor(red=255, green=99, blue=71), 'tomato2': RGBColor(red=238, green=92, blue=66), 'tomato3': RGBColor(red=205, green=79, blue=57), 'tomato4': RGBColor(red=139, green=54, blue=38), 'turquoise': RGBColor(red=64, green=224, blue=208), 'turquoise1': RGBColor(red=0, green=245, blue=255), 'turquoise2': RGBColor(red=0, green=229, blue=238), 'turquoise3': RGBColor(red=0, green=197, blue=205), 'turquoise4': RGBColor(red=0, green=134, blue=139), 'violet': RGBColor(red=238, green=130, blue=238), 'violetred': RGBColor(red=208, green=32, blue=144), 'violetred1': RGBColor(red=255, green=62, blue=150), 'violetred2': RGBColor(red=238, green=58, blue=140), 'violetred3': RGBColor(red=205, green=50, blue=120), 'violetred4': RGBColor(red=139, green=34, blue=82), 'webgray': RGBColor(red=128, green=128, blue=128), 'webgreen': RGBColor(red=0, green=128, blue=0), 'webgrey': RGBColor(red=128, green=128, blue=128), 'webmaroon': RGBColor(red=128, green=0, blue=0), 'webpurple': RGBColor(red=128, green=0, blue=128), 'wheat': RGBColor(red=245, green=222, blue=179), 'wheat1': RGBColor(red=255, green=231, blue=186), 'wheat2': RGBColor(red=238, green=216, blue=174), 'wheat3': RGBColor(red=205, green=186, blue=150), 'wheat4': RGBColor(red=139, green=126, blue=102), 'white': RGBColor(red=255, green=255, blue=255), 'whitesmoke': RGBColor(red=245, green=245, blue=245), 'x11gray': RGBColor(red=190, green=190, blue=190), 'x11green': RGBColor(red=0, green=255, blue=0), 'x11grey': RGBColor(red=190, green=190, blue=190), 'x11maroon': RGBColor(red=176, green=48, blue=96), 'x11purple': RGBColor(red=160, green=32, blue=240), 'yellow': RGBColor(red=255, green=255, blue=0), 'yellow1': RGBColor(red=255, green=255, blue=0), 'yellow2': RGBColor(red=238, green=238, blue=0), 'yellow3': RGBColor(red=205, green=205, blue=0), 'yellow4': RGBColor(red=139, green=139, blue=0), 'yellowgreen': RGBColor(red=154, green=205, blue=50)}

X11 Color names to (XTerm-defined) RGB values from xorg-rgb/rgb.txt

RGB_256TABLE = (RGBColor(red=0, green=0, blue=0), RGBColor(red=205, green=0, blue=0), RGBColor(red=0, green=205, blue=0), RGBColor(red=205, green=205, blue=0), RGBColor(red=0, green=0, blue=238), RGBColor(red=205, green=0, blue=205), RGBColor(red=0, green=205, blue=205), RGBColor(red=229, green=229, blue=229), RGBColor(red=127, green=127, blue=127), RGBColor(red=255, green=0, blue=0), RGBColor(red=0, green=255, blue=0), RGBColor(red=255, green=255, blue=0), RGBColor(red=92, green=92, blue=255), RGBColor(red=255, green=0, blue=255), RGBColor(red=0, green=255, blue=255), RGBColor(red=255, green=255, blue=255), RGBColor(red=0, green=0, blue=0), RGBColor(red=0, green=0, blue=95), RGBColor(red=0, green=0, blue=135), RGBColor(red=0, green=0, blue=175), RGBColor(red=0, green=0, blue=215), RGBColor(red=0, green=0, blue=255), RGBColor(red=0, green=95, blue=0), RGBColor(red=0, green=95, blue=95), RGBColor(red=0, green=95, blue=135), RGBColor(red=0, green=95, blue=175), RGBColor(red=0, green=95, blue=215), RGBColor(red=0, green=95, blue=255), RGBColor(red=0, green=135, blue=0), RGBColor(red=0, green=135, blue=95), RGBColor(red=0, green=135, blue=135), RGBColor(red=0, green=135, blue=175), RGBColor(red=0, green=135, blue=215), RGBColor(red=0, green=135, blue=255), RGBColor(red=0, green=175, blue=0), RGBColor(red=0, green=175, blue=95), RGBColor(red=0, green=175, blue=135), RGBColor(red=0, green=175, blue=175), RGBColor(red=0, green=175, blue=215), RGBColor(red=0, green=175, blue=255), RGBColor(red=0, green=215, blue=0), RGBColor(red=0, green=215, blue=95), RGBColor(red=0, green=215, blue=135), RGBColor(red=0, green=215, blue=175), RGBColor(red=0, green=215, blue=215), RGBColor(red=0, green=215, blue=255), RGBColor(red=0, green=255, blue=0), RGBColor(red=0, green=255, blue=95), RGBColor(red=0, green=255, blue=135), RGBColor(red=0, green=255, blue=175), RGBColor(red=0, green=255, blue=215), RGBColor(red=0, green=255, blue=255), RGBColor(red=95, green=0, blue=0), RGBColor(red=95, green=0, blue=95), RGBColor(red=95, green=0, blue=135), RGBColor(red=95, green=0, blue=175), RGBColor(red=95, green=0, blue=215), RGBColor(red=95, green=0, blue=255), RGBColor(red=95, green=95, blue=0), RGBColor(red=95, green=95, blue=95), RGBColor(red=95, green=95, blue=135), RGBColor(red=95, green=95, blue=175), RGBColor(red=95, green=95, blue=215), RGBColor(red=95, green=95, blue=255), RGBColor(red=95, green=135, blue=0), RGBColor(red=95, green=135, blue=95), RGBColor(red=95, green=135, blue=135), RGBColor(red=95, green=135, blue=175), RGBColor(red=95, green=135, blue=215), RGBColor(red=95, green=135, blue=255), RGBColor(red=95, green=175, blue=0), RGBColor(red=95, green=175, blue=95), RGBColor(red=95, green=175, blue=135), RGBColor(red=95, green=175, blue=175), RGBColor(red=95, green=175, blue=215), RGBColor(red=95, green=175, blue=255), RGBColor(red=95, green=215, blue=0), RGBColor(red=95, green=215, blue=95), RGBColor(red=95, green=215, blue=135), RGBColor(red=95, green=215, blue=175), RGBColor(red=95, green=215, blue=215), RGBColor(red=95, green=215, blue=255), RGBColor(red=95, green=255, blue=0), RGBColor(red=95, green=255, blue=95), RGBColor(red=95, green=255, blue=135), RGBColor(red=95, green=255, blue=175), RGBColor(red=95, green=255, blue=215), RGBColor(red=95, green=255, blue=255), RGBColor(red=135, green=0, blue=0), RGBColor(red=135, green=0, blue=95), RGBColor(red=135, green=0, blue=135), RGBColor(red=135, green=0, blue=175), RGBColor(red=135, green=0, blue=215), RGBColor(red=135, green=0, blue=255), RGBColor(red=135, green=95, blue=0), RGBColor(red=135, green=95, blue=95), RGBColor(red=135, green=95, blue=135), RGBColor(red=135, green=95, blue=175), RGBColor(red=135, green=95, blue=215), RGBColor(red=135, green=95, blue=255), RGBColor(red=135, green=135, blue=0), RGBColor(red=135, green=135, blue=95), RGBColor(red=135, green=135, blue=135), RGBColor(red=135, green=135, blue=175), RGBColor(red=135, green=135, blue=215), RGBColor(red=135, green=135, blue=255), RGBColor(red=135, green=175, blue=0), RGBColor(red=135, green=175, blue=95), RGBColor(red=135, green=175, blue=135), RGBColor(red=135, green=175, blue=175), RGBColor(red=135, green=175, blue=215), RGBColor(red=135, green=175, blue=255), RGBColor(red=135, green=215, blue=0), RGBColor(red=135, green=215, blue=95), RGBColor(red=135, green=215, blue=135), RGBColor(red=135, green=215, blue=175), RGBColor(red=135, green=215, blue=215), RGBColor(red=135, green=215, blue=255), RGBColor(red=135, green=255, blue=0), RGBColor(red=135, green=255, blue=95), RGBColor(red=135, green=255, blue=135), RGBColor(red=135, green=255, blue=175), RGBColor(red=135, green=255, blue=215), RGBColor(red=135, green=255, blue=255), RGBColor(red=175, green=0, blue=0), RGBColor(red=175, green=0, blue=95), RGBColor(red=175, green=0, blue=135), RGBColor(red=175, green=0, blue=175), RGBColor(red=175, green=0, blue=215), RGBColor(red=175, green=0, blue=255), RGBColor(red=175, green=95, blue=0), RGBColor(red=175, green=95, blue=95), RGBColor(red=175, green=95, blue=135), RGBColor(red=175, green=95, blue=175), RGBColor(red=175, green=95, blue=215), RGBColor(red=175, green=95, blue=255), RGBColor(red=175, green=135, blue=0), RGBColor(red=175, green=135, blue=95), RGBColor(red=175, green=135, blue=135), RGBColor(red=175, green=135, blue=175), RGBColor(red=175, green=135, blue=215), RGBColor(red=175, green=135, blue=255), RGBColor(red=175, green=175, blue=0), RGBColor(red=175, green=175, blue=95), RGBColor(red=175, green=175, blue=135), RGBColor(red=175, green=175, blue=175), RGBColor(red=175, green=175, blue=215), RGBColor(red=175, green=175, blue=255), RGBColor(red=175, green=215, blue=0), RGBColor(red=175, green=215, blue=95), RGBColor(red=175, green=215, blue=135), RGBColor(red=175, green=215, blue=175), RGBColor(red=175, green=215, blue=215), RGBColor(red=175, green=215, blue=255), RGBColor(red=175, green=255, blue=0), RGBColor(red=175, green=255, blue=95), RGBColor(red=175, green=255, blue=135), RGBColor(red=175, green=255, blue=175), RGBColor(red=175, green=255, blue=215), RGBColor(red=175, green=255, blue=255), RGBColor(red=215, green=0, blue=0), RGBColor(red=215, green=0, blue=95), RGBColor(red=215, green=0, blue=135), RGBColor(red=215, green=0, blue=175), RGBColor(red=215, green=0, blue=215), RGBColor(red=215, green=0, blue=255), RGBColor(red=215, green=95, blue=0), RGBColor(red=215, green=95, blue=95), RGBColor(red=215, green=95, blue=135), RGBColor(red=215, green=95, blue=175), RGBColor(red=215, green=95, blue=215), RGBColor(red=215, green=95, blue=255), RGBColor(red=215, green=135, blue=0), RGBColor(red=215, green=135, blue=95), RGBColor(red=215, green=135, blue=135), RGBColor(red=215, green=135, blue=175), RGBColor(red=215, green=135, blue=215), RGBColor(red=215, green=135, blue=255), RGBColor(red=215, green=175, blue=0), RGBColor(red=215, green=175, blue=95), RGBColor(red=215, green=175, blue=135), RGBColor(red=215, green=175, blue=175), RGBColor(red=215, green=175, blue=215), RGBColor(red=215, green=175, blue=255), RGBColor(red=215, green=215, blue=0), RGBColor(red=215, green=215, blue=95), RGBColor(red=215, green=215, blue=135), RGBColor(red=215, green=215, blue=175), RGBColor(red=215, green=215, blue=215), RGBColor(red=215, green=215, blue=255), RGBColor(red=215, green=255, blue=0), RGBColor(red=215, green=255, blue=95), RGBColor(red=215, green=255, blue=135), RGBColor(red=215, green=255, blue=175), RGBColor(red=215, green=255, blue=215), RGBColor(red=215, green=255, blue=255), RGBColor(red=255, green=0, blue=0), RGBColor(red=255, green=0, blue=135), RGBColor(red=255, green=0, blue=95), RGBColor(red=255, green=0, blue=175), RGBColor(red=255, green=0, blue=215), RGBColor(red=255, green=0, blue=255), RGBColor(red=255, green=95, blue=0), RGBColor(red=255, green=95, blue=95), RGBColor(red=255, green=95, blue=135), RGBColor(red=255, green=95, blue=175), RGBColor(red=255, green=95, blue=215), RGBColor(red=255, green=95, blue=255), RGBColor(red=255, green=135, blue=0), RGBColor(red=255, green=135, blue=95), RGBColor(red=255, green=135, blue=135), RGBColor(red=255, green=135, blue=175), RGBColor(red=255, green=135, blue=215), RGBColor(red=255, green=135, blue=255), RGBColor(red=255, green=175, blue=0), RGBColor(red=255, green=175, blue=95), RGBColor(red=255, green=175, blue=135), RGBColor(red=255, green=175, blue=175), RGBColor(red=255, green=175, blue=215), RGBColor(red=255, green=175, blue=255), RGBColor(red=255, green=215, blue=0), RGBColor(red=255, green=215, blue=95), RGBColor(red=255, green=215, blue=135), RGBColor(red=255, green=215, blue=175), RGBColor(red=255, green=215, blue=215), RGBColor(red=255, green=215, blue=255), RGBColor(red=255, green=255, blue=0), RGBColor(red=255, green=255, blue=95), RGBColor(red=255, green=255, blue=135), RGBColor(red=255, green=255, blue=175), RGBColor(red=255, green=255, blue=215), RGBColor(red=255, green=255, blue=255), RGBColor(red=8, green=8, blue=8), RGBColor(red=18, green=18, blue=18), RGBColor(red=28, green=28, blue=28), RGBColor(red=38, green=38, blue=38), RGBColor(red=48, green=48, blue=48), RGBColor(red=58, green=58, blue=58), RGBColor(red=68, green=68, blue=68), RGBColor(red=78, green=78, blue=78), RGBColor(red=88, green=88, blue=88), RGBColor(red=98, green=98, blue=98), RGBColor(red=108, green=108, blue=108), RGBColor(red=118, green=118, blue=118), RGBColor(red=128, green=128, blue=128), RGBColor(red=138, green=138, blue=138), RGBColor(red=148, green=148, blue=148), RGBColor(red=158, green=158, blue=158), RGBColor(red=168, green=168, blue=168), RGBColor(red=178, green=178, blue=178), RGBColor(red=188, green=188, blue=188), RGBColor(red=198, green=198, blue=198), RGBColor(red=208, green=208, blue=208), RGBColor(red=218, green=218, blue=218), RGBColor(red=228, green=228, blue=228), RGBColor(red=238, green=238, blue=238))

Curses color indices of 8, 16, and 256-color terminals

formatters.py

Sub-module providing sequence-formatting functions.

_make_colors()[source]

Return set of valid colors and their derivatives.

Return type

set

COLORS = {'aliceblue', 'antiquewhite', 'antiquewhite1', 'antiquewhite2', 'antiquewhite3', 'antiquewhite4', 'aqua', 'aquamarine', 'aquamarine1', 'aquamarine2', 'aquamarine3', 'aquamarine4', 'azure', 'azure1', 'azure2', 'azure3', 'azure4', 'beige', 'bisque', 'bisque1', 'bisque2', 'bisque3', 'bisque4', 'black', 'blanchedalmond', 'blue', 'blue1', 'blue2', 'blue3', 'blue4', 'blueviolet', 'bright_black', 'bright_blue', 'bright_cyan', 'bright_green', 'bright_magenta', 'bright_red', 'bright_white', 'bright_yellow', 'brown', 'brown1', 'brown2', 'brown3', 'brown4', 'burlywood', 'burlywood1', 'burlywood2', 'burlywood3', 'burlywood4', 'cadetblue', 'cadetblue1', 'cadetblue2', 'cadetblue3', 'cadetblue4', 'chartreuse', 'chartreuse1', 'chartreuse2', 'chartreuse3', 'chartreuse4', 'chocolate', 'chocolate1', 'chocolate2', 'chocolate3', 'chocolate4', 'coral', 'coral1', 'coral2', 'coral3', 'coral4', 'cornflowerblue', 'cornsilk', 'cornsilk1', 'cornsilk2', 'cornsilk3', 'cornsilk4', 'crimson', 'cyan', 'cyan1', 'cyan2', 'cyan3', 'cyan4', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgoldenrod1', 'darkgoldenrod2', 'darkgoldenrod3', 'darkgoldenrod4', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkolivegreen1', 'darkolivegreen2', 'darkolivegreen3', 'darkolivegreen4', 'darkorange', 'darkorange1', 'darkorange2', 'darkorange3', 'darkorange4', 'darkorchid', 'darkorchid1', 'darkorchid2', 'darkorchid3', 'darkorchid4', 'darkred', 'darksalmon', 'darkseagreen', 'darkseagreen1', 'darkseagreen2', 'darkseagreen3', 'darkseagreen4', 'darkslateblue', 'darkslategray', 'darkslategray1', 'darkslategray2', 'darkslategray3', 'darkslategray4', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deeppink1', 'deeppink2', 'deeppink3', 'deeppink4', 'deepskyblue', 'deepskyblue1', 'deepskyblue2', 'deepskyblue3', 'deepskyblue4', 'dimgray', 'dimgrey', 'dodgerblue', 'dodgerblue1', 'dodgerblue2', 'dodgerblue3', 'dodgerblue4', 'firebrick', 'firebrick1', 'firebrick2', 'firebrick3', 'firebrick4', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'gold1', 'gold2', 'gold3', 'gold4', 'goldenrod', 'goldenrod1', 'goldenrod2', 'goldenrod3', 'goldenrod4', 'gray', 'gray0', 'gray1', 'gray10', 'gray100', 'gray11', 'gray12', 'gray13', 'gray14', 'gray15', 'gray16', 'gray17', 'gray18', 'gray19', 'gray2', 'gray20', 'gray21', 'gray22', 'gray23', 'gray24', 'gray25', 'gray26', 'gray27', 'gray28', 'gray29', 'gray3', 'gray30', 'gray31', 'gray32', 'gray33', 'gray34', 'gray35', 'gray36', 'gray37', 'gray38', 'gray39', 'gray4', 'gray40', 'gray41', 'gray42', 'gray43', 'gray44', 'gray45', 'gray46', 'gray47', 'gray48', 'gray49', 'gray5', 'gray50', 'gray51', 'gray52', 'gray53', 'gray54', 'gray55', 'gray56', 'gray57', 'gray58', 'gray59', 'gray6', 'gray60', 'gray61', 'gray62', 'gray63', 'gray64', 'gray65', 'gray66', 'gray67', 'gray68', 'gray69', 'gray7', 'gray70', 'gray71', 'gray72', 'gray73', 'gray74', 'gray75', 'gray76', 'gray77', 'gray78', 'gray79', 'gray8', 'gray80', 'gray81', 'gray82', 'gray83', 'gray84', 'gray85', 'gray86', 'gray87', 'gray88', 'gray89', 'gray9', 'gray90', 'gray91', 'gray92', 'gray93', 'gray94', 'gray95', 'gray96', 'gray97', 'gray98', 'gray99', 'green', 'green1', 'green2', 'green3', 'green4', 'greenyellow', 'grey', 'grey0', 'grey1', 'grey10', 'grey100', 'grey11', 'grey12', 'grey13', 'grey14', 'grey15', 'grey16', 'grey17', 'grey18', 'grey19', 'grey2', 'grey20', 'grey21', 'grey22', 'grey23', 'grey24', 'grey25', 'grey26', 'grey27', 'grey28', 'grey29', 'grey3', 'grey30', 'grey31', 'grey32', 'grey33', 'grey34', 'grey35', 'grey36', 'grey37', 'grey38', 'grey39', 'grey4', 'grey40', 'grey41', 'grey42', 'grey43', 'grey44', 'grey45', 'grey46', 'grey47', 'grey48', 'grey49', 'grey5', 'grey50', 'grey51', 'grey52', 'grey53', 'grey54', 'grey55', 'grey56', 'grey57', 'grey58', 'grey59', 'grey6', 'grey60', 'grey61', 'grey62', 'grey63', 'grey64', 'grey65', 'grey66', 'grey67', 'grey68', 'grey69', 'grey7', 'grey70', 'grey71', 'grey72', 'grey73', 'grey74', 'grey75', 'grey76', 'grey77', 'grey78', 'grey79', 'grey8', 'grey80', 'grey81', 'grey82', 'grey83', 'grey84', 'grey85', 'grey86', 'grey87', 'grey88', 'grey89', 'grey9', 'grey90', 'grey91', 'grey92', 'grey93', 'grey94', 'grey95', 'grey96', 'grey97', 'grey98', 'grey99', 'honeydew', 'honeydew1', 'honeydew2', 'honeydew3', 'honeydew4', 'hotpink', 'hotpink1', 'hotpink2', 'hotpink3', 'hotpink4', 'indianred', 'indianred1', 'indianred2', 'indianred3', 'indianred4', 'indigo', 'ivory', 'ivory1', 'ivory2', 'ivory3', 'ivory4', 'khaki', 'khaki1', 'khaki2', 'khaki3', 'khaki4', 'lavender', 'lavenderblush', 'lavenderblush1', 'lavenderblush2', 'lavenderblush3', 'lavenderblush4', 'lawngreen', 'lemonchiffon', 'lemonchiffon1', 'lemonchiffon2', 'lemonchiffon3', 'lemonchiffon4', 'lightblue', 'lightblue1', 'lightblue2', 'lightblue3', 'lightblue4', 'lightcoral', 'lightcyan', 'lightcyan1', 'lightcyan2', 'lightcyan3', 'lightcyan4', 'lightgoldenrod', 'lightgoldenrod1', 'lightgoldenrod2', 'lightgoldenrod3', 'lightgoldenrod4', 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', 'lightpink', 'lightpink1', 'lightpink2', 'lightpink3', 'lightpink4', 'lightsalmon', 'lightsalmon1', 'lightsalmon2', 'lightsalmon3', 'lightsalmon4', 'lightseagreen', 'lightskyblue', 'lightskyblue1', 'lightskyblue2', 'lightskyblue3', 'lightskyblue4', 'lightslateblue', 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightsteelblue1', 'lightsteelblue2', 'lightsteelblue3', 'lightsteelblue4', 'lightyellow', 'lightyellow1', 'lightyellow2', 'lightyellow3', 'lightyellow4', 'lime', 'limegreen', 'linen', 'magenta', 'magenta1', 'magenta2', 'magenta3', 'magenta4', 'maroon', 'maroon1', 'maroon2', 'maroon3', 'maroon4', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumorchid1', 'mediumorchid2', 'mediumorchid3', 'mediumorchid4', 'mediumpurple', 'mediumpurple1', 'mediumpurple2', 'mediumpurple3', 'mediumpurple4', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'mistyrose1', 'mistyrose2', 'mistyrose3', 'mistyrose4', 'moccasin', 'navajowhite', 'navajowhite1', 'navajowhite2', 'navajowhite3', 'navajowhite4', 'navy', 'navyblue', 'oldlace', 'olive', 'olivedrab', 'olivedrab1', 'olivedrab2', 'olivedrab3', 'olivedrab4', 'on_aliceblue', 'on_antiquewhite', 'on_antiquewhite1', 'on_antiquewhite2', 'on_antiquewhite3', 'on_antiquewhite4', 'on_aqua', 'on_aquamarine', 'on_aquamarine1', 'on_aquamarine2', 'on_aquamarine3', 'on_aquamarine4', 'on_azure', 'on_azure1', 'on_azure2', 'on_azure3', 'on_azure4', 'on_beige', 'on_bisque', 'on_bisque1', 'on_bisque2', 'on_bisque3', 'on_bisque4', 'on_black', 'on_blanchedalmond', 'on_blue', 'on_blue1', 'on_blue2', 'on_blue3', 'on_blue4', 'on_blueviolet', 'on_bright_black', 'on_bright_blue', 'on_bright_cyan', 'on_bright_green', 'on_bright_magenta', 'on_bright_red', 'on_bright_white', 'on_bright_yellow', 'on_brown', 'on_brown1', 'on_brown2', 'on_brown3', 'on_brown4', 'on_burlywood', 'on_burlywood1', 'on_burlywood2', 'on_burlywood3', 'on_burlywood4', 'on_cadetblue', 'on_cadetblue1', 'on_cadetblue2', 'on_cadetblue3', 'on_cadetblue4', 'on_chartreuse', 'on_chartreuse1', 'on_chartreuse2', 'on_chartreuse3', 'on_chartreuse4', 'on_chocolate', 'on_chocolate1', 'on_chocolate2', 'on_chocolate3', 'on_chocolate4', 'on_coral', 'on_coral1', 'on_coral2', 'on_coral3', 'on_coral4', 'on_cornflowerblue', 'on_cornsilk', 'on_cornsilk1', 'on_cornsilk2', 'on_cornsilk3', 'on_cornsilk4', 'on_crimson', 'on_cyan', 'on_cyan1', 'on_cyan2', 'on_cyan3', 'on_cyan4', 'on_darkblue', 'on_darkcyan', 'on_darkgoldenrod', 'on_darkgoldenrod1', 'on_darkgoldenrod2', 'on_darkgoldenrod3', 'on_darkgoldenrod4', 'on_darkgray', 'on_darkgreen', 'on_darkgrey', 'on_darkkhaki', 'on_darkmagenta', 'on_darkolivegreen', 'on_darkolivegreen1', 'on_darkolivegreen2', 'on_darkolivegreen3', 'on_darkolivegreen4', 'on_darkorange', 'on_darkorange1', 'on_darkorange2', 'on_darkorange3', 'on_darkorange4', 'on_darkorchid', 'on_darkorchid1', 'on_darkorchid2', 'on_darkorchid3', 'on_darkorchid4', 'on_darkred', 'on_darksalmon', 'on_darkseagreen', 'on_darkseagreen1', 'on_darkseagreen2', 'on_darkseagreen3', 'on_darkseagreen4', 'on_darkslateblue', 'on_darkslategray', 'on_darkslategray1', 'on_darkslategray2', 'on_darkslategray3', 'on_darkslategray4', 'on_darkslategrey', 'on_darkturquoise', 'on_darkviolet', 'on_deeppink', 'on_deeppink1', 'on_deeppink2', 'on_deeppink3', 'on_deeppink4', 'on_deepskyblue', 'on_deepskyblue1', 'on_deepskyblue2', 'on_deepskyblue3', 'on_deepskyblue4', 'on_dimgray', 'on_dimgrey', 'on_dodgerblue', 'on_dodgerblue1', 'on_dodgerblue2', 'on_dodgerblue3', 'on_dodgerblue4', 'on_firebrick', 'on_firebrick1', 'on_firebrick2', 'on_firebrick3', 'on_firebrick4', 'on_floralwhite', 'on_forestgreen', 'on_fuchsia', 'on_gainsboro', 'on_ghostwhite', 'on_gold', 'on_gold1', 'on_gold2', 'on_gold3', 'on_gold4', 'on_goldenrod', 'on_goldenrod1', 'on_goldenrod2', 'on_goldenrod3', 'on_goldenrod4', 'on_gray', 'on_gray0', 'on_gray1', 'on_gray10', 'on_gray100', 'on_gray11', 'on_gray12', 'on_gray13', 'on_gray14', 'on_gray15', 'on_gray16', 'on_gray17', 'on_gray18', 'on_gray19', 'on_gray2', 'on_gray20', 'on_gray21', 'on_gray22', 'on_gray23', 'on_gray24', 'on_gray25', 'on_gray26', 'on_gray27', 'on_gray28', 'on_gray29', 'on_gray3', 'on_gray30', 'on_gray31', 'on_gray32', 'on_gray33', 'on_gray34', 'on_gray35', 'on_gray36', 'on_gray37', 'on_gray38', 'on_gray39', 'on_gray4', 'on_gray40', 'on_gray41', 'on_gray42', 'on_gray43', 'on_gray44', 'on_gray45', 'on_gray46', 'on_gray47', 'on_gray48', 'on_gray49', 'on_gray5', 'on_gray50', 'on_gray51', 'on_gray52', 'on_gray53', 'on_gray54', 'on_gray55', 'on_gray56', 'on_gray57', 'on_gray58', 'on_gray59', 'on_gray6', 'on_gray60', 'on_gray61', 'on_gray62', 'on_gray63', 'on_gray64', 'on_gray65', 'on_gray66', 'on_gray67', 'on_gray68', 'on_gray69', 'on_gray7', 'on_gray70', 'on_gray71', 'on_gray72', 'on_gray73', 'on_gray74', 'on_gray75', 'on_gray76', 'on_gray77', 'on_gray78', 'on_gray79', 'on_gray8', 'on_gray80', 'on_gray81', 'on_gray82', 'on_gray83', 'on_gray84', 'on_gray85', 'on_gray86', 'on_gray87', 'on_gray88', 'on_gray89', 'on_gray9', 'on_gray90', 'on_gray91', 'on_gray92', 'on_gray93', 'on_gray94', 'on_gray95', 'on_gray96', 'on_gray97', 'on_gray98', 'on_gray99', 'on_green', 'on_green1', 'on_green2', 'on_green3', 'on_green4', 'on_greenyellow', 'on_grey', 'on_grey0', 'on_grey1', 'on_grey10', 'on_grey100', 'on_grey11', 'on_grey12', 'on_grey13', 'on_grey14', 'on_grey15', 'on_grey16', 'on_grey17', 'on_grey18', 'on_grey19', 'on_grey2', 'on_grey20', 'on_grey21', 'on_grey22', 'on_grey23', 'on_grey24', 'on_grey25', 'on_grey26', 'on_grey27', 'on_grey28', 'on_grey29', 'on_grey3', 'on_grey30', 'on_grey31', 'on_grey32', 'on_grey33', 'on_grey34', 'on_grey35', 'on_grey36', 'on_grey37', 'on_grey38', 'on_grey39', 'on_grey4', 'on_grey40', 'on_grey41', 'on_grey42', 'on_grey43', 'on_grey44', 'on_grey45', 'on_grey46', 'on_grey47', 'on_grey48', 'on_grey49', 'on_grey5', 'on_grey50', 'on_grey51', 'on_grey52', 'on_grey53', 'on_grey54', 'on_grey55', 'on_grey56', 'on_grey57', 'on_grey58', 'on_grey59', 'on_grey6', 'on_grey60', 'on_grey61', 'on_grey62', 'on_grey63', 'on_grey64', 'on_grey65', 'on_grey66', 'on_grey67', 'on_grey68', 'on_grey69', 'on_grey7', 'on_grey70', 'on_grey71', 'on_grey72', 'on_grey73', 'on_grey74', 'on_grey75', 'on_grey76', 'on_grey77', 'on_grey78', 'on_grey79', 'on_grey8', 'on_grey80', 'on_grey81', 'on_grey82', 'on_grey83', 'on_grey84', 'on_grey85', 'on_grey86', 'on_grey87', 'on_grey88', 'on_grey89', 'on_grey9', 'on_grey90', 'on_grey91', 'on_grey92', 'on_grey93', 'on_grey94', 'on_grey95', 'on_grey96', 'on_grey97', 'on_grey98', 'on_grey99', 'on_honeydew', 'on_honeydew1', 'on_honeydew2', 'on_honeydew3', 'on_honeydew4', 'on_hotpink', 'on_hotpink1', 'on_hotpink2', 'on_hotpink3', 'on_hotpink4', 'on_indianred', 'on_indianred1', 'on_indianred2', 'on_indianred3', 'on_indianred4', 'on_indigo', 'on_ivory', 'on_ivory1', 'on_ivory2', 'on_ivory3', 'on_ivory4', 'on_khaki', 'on_khaki1', 'on_khaki2', 'on_khaki3', 'on_khaki4', 'on_lavender', 'on_lavenderblush', 'on_lavenderblush1', 'on_lavenderblush2', 'on_lavenderblush3', 'on_lavenderblush4', 'on_lawngreen', 'on_lemonchiffon', 'on_lemonchiffon1', 'on_lemonchiffon2', 'on_lemonchiffon3', 'on_lemonchiffon4', 'on_lightblue', 'on_lightblue1', 'on_lightblue2', 'on_lightblue3', 'on_lightblue4', 'on_lightcoral', 'on_lightcyan', 'on_lightcyan1', 'on_lightcyan2', 'on_lightcyan3', 'on_lightcyan4', 'on_lightgoldenrod', 'on_lightgoldenrod1', 'on_lightgoldenrod2', 'on_lightgoldenrod3', 'on_lightgoldenrod4', 'on_lightgoldenrodyellow', 'on_lightgray', 'on_lightgreen', 'on_lightgrey', 'on_lightpink', 'on_lightpink1', 'on_lightpink2', 'on_lightpink3', 'on_lightpink4', 'on_lightsalmon', 'on_lightsalmon1', 'on_lightsalmon2', 'on_lightsalmon3', 'on_lightsalmon4', 'on_lightseagreen', 'on_lightskyblue', 'on_lightskyblue1', 'on_lightskyblue2', 'on_lightskyblue3', 'on_lightskyblue4', 'on_lightslateblue', 'on_lightslategray', 'on_lightslategrey', 'on_lightsteelblue', 'on_lightsteelblue1', 'on_lightsteelblue2', 'on_lightsteelblue3', 'on_lightsteelblue4', 'on_lightyellow', 'on_lightyellow1', 'on_lightyellow2', 'on_lightyellow3', 'on_lightyellow4', 'on_lime', 'on_limegreen', 'on_linen', 'on_magenta', 'on_magenta1', 'on_magenta2', 'on_magenta3', 'on_magenta4', 'on_maroon', 'on_maroon1', 'on_maroon2', 'on_maroon3', 'on_maroon4', 'on_mediumaquamarine', 'on_mediumblue', 'on_mediumorchid', 'on_mediumorchid1', 'on_mediumorchid2', 'on_mediumorchid3', 'on_mediumorchid4', 'on_mediumpurple', 'on_mediumpurple1', 'on_mediumpurple2', 'on_mediumpurple3', 'on_mediumpurple4', 'on_mediumseagreen', 'on_mediumslateblue', 'on_mediumspringgreen', 'on_mediumturquoise', 'on_mediumvioletred', 'on_midnightblue', 'on_mintcream', 'on_mistyrose', 'on_mistyrose1', 'on_mistyrose2', 'on_mistyrose3', 'on_mistyrose4', 'on_moccasin', 'on_navajowhite', 'on_navajowhite1', 'on_navajowhite2', 'on_navajowhite3', 'on_navajowhite4', 'on_navy', 'on_navyblue', 'on_oldlace', 'on_olive', 'on_olivedrab', 'on_olivedrab1', 'on_olivedrab2', 'on_olivedrab3', 'on_olivedrab4', 'on_orange', 'on_orange1', 'on_orange2', 'on_orange3', 'on_orange4', 'on_orangered', 'on_orangered1', 'on_orangered2', 'on_orangered3', 'on_orangered4', 'on_orchid', 'on_orchid1', 'on_orchid2', 'on_orchid3', 'on_orchid4', 'on_palegoldenrod', 'on_palegreen', 'on_palegreen1', 'on_palegreen2', 'on_palegreen3', 'on_palegreen4', 'on_paleturquoise', 'on_paleturquoise1', 'on_paleturquoise2', 'on_paleturquoise3', 'on_paleturquoise4', 'on_palevioletred', 'on_palevioletred1', 'on_palevioletred2', 'on_palevioletred3', 'on_palevioletred4', 'on_papayawhip', 'on_peachpuff', 'on_peachpuff1', 'on_peachpuff2', 'on_peachpuff3', 'on_peachpuff4', 'on_peru', 'on_pink', 'on_pink1', 'on_pink2', 'on_pink3', 'on_pink4', 'on_plum', 'on_plum1', 'on_plum2', 'on_plum3', 'on_plum4', 'on_powderblue', 'on_purple', 'on_purple1', 'on_purple2', 'on_purple3', 'on_purple4', 'on_rebeccapurple', 'on_red', 'on_red1', 'on_red2', 'on_red3', 'on_red4', 'on_rosybrown', 'on_rosybrown1', 'on_rosybrown2', 'on_rosybrown3', 'on_rosybrown4', 'on_royalblue', 'on_royalblue1', 'on_royalblue2', 'on_royalblue3', 'on_royalblue4', 'on_saddlebrown', 'on_salmon', 'on_salmon1', 'on_salmon2', 'on_salmon3', 'on_salmon4', 'on_sandybrown', 'on_seagreen', 'on_seagreen1', 'on_seagreen2', 'on_seagreen3', 'on_seagreen4', 'on_seashell', 'on_seashell1', 'on_seashell2', 'on_seashell3', 'on_seashell4', 'on_sienna', 'on_sienna1', 'on_sienna2', 'on_sienna3', 'on_sienna4', 'on_silver', 'on_skyblue', 'on_skyblue1', 'on_skyblue2', 'on_skyblue3', 'on_skyblue4', 'on_slateblue', 'on_slateblue1', 'on_slateblue2', 'on_slateblue3', 'on_slateblue4', 'on_slategray', 'on_slategray1', 'on_slategray2', 'on_slategray3', 'on_slategray4', 'on_slategrey', 'on_snow', 'on_snow1', 'on_snow2', 'on_snow3', 'on_snow4', 'on_springgreen', 'on_springgreen1', 'on_springgreen2', 'on_springgreen3', 'on_springgreen4', 'on_steelblue', 'on_steelblue1', 'on_steelblue2', 'on_steelblue3', 'on_steelblue4', 'on_tan', 'on_tan1', 'on_tan2', 'on_tan3', 'on_tan4', 'on_teal', 'on_thistle', 'on_thistle1', 'on_thistle2', 'on_thistle3', 'on_thistle4', 'on_tomato', 'on_tomato1', 'on_tomato2', 'on_tomato3', 'on_tomato4', 'on_turquoise', 'on_turquoise1', 'on_turquoise2', 'on_turquoise3', 'on_turquoise4', 'on_violet', 'on_violetred', 'on_violetred1', 'on_violetred2', 'on_violetred3', 'on_violetred4', 'on_webgray', 'on_webgreen', 'on_webgrey', 'on_webmaroon', 'on_webpurple', 'on_wheat', 'on_wheat1', 'on_wheat2', 'on_wheat3', 'on_wheat4', 'on_white', 'on_whitesmoke', 'on_x11gray', 'on_x11green', 'on_x11grey', 'on_x11maroon', 'on_x11purple', 'on_yellow', 'on_yellow1', 'on_yellow2', 'on_yellow3', 'on_yellow4', 'on_yellowgreen', 'orange', 'orange1', 'orange2', 'orange3', 'orange4', 'orangered', 'orangered1', 'orangered2', 'orangered3', 'orangered4', 'orchid', 'orchid1', 'orchid2', 'orchid3', 'orchid4', 'palegoldenrod', 'palegreen', 'palegreen1', 'palegreen2', 'palegreen3', 'palegreen4', 'paleturquoise', 'paleturquoise1', 'paleturquoise2', 'paleturquoise3', 'paleturquoise4', 'palevioletred', 'palevioletred1', 'palevioletred2', 'palevioletred3', 'palevioletred4', 'papayawhip', 'peachpuff', 'peachpuff1', 'peachpuff2', 'peachpuff3', 'peachpuff4', 'peru', 'pink', 'pink1', 'pink2', 'pink3', 'pink4', 'plum', 'plum1', 'plum2', 'plum3', 'plum4', 'powderblue', 'purple', 'purple1', 'purple2', 'purple3', 'purple4', 'rebeccapurple', 'red', 'red1', 'red2', 'red3', 'red4', 'rosybrown', 'rosybrown1', 'rosybrown2', 'rosybrown3', 'rosybrown4', 'royalblue', 'royalblue1', 'royalblue2', 'royalblue3', 'royalblue4', 'saddlebrown', 'salmon', 'salmon1', 'salmon2', 'salmon3', 'salmon4', 'sandybrown', 'seagreen', 'seagreen1', 'seagreen2', 'seagreen3', 'seagreen4', 'seashell', 'seashell1', 'seashell2', 'seashell3', 'seashell4', 'sienna', 'sienna1', 'sienna2', 'sienna3', 'sienna4', 'silver', 'skyblue', 'skyblue1', 'skyblue2', 'skyblue3', 'skyblue4', 'slateblue', 'slateblue1', 'slateblue2', 'slateblue3', 'slateblue4', 'slategray', 'slategray1', 'slategray2', 'slategray3', 'slategray4', 'slategrey', 'snow', 'snow1', 'snow2', 'snow3', 'snow4', 'springgreen', 'springgreen1', 'springgreen2', 'springgreen3', 'springgreen4', 'steelblue', 'steelblue1', 'steelblue2', 'steelblue3', 'steelblue4', 'tan', 'tan1', 'tan2', 'tan3', 'tan4', 'teal', 'thistle', 'thistle1', 'thistle2', 'thistle3', 'thistle4', 'tomato', 'tomato1', 'tomato2', 'tomato3', 'tomato4', 'turquoise', 'turquoise1', 'turquoise2', 'turquoise3', 'turquoise4', 'violet', 'violetred', 'violetred1', 'violetred2', 'violetred3', 'violetred4', 'webgray', 'webgreen', 'webgrey', 'webmaroon', 'webpurple', 'wheat', 'wheat1', 'wheat2', 'wheat3', 'wheat4', 'white', 'whitesmoke', 'x11gray', 'x11green', 'x11grey', 'x11maroon', 'x11purple', 'yellow', 'yellow1', 'yellow2', 'yellow3', 'yellow4', 'yellowgreen'}

Valid colors and their background (on), bright, and bright-background derivatives.

COMPOUNDABLES = {'blink', 'bold', 'italic', 'reverse', 'standout', 'underline'}

Attributes that may be compounded with colors, by underscore, such as ‘reverse_indigo’.

class ParameterizingString[source]

A Unicode string which can be called as a parameterizing termcap.

For example:

>>> term = Terminal()
>>> color = ParameterizingString(term.color, term.normal, 'color')
>>> color(9)('color #9')
u'\x1b[91mcolor #9\x1b(B\x1b[m'

Class constructor accepting 3 positional arguments.

Parameters
  • cap – parameterized string suitable for curses.tparm()

  • normal – terminating sequence for this capability (optional).

  • name – name of this terminal capability (optional).

__call__(*args)[source]

Returning FormattingString instance for given parameters.

Return evaluated terminal capability (self), receiving arguments *args, followed by the terminating sequence (self.normal) into a FormattingString capable of being called.

Return type

FormattingString or NullCallableString

class ParameterizingProxyString[source]

A Unicode string which can be called to proxy missing termcap entries.

This class supports the function get_proxy_string(), and mirrors the behavior of ParameterizingString, except that instead of a capability name, receives a format string, and callable to filter the given positional *args of ParameterizingProxyString.__call__() into a terminal sequence.

For example:

>>> from blessed import Terminal
>>> term = Terminal('screen')
>>> hpa = ParameterizingString(term.hpa, term.normal, 'hpa')
>>> hpa(9)
u''
>>> fmt = u'\x1b[{0}G'
>>> fmt_arg = lambda *arg: (arg[0] + 1,)
>>> hpa = ParameterizingProxyString((fmt, fmt_arg), term.normal, 'hpa')
>>> hpa(9)
u'\x1b[10G'

Class constructor accepting 4 positional arguments.

Parameters
  • fmt – format string suitable for displaying terminal sequences.

  • callable – receives __call__ arguments for formatting fmt.

  • normal – terminating sequence for this capability (optional).

  • name – name of this terminal capability (optional).

__call__(*args)[source]

Returning FormattingString instance for given parameters.

Arguments are determined by the capability. For example, hpa (move_x) receives only a single integer, whereas cup (move) receives two integers. See documentation in terminfo(5) for the given capability.

Return type

FormattingString

class FormattingString[source]

A Unicode string which doubles as a callable.

This is used for terminal attributes, so that it may be used both directly, or as a callable. When used directly, it simply emits the given terminal sequence. When used as a callable, it wraps the given (string) argument with the 2nd argument used by the class constructor:

>>> style = FormattingString(term.bright_blue, term.normal)
>>> print(repr(style))
u'\x1b[94m'
>>> style('Big Blue')
u'\x1b[94mBig Blue\x1b(B\x1b[m'

Class constructor accepting 2 positional arguments.

Parameters
  • sequence – terminal attribute sequence.

  • normal – terminating sequence for this attribute (optional).

__call__(*args)[source]

Return text joined by sequence and normal.

class FormattingOtherString[source]

A Unicode string which doubles as a callable for another sequence when called.

This is used for the move_up(), down, left, and right() family of functions:

>>> move_right = FormattingOtherString(term.cuf1, term.cuf)
>>> print(repr(move_right))
u'\x1b[C'
>>> print(repr(move_right(666)))
u'\x1b[666C'
>>> print(repr(move_right()))
u'\x1b[C'

Class constructor accepting 2 positional arguments.

Parameters
  • direct (str) – capability name for direct formatting, eg ('x' + term.right).

  • callable (str) – capability name for callable, eg ('x' + term.right(99)).

__call__(*args)[source]

Return text by callable.

class NullCallableString[source]

A dummy callable Unicode alternative to FormattingString.

This is used for colors on terminals that do not support colors, it is just a basic form of unicode that may also act as a callable.

Class constructor.

__call__(*args)[source]

Allow empty string to be callable, returning given string, if any.

When called with an int as the first arg, return an empty Unicode. An int is a good hint that I am a ParameterizingString, as there are only about half a dozen string-returning capabilities listed in terminfo(5) which accept non-int arguments, they are seldom used.

When called with a non-int as the first arg (no no args at all), return the first arg, acting in place of FormattingString without any attributes.

get_proxy_string(term, attr)[source]

Proxy and return callable string for proxied attributes.

Parameters
  • term (Terminal) – Terminal instance.

  • attr (str) – terminal capability name that may be proxied.

Return type

None or ParameterizingProxyString.

Returns

ParameterizingProxyString for some attributes of some terminal types that support it, where the terminfo(5) database would otherwise come up empty, such as move_x attribute for term.kind of screen. Otherwise, None.

split_compound(compound)[source]

Split compound formating string into segments.

>>> split_compound('bold_underline_bright_blue_on_red')
['bold', 'underline', 'bright_blue', 'on_red']
Parameters

compound (str) – a string that may contain compounds, separated by underline (_).

Return type

list

resolve_capability(term, attr)[source]

Resolve a raw terminal capability using tigetstr().

Parameters
Returns

string of the given terminal capability named by attr, which may be empty (u’‘) if not found or not supported by the given kind.

Return type

str

resolve_color(term, color)[source]

Resolve a simple color name to a callable capability.

This function supports resolve_attribute().

Parameters
Returns

a string class instance which emits the terminal sequence for the given color, and may be used as a callable to wrap the given string with such sequence.

Returns

NullCallableString when number_of_colors is 0, otherwise FormattingString.

Return type

NullCallableString or FormattingString

resolve_attribute(term, attr)[source]

Resolve a terminal attribute name into a capability class.

Parameters
  • term (Terminal) – Terminal instance.

  • attr (str) – Sugary, ordinary, or compound formatted terminal capability, such as “red_on_white”, “normal”, “red”, or “bold_on_black”, respectively.

Returns

a string class instance which emits the terminal sequence for the given terminal capability, or may be used as a callable to wrap the given string with such sequence.

Returns

NullCallableString when number_of_colors is 0, otherwise FormattingString.

Return type

NullCallableString or FormattingString

COLORS = {'aliceblue', 'antiquewhite', 'antiquewhite1', 'antiquewhite2', 'antiquewhite3', 'antiquewhite4', 'aqua', 'aquamarine', 'aquamarine1', 'aquamarine2', 'aquamarine3', 'aquamarine4', 'azure', 'azure1', 'azure2', 'azure3', 'azure4', 'beige', 'bisque', 'bisque1', 'bisque2', 'bisque3', 'bisque4', 'black', 'blanchedalmond', 'blue', 'blue1', 'blue2', 'blue3', 'blue4', 'blueviolet', 'bright_black', 'bright_blue', 'bright_cyan', 'bright_green', 'bright_magenta', 'bright_red', 'bright_white', 'bright_yellow', 'brown', 'brown1', 'brown2', 'brown3', 'brown4', 'burlywood', 'burlywood1', 'burlywood2', 'burlywood3', 'burlywood4', 'cadetblue', 'cadetblue1', 'cadetblue2', 'cadetblue3', 'cadetblue4', 'chartreuse', 'chartreuse1', 'chartreuse2', 'chartreuse3', 'chartreuse4', 'chocolate', 'chocolate1', 'chocolate2', 'chocolate3', 'chocolate4', 'coral', 'coral1', 'coral2', 'coral3', 'coral4', 'cornflowerblue', 'cornsilk', 'cornsilk1', 'cornsilk2', 'cornsilk3', 'cornsilk4', 'crimson', 'cyan', 'cyan1', 'cyan2', 'cyan3', 'cyan4', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgoldenrod1', 'darkgoldenrod2', 'darkgoldenrod3', 'darkgoldenrod4', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkolivegreen1', 'darkolivegreen2', 'darkolivegreen3', 'darkolivegreen4', 'darkorange', 'darkorange1', 'darkorange2', 'darkorange3', 'darkorange4', 'darkorchid', 'darkorchid1', 'darkorchid2', 'darkorchid3', 'darkorchid4', 'darkred', 'darksalmon', 'darkseagreen', 'darkseagreen1', 'darkseagreen2', 'darkseagreen3', 'darkseagreen4', 'darkslateblue', 'darkslategray', 'darkslategray1', 'darkslategray2', 'darkslategray3', 'darkslategray4', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deeppink1', 'deeppink2', 'deeppink3', 'deeppink4', 'deepskyblue', 'deepskyblue1', 'deepskyblue2', 'deepskyblue3', 'deepskyblue4', 'dimgray', 'dimgrey', 'dodgerblue', 'dodgerblue1', 'dodgerblue2', 'dodgerblue3', 'dodgerblue4', 'firebrick', 'firebrick1', 'firebrick2', 'firebrick3', 'firebrick4', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'gold1', 'gold2', 'gold3', 'gold4', 'goldenrod', 'goldenrod1', 'goldenrod2', 'goldenrod3', 'goldenrod4', 'gray', 'gray0', 'gray1', 'gray10', 'gray100', 'gray11', 'gray12', 'gray13', 'gray14', 'gray15', 'gray16', 'gray17', 'gray18', 'gray19', 'gray2', 'gray20', 'gray21', 'gray22', 'gray23', 'gray24', 'gray25', 'gray26', 'gray27', 'gray28', 'gray29', 'gray3', 'gray30', 'gray31', 'gray32', 'gray33', 'gray34', 'gray35', 'gray36', 'gray37', 'gray38', 'gray39', 'gray4', 'gray40', 'gray41', 'gray42', 'gray43', 'gray44', 'gray45', 'gray46', 'gray47', 'gray48', 'gray49', 'gray5', 'gray50', 'gray51', 'gray52', 'gray53', 'gray54', 'gray55', 'gray56', 'gray57', 'gray58', 'gray59', 'gray6', 'gray60', 'gray61', 'gray62', 'gray63', 'gray64', 'gray65', 'gray66', 'gray67', 'gray68', 'gray69', 'gray7', 'gray70', 'gray71', 'gray72', 'gray73', 'gray74', 'gray75', 'gray76', 'gray77', 'gray78', 'gray79', 'gray8', 'gray80', 'gray81', 'gray82', 'gray83', 'gray84', 'gray85', 'gray86', 'gray87', 'gray88', 'gray89', 'gray9', 'gray90', 'gray91', 'gray92', 'gray93', 'gray94', 'gray95', 'gray96', 'gray97', 'gray98', 'gray99', 'green', 'green1', 'green2', 'green3', 'green4', 'greenyellow', 'grey', 'grey0', 'grey1', 'grey10', 'grey100', 'grey11', 'grey12', 'grey13', 'grey14', 'grey15', 'grey16', 'grey17', 'grey18', 'grey19', 'grey2', 'grey20', 'grey21', 'grey22', 'grey23', 'grey24', 'grey25', 'grey26', 'grey27', 'grey28', 'grey29', 'grey3', 'grey30', 'grey31', 'grey32', 'grey33', 'grey34', 'grey35', 'grey36', 'grey37', 'grey38', 'grey39', 'grey4', 'grey40', 'grey41', 'grey42', 'grey43', 'grey44', 'grey45', 'grey46', 'grey47', 'grey48', 'grey49', 'grey5', 'grey50', 'grey51', 'grey52', 'grey53', 'grey54', 'grey55', 'grey56', 'grey57', 'grey58', 'grey59', 'grey6', 'grey60', 'grey61', 'grey62', 'grey63', 'grey64', 'grey65', 'grey66', 'grey67', 'grey68', 'grey69', 'grey7', 'grey70', 'grey71', 'grey72', 'grey73', 'grey74', 'grey75', 'grey76', 'grey77', 'grey78', 'grey79', 'grey8', 'grey80', 'grey81', 'grey82', 'grey83', 'grey84', 'grey85', 'grey86', 'grey87', 'grey88', 'grey89', 'grey9', 'grey90', 'grey91', 'grey92', 'grey93', 'grey94', 'grey95', 'grey96', 'grey97', 'grey98', 'grey99', 'honeydew', 'honeydew1', 'honeydew2', 'honeydew3', 'honeydew4', 'hotpink', 'hotpink1', 'hotpink2', 'hotpink3', 'hotpink4', 'indianred', 'indianred1', 'indianred2', 'indianred3', 'indianred4', 'indigo', 'ivory', 'ivory1', 'ivory2', 'ivory3', 'ivory4', 'khaki', 'khaki1', 'khaki2', 'khaki3', 'khaki4', 'lavender', 'lavenderblush', 'lavenderblush1', 'lavenderblush2', 'lavenderblush3', 'lavenderblush4', 'lawngreen', 'lemonchiffon', 'lemonchiffon1', 'lemonchiffon2', 'lemonchiffon3', 'lemonchiffon4', 'lightblue', 'lightblue1', 'lightblue2', 'lightblue3', 'lightblue4', 'lightcoral', 'lightcyan', 'lightcyan1', 'lightcyan2', 'lightcyan3', 'lightcyan4', 'lightgoldenrod', 'lightgoldenrod1', 'lightgoldenrod2', 'lightgoldenrod3', 'lightgoldenrod4', 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', 'lightpink', 'lightpink1', 'lightpink2', 'lightpink3', 'lightpink4', 'lightsalmon', 'lightsalmon1', 'lightsalmon2', 'lightsalmon3', 'lightsalmon4', 'lightseagreen', 'lightskyblue', 'lightskyblue1', 'lightskyblue2', 'lightskyblue3', 'lightskyblue4', 'lightslateblue', 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightsteelblue1', 'lightsteelblue2', 'lightsteelblue3', 'lightsteelblue4', 'lightyellow', 'lightyellow1', 'lightyellow2', 'lightyellow3', 'lightyellow4', 'lime', 'limegreen', 'linen', 'magenta', 'magenta1', 'magenta2', 'magenta3', 'magenta4', 'maroon', 'maroon1', 'maroon2', 'maroon3', 'maroon4', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumorchid1', 'mediumorchid2', 'mediumorchid3', 'mediumorchid4', 'mediumpurple', 'mediumpurple1', 'mediumpurple2', 'mediumpurple3', 'mediumpurple4', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'mistyrose1', 'mistyrose2', 'mistyrose3', 'mistyrose4', 'moccasin', 'navajowhite', 'navajowhite1', 'navajowhite2', 'navajowhite3', 'navajowhite4', 'navy', 'navyblue', 'oldlace', 'olive', 'olivedrab', 'olivedrab1', 'olivedrab2', 'olivedrab3', 'olivedrab4', 'on_aliceblue', 'on_antiquewhite', 'on_antiquewhite1', 'on_antiquewhite2', 'on_antiquewhite3', 'on_antiquewhite4', 'on_aqua', 'on_aquamarine', 'on_aquamarine1', 'on_aquamarine2', 'on_aquamarine3', 'on_aquamarine4', 'on_azure', 'on_azure1', 'on_azure2', 'on_azure3', 'on_azure4', 'on_beige', 'on_bisque', 'on_bisque1', 'on_bisque2', 'on_bisque3', 'on_bisque4', 'on_black', 'on_blanchedalmond', 'on_blue', 'on_blue1', 'on_blue2', 'on_blue3', 'on_blue4', 'on_blueviolet', 'on_bright_black', 'on_bright_blue', 'on_bright_cyan', 'on_bright_green', 'on_bright_magenta', 'on_bright_red', 'on_bright_white', 'on_bright_yellow', 'on_brown', 'on_brown1', 'on_brown2', 'on_brown3', 'on_brown4', 'on_burlywood', 'on_burlywood1', 'on_burlywood2', 'on_burlywood3', 'on_burlywood4', 'on_cadetblue', 'on_cadetblue1', 'on_cadetblue2', 'on_cadetblue3', 'on_cadetblue4', 'on_chartreuse', 'on_chartreuse1', 'on_chartreuse2', 'on_chartreuse3', 'on_chartreuse4', 'on_chocolate', 'on_chocolate1', 'on_chocolate2', 'on_chocolate3', 'on_chocolate4', 'on_coral', 'on_coral1', 'on_coral2', 'on_coral3', 'on_coral4', 'on_cornflowerblue', 'on_cornsilk', 'on_cornsilk1', 'on_cornsilk2', 'on_cornsilk3', 'on_cornsilk4', 'on_crimson', 'on_cyan', 'on_cyan1', 'on_cyan2', 'on_cyan3', 'on_cyan4', 'on_darkblue', 'on_darkcyan', 'on_darkgoldenrod', 'on_darkgoldenrod1', 'on_darkgoldenrod2', 'on_darkgoldenrod3', 'on_darkgoldenrod4', 'on_darkgray', 'on_darkgreen', 'on_darkgrey', 'on_darkkhaki', 'on_darkmagenta', 'on_darkolivegreen', 'on_darkolivegreen1', 'on_darkolivegreen2', 'on_darkolivegreen3', 'on_darkolivegreen4', 'on_darkorange', 'on_darkorange1', 'on_darkorange2', 'on_darkorange3', 'on_darkorange4', 'on_darkorchid', 'on_darkorchid1', 'on_darkorchid2', 'on_darkorchid3', 'on_darkorchid4', 'on_darkred', 'on_darksalmon', 'on_darkseagreen', 'on_darkseagreen1', 'on_darkseagreen2', 'on_darkseagreen3', 'on_darkseagreen4', 'on_darkslateblue', 'on_darkslategray', 'on_darkslategray1', 'on_darkslategray2', 'on_darkslategray3', 'on_darkslategray4', 'on_darkslategrey', 'on_darkturquoise', 'on_darkviolet', 'on_deeppink', 'on_deeppink1', 'on_deeppink2', 'on_deeppink3', 'on_deeppink4', 'on_deepskyblue', 'on_deepskyblue1', 'on_deepskyblue2', 'on_deepskyblue3', 'on_deepskyblue4', 'on_dimgray', 'on_dimgrey', 'on_dodgerblue', 'on_dodgerblue1', 'on_dodgerblue2', 'on_dodgerblue3', 'on_dodgerblue4', 'on_firebrick', 'on_firebrick1', 'on_firebrick2', 'on_firebrick3', 'on_firebrick4', 'on_floralwhite', 'on_forestgreen', 'on_fuchsia', 'on_gainsboro', 'on_ghostwhite', 'on_gold', 'on_gold1', 'on_gold2', 'on_gold3', 'on_gold4', 'on_goldenrod', 'on_goldenrod1', 'on_goldenrod2', 'on_goldenrod3', 'on_goldenrod4', 'on_gray', 'on_gray0', 'on_gray1', 'on_gray10', 'on_gray100', 'on_gray11', 'on_gray12', 'on_gray13', 'on_gray14', 'on_gray15', 'on_gray16', 'on_gray17', 'on_gray18', 'on_gray19', 'on_gray2', 'on_gray20', 'on_gray21', 'on_gray22', 'on_gray23', 'on_gray24', 'on_gray25', 'on_gray26', 'on_gray27', 'on_gray28', 'on_gray29', 'on_gray3', 'on_gray30', 'on_gray31', 'on_gray32', 'on_gray33', 'on_gray34', 'on_gray35', 'on_gray36', 'on_gray37', 'on_gray38', 'on_gray39', 'on_gray4', 'on_gray40', 'on_gray41', 'on_gray42', 'on_gray43', 'on_gray44', 'on_gray45', 'on_gray46', 'on_gray47', 'on_gray48', 'on_gray49', 'on_gray5', 'on_gray50', 'on_gray51', 'on_gray52', 'on_gray53', 'on_gray54', 'on_gray55', 'on_gray56', 'on_gray57', 'on_gray58', 'on_gray59', 'on_gray6', 'on_gray60', 'on_gray61', 'on_gray62', 'on_gray63', 'on_gray64', 'on_gray65', 'on_gray66', 'on_gray67', 'on_gray68', 'on_gray69', 'on_gray7', 'on_gray70', 'on_gray71', 'on_gray72', 'on_gray73', 'on_gray74', 'on_gray75', 'on_gray76', 'on_gray77', 'on_gray78', 'on_gray79', 'on_gray8', 'on_gray80', 'on_gray81', 'on_gray82', 'on_gray83', 'on_gray84', 'on_gray85', 'on_gray86', 'on_gray87', 'on_gray88', 'on_gray89', 'on_gray9', 'on_gray90', 'on_gray91', 'on_gray92', 'on_gray93', 'on_gray94', 'on_gray95', 'on_gray96', 'on_gray97', 'on_gray98', 'on_gray99', 'on_green', 'on_green1', 'on_green2', 'on_green3', 'on_green4', 'on_greenyellow', 'on_grey', 'on_grey0', 'on_grey1', 'on_grey10', 'on_grey100', 'on_grey11', 'on_grey12', 'on_grey13', 'on_grey14', 'on_grey15', 'on_grey16', 'on_grey17', 'on_grey18', 'on_grey19', 'on_grey2', 'on_grey20', 'on_grey21', 'on_grey22', 'on_grey23', 'on_grey24', 'on_grey25', 'on_grey26', 'on_grey27', 'on_grey28', 'on_grey29', 'on_grey3', 'on_grey30', 'on_grey31', 'on_grey32', 'on_grey33', 'on_grey34', 'on_grey35', 'on_grey36', 'on_grey37', 'on_grey38', 'on_grey39', 'on_grey4', 'on_grey40', 'on_grey41', 'on_grey42', 'on_grey43', 'on_grey44', 'on_grey45', 'on_grey46', 'on_grey47', 'on_grey48', 'on_grey49', 'on_grey5', 'on_grey50', 'on_grey51', 'on_grey52', 'on_grey53', 'on_grey54', 'on_grey55', 'on_grey56', 'on_grey57', 'on_grey58', 'on_grey59', 'on_grey6', 'on_grey60', 'on_grey61', 'on_grey62', 'on_grey63', 'on_grey64', 'on_grey65', 'on_grey66', 'on_grey67', 'on_grey68', 'on_grey69', 'on_grey7', 'on_grey70', 'on_grey71', 'on_grey72', 'on_grey73', 'on_grey74', 'on_grey75', 'on_grey76', 'on_grey77', 'on_grey78', 'on_grey79', 'on_grey8', 'on_grey80', 'on_grey81', 'on_grey82', 'on_grey83', 'on_grey84', 'on_grey85', 'on_grey86', 'on_grey87', 'on_grey88', 'on_grey89', 'on_grey9', 'on_grey90', 'on_grey91', 'on_grey92', 'on_grey93', 'on_grey94', 'on_grey95', 'on_grey96', 'on_grey97', 'on_grey98', 'on_grey99', 'on_honeydew', 'on_honeydew1', 'on_honeydew2', 'on_honeydew3', 'on_honeydew4', 'on_hotpink', 'on_hotpink1', 'on_hotpink2', 'on_hotpink3', 'on_hotpink4', 'on_indianred', 'on_indianred1', 'on_indianred2', 'on_indianred3', 'on_indianred4', 'on_indigo', 'on_ivory', 'on_ivory1', 'on_ivory2', 'on_ivory3', 'on_ivory4', 'on_khaki', 'on_khaki1', 'on_khaki2', 'on_khaki3', 'on_khaki4', 'on_lavender', 'on_lavenderblush', 'on_lavenderblush1', 'on_lavenderblush2', 'on_lavenderblush3', 'on_lavenderblush4', 'on_lawngreen', 'on_lemonchiffon', 'on_lemonchiffon1', 'on_lemonchiffon2', 'on_lemonchiffon3', 'on_lemonchiffon4', 'on_lightblue', 'on_lightblue1', 'on_lightblue2', 'on_lightblue3', 'on_lightblue4', 'on_lightcoral', 'on_lightcyan', 'on_lightcyan1', 'on_lightcyan2', 'on_lightcyan3', 'on_lightcyan4', 'on_lightgoldenrod', 'on_lightgoldenrod1', 'on_lightgoldenrod2', 'on_lightgoldenrod3', 'on_lightgoldenrod4', 'on_lightgoldenrodyellow', 'on_lightgray', 'on_lightgreen', 'on_lightgrey', 'on_lightpink', 'on_lightpink1', 'on_lightpink2', 'on_lightpink3', 'on_lightpink4', 'on_lightsalmon', 'on_lightsalmon1', 'on_lightsalmon2', 'on_lightsalmon3', 'on_lightsalmon4', 'on_lightseagreen', 'on_lightskyblue', 'on_lightskyblue1', 'on_lightskyblue2', 'on_lightskyblue3', 'on_lightskyblue4', 'on_lightslateblue', 'on_lightslategray', 'on_lightslategrey', 'on_lightsteelblue', 'on_lightsteelblue1', 'on_lightsteelblue2', 'on_lightsteelblue3', 'on_lightsteelblue4', 'on_lightyellow', 'on_lightyellow1', 'on_lightyellow2', 'on_lightyellow3', 'on_lightyellow4', 'on_lime', 'on_limegreen', 'on_linen', 'on_magenta', 'on_magenta1', 'on_magenta2', 'on_magenta3', 'on_magenta4', 'on_maroon', 'on_maroon1', 'on_maroon2', 'on_maroon3', 'on_maroon4', 'on_mediumaquamarine', 'on_mediumblue', 'on_mediumorchid', 'on_mediumorchid1', 'on_mediumorchid2', 'on_mediumorchid3', 'on_mediumorchid4', 'on_mediumpurple', 'on_mediumpurple1', 'on_mediumpurple2', 'on_mediumpurple3', 'on_mediumpurple4', 'on_mediumseagreen', 'on_mediumslateblue', 'on_mediumspringgreen', 'on_mediumturquoise', 'on_mediumvioletred', 'on_midnightblue', 'on_mintcream', 'on_mistyrose', 'on_mistyrose1', 'on_mistyrose2', 'on_mistyrose3', 'on_mistyrose4', 'on_moccasin', 'on_navajowhite', 'on_navajowhite1', 'on_navajowhite2', 'on_navajowhite3', 'on_navajowhite4', 'on_navy', 'on_navyblue', 'on_oldlace', 'on_olive', 'on_olivedrab', 'on_olivedrab1', 'on_olivedrab2', 'on_olivedrab3', 'on_olivedrab4', 'on_orange', 'on_orange1', 'on_orange2', 'on_orange3', 'on_orange4', 'on_orangered', 'on_orangered1', 'on_orangered2', 'on_orangered3', 'on_orangered4', 'on_orchid', 'on_orchid1', 'on_orchid2', 'on_orchid3', 'on_orchid4', 'on_palegoldenrod', 'on_palegreen', 'on_palegreen1', 'on_palegreen2', 'on_palegreen3', 'on_palegreen4', 'on_paleturquoise', 'on_paleturquoise1', 'on_paleturquoise2', 'on_paleturquoise3', 'on_paleturquoise4', 'on_palevioletred', 'on_palevioletred1', 'on_palevioletred2', 'on_palevioletred3', 'on_palevioletred4', 'on_papayawhip', 'on_peachpuff', 'on_peachpuff1', 'on_peachpuff2', 'on_peachpuff3', 'on_peachpuff4', 'on_peru', 'on_pink', 'on_pink1', 'on_pink2', 'on_pink3', 'on_pink4', 'on_plum', 'on_plum1', 'on_plum2', 'on_plum3', 'on_plum4', 'on_powderblue', 'on_purple', 'on_purple1', 'on_purple2', 'on_purple3', 'on_purple4', 'on_rebeccapurple', 'on_red', 'on_red1', 'on_red2', 'on_red3', 'on_red4', 'on_rosybrown', 'on_rosybrown1', 'on_rosybrown2', 'on_rosybrown3', 'on_rosybrown4', 'on_royalblue', 'on_royalblue1', 'on_royalblue2', 'on_royalblue3', 'on_royalblue4', 'on_saddlebrown', 'on_salmon', 'on_salmon1', 'on_salmon2', 'on_salmon3', 'on_salmon4', 'on_sandybrown', 'on_seagreen', 'on_seagreen1', 'on_seagreen2', 'on_seagreen3', 'on_seagreen4', 'on_seashell', 'on_seashell1', 'on_seashell2', 'on_seashell3', 'on_seashell4', 'on_sienna', 'on_sienna1', 'on_sienna2', 'on_sienna3', 'on_sienna4', 'on_silver', 'on_skyblue', 'on_skyblue1', 'on_skyblue2', 'on_skyblue3', 'on_skyblue4', 'on_slateblue', 'on_slateblue1', 'on_slateblue2', 'on_slateblue3', 'on_slateblue4', 'on_slategray', 'on_slategray1', 'on_slategray2', 'on_slategray3', 'on_slategray4', 'on_slategrey', 'on_snow', 'on_snow1', 'on_snow2', 'on_snow3', 'on_snow4', 'on_springgreen', 'on_springgreen1', 'on_springgreen2', 'on_springgreen3', 'on_springgreen4', 'on_steelblue', 'on_steelblue1', 'on_steelblue2', 'on_steelblue3', 'on_steelblue4', 'on_tan', 'on_tan1', 'on_tan2', 'on_tan3', 'on_tan4', 'on_teal', 'on_thistle', 'on_thistle1', 'on_thistle2', 'on_thistle3', 'on_thistle4', 'on_tomato', 'on_tomato1', 'on_tomato2', 'on_tomato3', 'on_tomato4', 'on_turquoise', 'on_turquoise1', 'on_turquoise2', 'on_turquoise3', 'on_turquoise4', 'on_violet', 'on_violetred', 'on_violetred1', 'on_violetred2', 'on_violetred3', 'on_violetred4', 'on_webgray', 'on_webgreen', 'on_webgrey', 'on_webmaroon', 'on_webpurple', 'on_wheat', 'on_wheat1', 'on_wheat2', 'on_wheat3', 'on_wheat4', 'on_white', 'on_whitesmoke', 'on_x11gray', 'on_x11green', 'on_x11grey', 'on_x11maroon', 'on_x11purple', 'on_yellow', 'on_yellow1', 'on_yellow2', 'on_yellow3', 'on_yellow4', 'on_yellowgreen', 'orange', 'orange1', 'orange2', 'orange3', 'orange4', 'orangered', 'orangered1', 'orangered2', 'orangered3', 'orangered4', 'orchid', 'orchid1', 'orchid2', 'orchid3', 'orchid4', 'palegoldenrod', 'palegreen', 'palegreen1', 'palegreen2', 'palegreen3', 'palegreen4', 'paleturquoise', 'paleturquoise1', 'paleturquoise2', 'paleturquoise3', 'paleturquoise4', 'palevioletred', 'palevioletred1', 'palevioletred2', 'palevioletred3', 'palevioletred4', 'papayawhip', 'peachpuff', 'peachpuff1', 'peachpuff2', 'peachpuff3', 'peachpuff4', 'peru', 'pink', 'pink1', 'pink2', 'pink3', 'pink4', 'plum', 'plum1', 'plum2', 'plum3', 'plum4', 'powderblue', 'purple', 'purple1', 'purple2', 'purple3', 'purple4', 'rebeccapurple', 'red', 'red1', 'red2', 'red3', 'red4', 'rosybrown', 'rosybrown1', 'rosybrown2', 'rosybrown3', 'rosybrown4', 'royalblue', 'royalblue1', 'royalblue2', 'royalblue3', 'royalblue4', 'saddlebrown', 'salmon', 'salmon1', 'salmon2', 'salmon3', 'salmon4', 'sandybrown', 'seagreen', 'seagreen1', 'seagreen2', 'seagreen3', 'seagreen4', 'seashell', 'seashell1', 'seashell2', 'seashell3', 'seashell4', 'sienna', 'sienna1', 'sienna2', 'sienna3', 'sienna4', 'silver', 'skyblue', 'skyblue1', 'skyblue2', 'skyblue3', 'skyblue4', 'slateblue', 'slateblue1', 'slateblue2', 'slateblue3', 'slateblue4', 'slategray', 'slategray1', 'slategray2', 'slategray3', 'slategray4', 'slategrey', 'snow', 'snow1', 'snow2', 'snow3', 'snow4', 'springgreen', 'springgreen1', 'springgreen2', 'springgreen3', 'springgreen4', 'steelblue', 'steelblue1', 'steelblue2', 'steelblue3', 'steelblue4', 'tan', 'tan1', 'tan2', 'tan3', 'tan4', 'teal', 'thistle', 'thistle1', 'thistle2', 'thistle3', 'thistle4', 'tomato', 'tomato1', 'tomato2', 'tomato3', 'tomato4', 'turquoise', 'turquoise1', 'turquoise2', 'turquoise3', 'turquoise4', 'violet', 'violetred', 'violetred1', 'violetred2', 'violetred3', 'violetred4', 'webgray', 'webgreen', 'webgrey', 'webmaroon', 'webpurple', 'wheat', 'wheat1', 'wheat2', 'wheat3', 'wheat4', 'white', 'whitesmoke', 'x11gray', 'x11green', 'x11grey', 'x11maroon', 'x11purple', 'yellow', 'yellow1', 'yellow2', 'yellow3', 'yellow4', 'yellowgreen'}

Valid colors and their background (on), bright, and bright-background derivatives.

COMPOUNDABLES = {'blink', 'bold', 'italic', 'reverse', 'standout', 'underline'}

Attributes that may be compounded with colors, by underscore, such as ‘reverse_indigo’.

keyboard.py

Sub-module providing ‘keyboard awareness’.

class Keystroke[source]

A unicode-derived class for describing a single keystroke.

A class instance describes a single keystroke received on input, which may contain multiple characters as a multibyte sequence, which is indicated by properties is_sequence returning True.

When the string is a known sequence, code matches terminal class attributes for comparison, such as term.KEY_LEFT.

The string-name of the sequence, such as u'KEY_LEFT' is accessed by property name, and is used by the __repr__() method to display a human-readable form of the Keystroke this class instance represents. It may otherwise by joined, split, or evaluated just as as any other unicode string.

Class constructor.

static __new__(cls, ucs='', code=None, name=None)[source]

Class constructor.

property is_sequence

Whether the value represents a multibyte sequence (bool).

property name

String-name of key sequence, such as u'KEY_LEFT' (str).

property code

Integer keycode value of multibyte sequence (int).

get_keyboard_codes()[source]

Return mapping of keycode integer values paired by their curses key-name.

Return type

dict

Returns dictionary of (code, name) pairs for curses keyboard constant values and their mnemonic name. Such as key 260, with the value of its identity, u'KEY_LEFT'. These are derived from the attributes by the same of the curses module, with the following exceptions:

  • KEY_DELETE in place of KEY_DC

  • KEY_INSERT in place of KEY_IC

  • KEY_PGUP in place of KEY_PPAGE

  • KEY_PGDOWN in place of KEY_NPAGE

  • KEY_ESCAPE in place of KEY_EXIT

  • KEY_SUP in place of KEY_SR

  • KEY_SDOWN in place of KEY_SF

This function is the inverse of get_curses_keycodes(). With the given override “mixins” listed above, the keycode for the delete key will map to our imaginary KEY_DELETE mnemonic, effectively erasing the phrase KEY_DC from our code vocabulary for anyone that wishes to use the return value to determine the key-name by keycode.

get_keyboard_sequences(term)[source]

Return mapping of keyboard sequences paired by keycodes.

Parameters

term (blessed.Terminal) – Terminal instance.

Returns

mapping of keyboard unicode sequences paired by keycodes as integer. This is used as the argument mapper to the supporting function resolve_sequence().

Return type

OrderedDict

Initialize and return a keyboard map and sequence lookup table, (sequence, keycode) from Terminal instance term, where sequence is a multibyte input sequence of unicode characters, such as u'\x1b[D', and keycode is an integer value, matching curses constant such as term.KEY_LEFT.

The return value is an OrderedDict instance, with their keys sorted longest-first.

_alternative_left_right(term)[source]

Determine and return mapping of left and right arrow keys sequences.

Parameters

term (blessed.Terminal) – Terminal instance.

Return type

dict

This function supports get_terminal_sequences() to discover the preferred input sequence for the left and right application keys.

Return dict of sequences term._cuf1, and term._cub1, valued as KEY_RIGHT, KEY_LEFT (when appropriate). It is necessary to check the value of these sequences to ensure we do not use u' ' and u'\b' for KEY_RIGHT and KEY_LEFT, preferring their true application key sequence, instead.

DEFAULT_SEQUENCE_MIXIN = (('\n', 343), ('\r', 343), ('\x08', 263), ('\t', 512), ('\x1b', 361), ('\x7f', 263), ('\x1b[A', 259), ('\x1b[B', 258), ('\x1b[C', 261), ('\x1b[D', 260), ('\x1b[F', 360), ('\x1b[H', 262), ('\x1b[K', 360), ('\x1b[U', 338), ('\x1b[V', 339), ('\x1bOM', 343), ('\x1bOj', 513), ('\x1bOk', 514), ('\x1bOl', 515), ('\x1bOm', 516), ('\x1bOn', 517), ('\x1bOo', 518), ('\x1bOX', 519), ('\x1bOp', 520), ('\x1bOq', 521), ('\x1bOr', 522), ('\x1bOs', 523), ('\x1bOt', 524), ('\x1bOu', 525), ('\x1bOv', 526), ('\x1bOw', 527), ('\x1bOx', 528), ('\x1bOy', 529), ('\x1b[1~', 362), ('\x1b[2~', 331), ('\x1b[3~', 330), ('\x1b[4~', 385), ('\x1b[5~', 339), ('\x1b[6~', 338), ('\x1b[7~', 262), ('\x1b[8~', 360), ('\x1b[OA', 259), ('\x1b[OB', 258), ('\x1b[OC', 261), ('\x1b[OD', 260), ('\x1b[OF', 360), ('\x1b[OH', 262), ('\x1bOP', 265), ('\x1bOQ', 266), ('\x1bOR', 267), ('\x1bOS', 268))

In a perfect world, terminal emulators would always send exactly what the terminfo(5) capability database plans for them, accordingly by the value of the TERM name they declare.

But this isn’t a perfect world. Many vt220-derived terminals, such as those declaring ‘xterm’, will continue to send vt220 codes instead of their native-declared codes, for backwards-compatibility.

This goes for many: rxvt, putty, iTerm.

These “mixins” are used for all terminals, regardless of their type.

Furthermore, curses does not provide sequences sent by the keypad, at least, it does not provide a way to distinguish between keypad 0 and numeric 0.

CURSES_KEYCODE_OVERRIDE_MIXIN = (('KEY_DELETE', 330), ('KEY_INSERT', 331), ('KEY_PGUP', 339), ('KEY_PGDOWN', 338), ('KEY_ESCAPE', 361), ('KEY_SUP', 337), ('KEY_SDOWN', 336), ('KEY_UP_LEFT', 348), ('KEY_UP_RIGHT', 349), ('KEY_CENTER', 350), ('KEY_BEGIN', 354))

Override mixins for a few curses constants with easier mnemonics: there may only be a 1:1 mapping when only a keycode (int) is given, where these phrases are preferred.

_CURSES_KEYCODE_ADDINS = ('TAB', 'KP_MULTIPLY', 'KP_ADD', 'KP_SEPARATOR', 'KP_SUBTRACT', 'KP_DECIMAL', 'KP_DIVIDE', 'KP_EQUAL', 'KP_0', 'KP_1', 'KP_2', 'KP_3', 'KP_4', 'KP_5', 'KP_6', 'KP_7', 'KP_8', 'KP_9')

Though we may determine keynames and codes for keyboard input that generate multibyte sequences, it is also especially useful to aliases a few basic ASCII characters such as KEY_TAB instead of u'\t' for uniformity.

Furthermore, many key-names for application keys enabled only by context manager keypad() are surprisingly absent. We inject them here directly into the curses module.

sequences.py

Module providing ‘sequence awareness’.

class SequenceTextWrapper(width, term, **kwargs)[source]

Object for wrapping/filling text. The public interface consists of the wrap() and fill() methods; the other methods are just there for subclasses to override in order to tweak the default behaviour. If you want to completely replace the main wrapping algorithm, you’ll probably have to override _wrap_chunks().

Several instance attributes control various aspects of wrapping:
width (default: 70)

the maximum width of wrapped lines (unless break_long_words is false)

initial_indent (default: “”)

string that will be prepended to the first line of wrapped output. Counts towards the line’s width.

subsequent_indent (default: “”)

string that will be prepended to all lines save the first of wrapped output; also counts towards each line’s width.

expand_tabs (default: true)

Expand tabs in input text to spaces before further processing. Each tab will become 0 .. ‘tabsize’ spaces, depending on its position in its line. If false, each tab is treated as a single character.

tabsize (default: 8)

Expand tabs in input text to 0 .. ‘tabsize’ spaces, unless ‘expand_tabs’ is false.

replace_whitespace (default: true)

Replace all whitespace characters in the input text by spaces after tab expansion. Note that if expand_tabs is false and replace_whitespace is true, every tab will be converted to a single space!

fix_sentence_endings (default: false)

Ensure that sentence-ending punctuation is always followed by two spaces. Off by default because the algorithm is (unavoidably) imperfect.

break_long_words (default: true)

Break words longer than ‘width’. If false, those words will not be broken, and some lines might be longer than ‘width’.

break_on_hyphens (default: true)

Allow breaking hyphenated words. If true, wrapping will occur preferably on whitespaces and right after hyphens part of compound words.

drop_whitespace (default: true)

Drop leading and trailing whitespace from lines.

max_lines (default: None)

Truncate wrapped lines.

placeholder (default: ‘ […]’)

Append to the last line of truncated text.

Class initializer.

This class supports the wrap() method.

_wrap_chunks(chunks)[source]

Sequence-aware variant of textwrap.TextWrapper._wrap_chunks().

This simply ensures that word boundaries are not broken mid-sequence, as standard python textwrap would incorrectly determine the length of a string containing sequences, and may also break consider sequences part of a “word” that may be broken by hyphen (-), where this implementation corrects both.

_handle_long_word(reversed_chunks, cur_line, cur_len, width)[source]

Sequence-aware textwrap.TextWrapper._handle_long_word().

This simply ensures that word boundaries are not broken mid-sequence, as standard python textwrap would incorrectly determine the length of a string containing sequences, and may also break consider sequences part of a “word” that may be broken by hyphen (-), where this implementation corrects both.

class Sequence[source]

A “sequence-aware” version of the base str class.

This unicode-derived class understands the effect of escape sequences of printable length, allowing a properly implemented rjust(), ljust(), center(), and length().

Class constructor.

Parameters
  • sequence_text – A string that may contain sequences.

  • term (blessed.Terminal) – Terminal instance.

ljust(width, fillchar=' ')[source]

Return string containing sequences, left-adjusted.

Parameters
  • width (int) – Total width given to right-adjust text. If unspecified, the width of the attached terminal is used (default).

  • fillchar (str) – String for padding right-of text.

Returns

String of text, right-aligned by width.

Return type

str

rjust(width, fillchar=' ')[source]

Return string containing sequences, right-adjusted.

Parameters
  • width (int) – Total width given to right-adjust text. If unspecified, the width of the attached terminal is used (default).

  • fillchar (str) – String for padding left-of text.

Returns

String of text, right-aligned by width.

Return type

str

center(width, fillchar=' ')[source]

Return string containing sequences, centered.

Parameters
  • width (int) – Total width given to center text. If unspecified, the width of the attached terminal is used (default).

  • fillchar (str) – String for padding left and right-of text.

Returns

String of text, centered by width.

Return type

str

length()[source]

Return the printable length of string containing sequences.

Strings containing term.left or \b will cause “overstrike”, but a length less than 0 is not ever returned. So _\b+ is a length of 1 (displays as +), but \b alone is simply a length of 0.

Some characters may consume more than one cell, mainly those CJK Unified Ideographs (Chinese, Japanese, Korean) defined by Unicode as half or full-width characters.

For example:

>>> from blessed import Terminal
>>> from blessed.sequences import Sequence
>>> term = Terminal()
>>> msg = term.clear + term.red(u'コンニチハ'), term
>>> Sequence(msg).length()
10

Note

Although accounted for, strings containing sequences such as term.clear will not give accurate returns, it is not considered lengthy (a length of 0).

strip(chars=None)[source]

Return string of sequences, leading, and trailing whitespace removed.

Parameters

chars (str) – Remove characters in chars instead of whitespace.

Return type

str

lstrip(chars=None)[source]

Return string of all sequences and leading whitespace removed.

Parameters

chars (str) – Remove characters in chars instead of whitespace.

Return type

str

rstrip(chars=None)[source]

Return string of all sequences and trailing whitespace removed.

Parameters

chars (str) – Remove characters in chars instead of whitespace.

Return type

str

strip_seqs()[source]

Return text stripped of only its terminal sequences.

Return type

str

padd()[source]

Return non-destructive horizontal movement as destructive spacing.

Return type

str

iter_parse(term, text)[source]

Generator yields (text, capability) for characters of text.

value for capability may be None, where text is str of length 1. Otherwise, text is a full matching sequence of given capability.

measure_length(text, term)[source]

Deprecated since version 1.12.0..

Return type

int

terminal.py

Module containing Terminal, the primary API entry point.

class Terminal(kind=None, stream=None, force_styling=False)[source]

An abstraction for color, style, positioning, and input in the terminal.

This keeps the endless calls to tigetstr() and tparm() out of your code, acts intelligently when somebody pipes your output to a non-terminal, and abstracts over the complexity of unbuffered keyboard input. It uses the terminfo database to remain portable across terminal types.

Initialize the terminal.

Parameters
  • kind (str) –

    A terminal string as taken by curses.setupterm(). Defaults to the value of the TERM environment variable.

    Note

    Terminals withing a single process must share a common kind. See _CUR_TERM.

  • stream (file) –

    A file-like object representing the Terminal output. Defaults to the original value of sys.__stdout__, like curses.initscr() does.

    If stream is not a tty, empty Unicode strings are returned for all capability values, so things like piping your program output to a pipe or file does not emit terminal sequences.

  • force_styling (bool) –

    Whether to force the emission of capabilities even if sys.__stdout__ does not seem to be connected to a terminal. If you want to force styling to not happen, use force_styling=None.

    This comes in handy if users are trying to pipe your output through something like less -r or build systems which support decoding of terminal sequences.

__getattr__(attr)[source]

Return a terminal capability as Unicode string.

For example, term.bold is a unicode string that may be prepended to text to set the video attribute for bold, which should also be terminated with the pairing normal. This capability returns a callable, so you can use term.bold("hi") which results in the joining of (term.bold, "hi", term.normal).

Compound formatters may also be used. For example:

>>> term.bold_blink_red_on_green("merry x-mas!")

For a parameterized capability such as move (or cup), pass the parameters as positional arguments:

>>> term.move(line, column)

See the manual page terminfo(5) for a complete list of capabilities and their arguments.

property kind

Read-only property: Terminal kind determined on class initialization.

Return type

str

property does_styling

Read-only property: Whether this class instance may emit sequences.

Return type

bool

property is_a_tty

Read-only property: Whether stream is a terminal.

Return type

bool

property height

Read-only property: Height of the terminal (in number of lines).

Return type

int

property width

Read-only property: Width of the terminal (in number of columns).

Return type

int

location(x=None, y=None)[source]

Context manager for temporarily moving the cursor.

Move the cursor to a certain position on entry, let you print stuff there, then return the cursor to its original position:

term = Terminal()
with term.location(2, 5):
    for x in xrange(10):
        print('I can do it %i times!' % x)
print('We're back to the original location.')

Specify x to move to a certain column, y to move to a certain row, both, or neither. If you specify neither, only the saving and restoration of cursor position will happen. This can be useful if you simply want to restore your place after doing some manual cursor movement.

Note

The store- and restore-cursor capabilities used internally provide no stack. This means that location() calls cannot be nested: only one should be entered at a time.

get_location(timeout=None)[source]

Return tuple (row, column) of cursor position.

Parameters

timeout (float) – Return after time elapsed in seconds with value (-1, -1) indicating that the remote end did not respond.

Return type

tuple

Returns

cursor position as tuple in form of (row, column).

The location of the cursor is determined by emitting the u7 terminal capability, or VT100 Query Cursor Position when such capability is undefined, which elicits a response from a reply string described by capability u6, or again VT100’s definition of \x1b[%i%d;%dR when undefined.

The (row, col) return value matches the parameter order of the move capability, so that the following sequence should cause the cursor to not move at all:

>>> term = Terminal()
>>> term.move(*term.get_location()))

Warning

You might first test that a terminal is capable of informing you of its location, while using a timeout, before later calling. When a timeout is specified, always ensure the return value is conditionally checked for (-1, -1).

fullscreen()[source]

Context manager that switches to secondary screen, restoring on exit.

Under the hood, this switches between the primary screen buffer and the secondary one. The primary one is saved on entry and restored on exit. Likewise, the secondary contents are also stable and are faithfully restored on the next entry:

with term.fullscreen():
    main()

Note

There is only one primary and one secondary screen buffer. fullscreen() calls cannot be nested, only one should be entered at a time.

hidden_cursor()[source]

Context manager that hides the cursor, setting visibility on exit.

with term.hidden_cursor():

main()

Note

hidden_cursor() calls cannot be nested: only one should be entered at a time.

move_xy(x, y)[source]

A callable string that moves the cursor to the given (x, y) screen coordinates.

Parameters
  • x (int) – horizontal position.

  • y (int) – vertical position.

Return type

ParameterizingString

move_yx(y, x)[source]

A callable string that moves the cursor to the given (y, x) screen coordinates.

Parameters
  • x (int) – horizontal position.

  • y (int) – vertical position.

Return type

ParameterizingString

property move_left

Move cursor 1 cells to the left, or callable string for n>1 cells.

property move_right

Move cursor 1 or more cells to the right, or callable string for n>1 cells.

property move_up

Move cursor 1 or more cells upwards, or callable string for n>1 cells.

property move_down

Move cursor 1 or more cells downwards, or callable string for n>1 cells.

property color

A callable string that sets the foreground color.

Parameters

num (int) – The foreground color index.

Return type

ParameterizingString

The capability is unparameterized until called and passed a number, at which point it returns another string which represents a specific color change. This second string can further be called to color a piece of text and set everything back to normal afterward.

This should not be used directly, but rather a specific color by name or color_rgb() value.

color_rgb(red, green, blue)[source]
property on_color

A callable capability that sets the background color.

Parameters

num (int) – The background color index.

Return type

ParameterizingString

on_color_rgb(red, green, blue)[source]
rgb_downconvert(red, green, blue)[source]

Translate an RGB color to a color code of the terminal’s color depth.

Parameters
  • red (int) – RGB value of Red (0-255).

  • green (int) – RGB value of Green (0-255).

  • blue (int) – RGB value of Blue (0-255).

Return type

int

property normal

A capability that resets all video attributes.

Return type

str

normal is an alias for sgr0 or exit_attribute_mode. Any styling attributes previously applied, such as foreground or background colors, reverse video, or bold are reset to defaults.

property stream

Read-only property: stream the terminal outputs to.

This is a convenience attribute. It is used internally for implied writes performed by context managers hidden_cursor(), fullscreen(), location(), and keypad().

property number_of_colors

Number of colors supported by terminal.

Common return values are 0, 8, 16, 256, or 1 << 24.

This may be used to test whether the terminal supports colors, and at what depth, if that’s a concern.

property color_distance_algorithm

Color distance algorithm used by rgb_downconvert().

The slowest, but most accurate, ‘cie2000’, is default. Other available options are ‘rgb’, ‘rgb-weighted’, ‘cie76’, and ‘cie94’.

ljust(text, width=None, fillchar=' ')[source]

Left-align text, which may contain terminal sequences.

Parameters
  • text (str) – String to be aligned

  • width (int) – Total width to fill with aligned text. If unspecified, the whole width of the terminal is filled.

  • fillchar (str) – String for padding the right of text

Return type

str

rjust(text, width=None, fillchar=' ')[source]

Right-align text, which may contain terminal sequences.

Parameters
  • text (str) – String to be aligned

  • width (int) – Total width to fill with aligned text. If unspecified, the whole width of the terminal is used.

  • fillchar (str) – String for padding the left of text

Return type

str

center(text, width=None, fillchar=' ')[source]

Center text, which may contain terminal sequences.

Parameters
  • text (str) – String to be centered

  • width (int) – Total width in which to center text. If unspecified, the whole width of the terminal is used.

  • fillchar (str) – String for padding the left and right of text

Return type

str

length(text)[source]

Return printable length of a string containing sequences.

Parameters

text (str) – String to measure. May contain terminal sequences.

Return type

int

Returns

The number of terminal character cells the string will occupy when printed

Wide characters that consume 2 character cells are supported:

>>> term = Terminal()
>>> term.length(term.clear + term.red(u'コンニチハ'))
10

Note

Sequences such as ‘clear’, which is considered as a “movement sequence” because it would move the cursor to (y, x)(0, 0), are evaluated as a printable length of 0.

strip(text, chars=None)[source]

Return text without sequences and leading or trailing whitespace.

Return type

str

>>> term.strip(u' \x1b[0;3m xyz ')
u'xyz'
rstrip(text, chars=None)[source]

Return text without terminal sequences or trailing whitespace.

Return type

str

>>> term.rstrip(u' \x1b[0;3m xyz ')
u'  xyz'
lstrip(text, chars=None)[source]

Return text without terminal sequences or leading whitespace.

Return type

str

>>> term.lstrip(u' \x1b[0;3m xyz ')
u'xyz '
strip_seqs(text)[source]

Return text stripped of only its terminal sequences.

Return type

str

>>> term.strip_seqs(u'\x1b[0;3mxyz')
u'xyz'
>>> term.strip_seqs(term.cuf(5) + term.red(u'test'))
u'     test'

Note

Non-destructive sequences that adjust horizontal distance (such as \b or term.cuf(5)) are replaced by destructive space or erasing.

split_seqs(text, **kwds)[source]

Return text split by individual character elements and sequences.

Parameters

kwds – remaining keyword arguments for re.split().

Return type

list[str]

>>> term.split_seqs(term.underline(u'xyz'))
['\x1b[4m', 'x', 'y', 'z', '\x1b(B', '\x1b[m']
wrap(text, width=None, **kwargs)[source]

Text-wrap a string, returning a list of wrapped lines.

Parameters
  • text (str) – Unlike textwrap.wrap(), text may contain terminal sequences, such as colors, bold, or underline. By default, tabs in text are expanded by string.expandtabs().

  • width (int) – Unlike textwrap.wrap(), width will default to the width of the attached terminal.

Return type

list

See textwrap.TextWrapper for keyword arguments that can customize wrapping behaviour.

getch()[source]

Read, decode, and return the next byte from the keyboard stream.

Return type

unicode

Returns

a single unicode character, or u'' if a multi-byte sequence has not yet been fully received.

This method name and behavior mimics curses getch(void), and it supports inkey(), reading only one byte from the keyboard string at a time. This method should always return without blocking if called after kbhit() has returned True.

Implementors of alternate input stream methods should override this method.

ungetch(text)[source]

Buffer input data to be discovered by next call to inkey().

Parameters

ucs (str) – String to be buffered as keyboard input.

kbhit(timeout=None)[source]

Return whether a keypress has been detected on the keyboard.

This method is used by inkey() to determine if a byte may be read using getch() without blocking. The standard implementation simply uses the select.select() call on stdin.

Parameters

timeout (float) – When timeout is 0, this call is non-blocking, otherwise blocking indefinitely until keypress is detected when None (default). When timeout is a positive number, returns after timeout seconds have elapsed (float).

Return type

bool

Returns

True if a keypress is awaiting to be read on the keyboard attached to this terminal. When input is not a terminal, False is always returned.

cbreak()[source]

Allow each keystroke to be read immediately after it is pressed.

This is a context manager for tty.setcbreak().

This context manager activates ‘rare’ mode, the opposite of ‘cooked’ mode: On entry, tty.setcbreak() mode is activated disabling line-buffering of keyboard input and turning off automatic echo of input as output.

Note

You must explicitly print any user input you would like displayed. If you provide any kind of editing, you must handle backspace and other line-editing control functions in this mode as well!

Normally, characters received from the keyboard cannot be read by Python until the Return key is pressed. Also known as cooked or canonical input mode, it allows the tty driver to provide line-editing before shuttling the input to your program and is the (implicit) default terminal mode set by most unix shells before executing programs.

Technically, this context manager sets the termios attributes of the terminal attached to sys.__stdin__.

raw()[source]

A context manager for tty.setraw().

Although both break() and raw() modes allow each keystroke to be read immediately after it is pressed, Raw mode disables processing of input and output.

In cbreak mode, special input characters such as ^C or ^S are interpreted by the terminal driver and excluded from the stdin stream. In raw mode these values are receive by the inkey() method.

Because output processing is not done, the newline '\n' is not enough, you must also print carriage return to ensure that the cursor is returned to the first column:

with term.raw():
    print("printing in raw mode", end="\r\n")
keypad()[source]

Context manager that enables directional keypad input.

On entrying, this puts the terminal into “keyboard_transmit” mode by emitting the keypad_xmit (smkx) capability. On exit, it emits keypad_local (rmkx).

On an IBM-PC keyboard with numeric keypad of terminal-type xterm, with numlock off, the lower-left diagonal key transmits sequence \\x1b[F, translated to Terminal attribute KEY_END.

However, upon entering keypad(), \\x1b[OF is transmitted, translating to KEY_LL (lower-left key), allowing you to determine diagonal direction keys.

inkey(timeout=None, esc_delay=0.35)[source]

Read and return the next keyboard event within given timeout.

Generally, this should be used inside the raw() context manager.

Parameters
  • timeout (float) – Number of seconds to wait for a keystroke before returning. When None (default), this method may block indefinitely.

  • esc_delay (float) – To distinguish between the keystroke of KEY_ESCAPE, and sequences beginning with escape, the parameter esc_delay specifies the amount of time after receiving escape (chr(27)) to seek for the completion of an application key before returning a Keystroke instance for KEY_ESCAPE.

Return type

Keystroke.

Returns

Keystroke, which may be empty (u'') if timeout is specified and keystroke is not received.

Note

When used without the context manager cbreak(), or raw(), sys.__stdin__ remains line-buffered, and this function will block until the return key is pressed!

class WINSZ[source]

Structure represents return value of termios.TIOCGWINSZ.

ws_row

rows, in characters

ws_col

columns, in characters

ws_xpixel

horizontal size, pixels

ws_ypixel

vertical size, pixels

Create new instance of WINSZ(ws_row, ws_col, ws_xpixel, ws_ypixel)

_CUR_TERM = None