Welcome to Blessed documentation!

Downloads codecov.io Code Coverage Windows supported Linux supported MacOS supported BSD supported

Introduction

Blessed is an easy, practical library for making terminal apps, by providing an elegant, well-documented interface to Colors, Keyboard input, and screen position and Location capabilities.

from blessed import Terminal

term = Terminal()

print(term.home + term.clear + term.move_y(term.height // 2))
print(term.black_on_darkkhaki(term.center('press any key to continue.')))

with term.cbreak(), term.hidden_cursor():
    inp = term.inkey()

print(term.move_down(2) + 'You pressed ' + term.bold(repr(inp)))
Animation of running the code example

It’s meant to be fun and easy, to do basic terminal graphics and styling with Python using blessed. Terminal is the only class you need to import and the only object you should need for Terminal capabilities.

Whether you want to improve CLI apps with colors, or make fullscreen applications or games, blessed should help get you started quickly. Your users will love it because it works on Windows, Mac, and Linux, and you will love it because it has plenty of documentation and examples!

Full documentation at https://blessed.readthedocs.io/en/latest/

Examples

Animations of x11-colorpicker.py, bounce.py, worms.py, and plasma.py

x11-colorpicker.py, bounce.py, worms.py, and plasma.py, from our repository.

Exemplary 3rd-party examples which use blessed,

Screenshot of 'Voltron' (By the author of Voltron, from their README).

Voltron is an extensible debugger UI toolkit written in Python

Animation of 'cursewords' (By the author of cursewords, from their README).

cursewords is “graphical” command line program for solving crossword puzzles in the terminal.

Animation of 'githeat.interactive', using blessed repository at the time of capture.

GitHeat builds an interactive heatmap of git history.

Animations from 'Dashing' (By the author of Dashing, from their README)

Dashing is a library to quickly create terminal-based dashboards.

Animations from 'Enlighten' (By the author of Enlighten, from their README)

Enlighten is a console progress bar library that allows simultaneous output without redirection.

Demonstration of 'macht', a 2048 clone

macht is a clone of the (briefly popular) puzzle game, 2048.

Requirements

Blessed works with Windows, Mac, Linux, and BSD’s, on Python 2.7, 3.4, 3.5, 3.6, 3.7, and 3.8.

Brief Overview

Blessed is more than just a Python wrapper around curses:

  • Styles, Colors, and maybe a little positioning without necessarily clearing the whole screen first.
  • Works great with Python’s new f-strings or any other kind of string formatting.
  • Provides up-to-the-moment Location and terminal height and width, so you can respond to terminal size changes.
  • Avoids making a mess if the output gets piped to a non-terminal, you can output sequences to any file-like object such as StringIO, files, pipes or sockets.
  • Uses terminfo(5) so it works with any terminal type and capability: No more C-like calls to tigetstr and tparm.
  • Non-obtrusive calls to only the capabilities database ensures that you are free to mix and match with calls to any other curses application code or library you like.
  • Provides context managers Terminal.fullscreen() and Terminal.hidden_cursor() to safely express terminal modes, curses development will no longer fudge up your shell.
  • Act intelligently when somebody redirects your output to a file, omitting all of the special sequences colors, but still containing all of the text.

Blessed is a fork of blessings, which does all of the same above with the same API, as well as following enhancements:

Before And After

With the built-in curses module, this is how you would typically print some underlined text at the bottom of the screen:

from curses import tigetstr, setupterm, tparm
from fcntl import ioctl
from os import isatty
import struct
import sys
from termios import TIOCGWINSZ

# If we want to tolerate having our output piped to other commands or
# files without crashing, we need to do all this branching:
if hasattr(sys.stdout, 'fileno') and isatty(sys.stdout.fileno()):
    setupterm()
    sc = tigetstr('sc')
    cup = tigetstr('cup')
    rc = tigetstr('rc')
    underline = tigetstr('smul')
    normal = tigetstr('sgr0')
else:
    sc = cup = rc = underline = normal = ''

# Save cursor position.
print(sc)

if cup:
    # tigetnum('lines') doesn't always update promptly, hence this:
    height = struct.unpack('hhhh', ioctl(0, TIOCGWINSZ, '\000' * 8))[0]

    # Move cursor to bottom.
    print(tparm(cup, height - 1, 0))

print('This is {under}underlined{normal}!'
      .format(under=underline, normal=normal))

# Restore cursor position.
print(rc)

The same program with Blessed is simply:

from blessed import Terminal

term = Terminal()
with term.location(0, term.height - 1):
    print('This is ' + term.underline('underlined') + '!')

Terminal

A visual example of the below interaction with the Terminal class, in IPython.

Blessed provides just one top-level object: Terminal. Instantiating a Terminal figures out whether you’re on a terminal at all and, if so, does any necessary setup:

>>> import blessed
>>> term = blessed.Terminal()

This is the only object, named term here, that you should need from blessed, for all of the remaining examples in our documentation.

You can proceed to ask it all sorts of things about the terminal, such as its size:

>>> term.height, term.width
(34, 102)

Support for Colors:

>>> term.number_of_colors
256

And create printable strings containing sequences for Colors:

>>> term.green_reverse('ALL SYSTEMS GO')
'\x1b[32m\x1b[7mALL SYSTEMS GO\x1b[m'

When printed, these codes make your terminal go to work:

>>> print(term.white_on_firebrick3('SYSTEM OFFLINE'))

And thanks to f-strings since python 3.6, it’s very easy to mix attributes and strings together:

>>> print(f"{term.yellow}Yellow is brown, {term.bright_yellow}"
          f"Bright yellow is actually yellow!{term.normal}")

Capabilities

Any capability in the terminfo(5) manual, under column Cap-name can be an attribute of the Terminal class, such as ‘smul’ for ‘begin underline mode’.

There are a lot of interesting capabilities in the terminfo(5) manual page, but many of these will return an empty string, as they are not supported by your terminal. They can still be used, but have no effect. For example, blink only works on a few terminals, does yours?

>>> print(term.blink("Insert System disk into drive A:"))

Compound Formatting

If you want to do lots of crazy formatting all at once, you can just mash it all together:

>>> print(term.underline_bold_green_on_yellow('They live! In sewers!'))

This compound notation comes in handy for users & configuration to customize your app, too!

Clearing The Screen

Blessed provides syntactic sugar over some screen-clearing capabilities:

clear
Clear the whole screen.
clear_eol
Clear to the end of the line.
clear_bol
Clear backward to the beginning of the line.
clear_eos
Clear to the end of screen.

Suggest to always combine home and clear, and, in almost all emulators, clearing the screen after setting the background color will repaint the background of the screen:

>>> print(term.home + term.on_blue + term.clear)

Styles

In addition to Colors, blessed also supports the limited amount of styles that terminals can do. These are:

bold
Turn on ‘extra bright’ mode.
reverse
Switch fore and background attributes.
normal
Reset attributes to default.
underline
Enable underline mode.
no_underline
Disable underline mode.

Note

While the inverse of underline is no_underline, the only way to turn off bold or reverse is normal, which also cancels any custom colors.

Full-Screen Mode

If you’ve ever noticed how a program like vim(1) restores you to your unix shell history after exiting, it’s actually a pretty basic trick that all terminal emulators support, that blessed provides using the fullscreen() context manager over these two basic capabilities:

enter_fullscreen
Switch to alternate screen, previous screen is stored by terminal driver.
exit_fullscreen
Switch back to standard screen, restoring the same terminal screen.
with term.fullscreen(), term.cbreak():
    print(term.move_y(term.height // 2) +
          term.center('press any key').rstrip())
    term.inkey()

Pipe Savvy

If your program isn’t attached to a terminal, such as piped to a program like less(1) or redirected to a file, all the capability attributes on Terminal will return empty strings for any Colors, Location, or other sequences. You’ll get a nice-looking file without any formatting codes gumming up the works.

If you want to override this, such as when piping output to less -R, pass argument value True to the force_styling parameter.

In any case, there is a does_styling attribute that lets you see whether the terminal attached to the output stream is capable of formatting. If it is False, you may refrain from drawing progress bars and other frippery and just stick to content:

if term.does_styling:
    with term.location(x=0, y=term.height - 1):
        print('Progress: [=======>   ]')
print(term.bold("60%"))

Colors

Doing colors with blessed is easy, pick a color name from the All Terminal colors, by name below, any of these named are also attributes of the Terminal!

These attributes can be printed directly, causing the terminal to switch into the given color. Or, as a callable, which terminates the string with the normal attribute. The following three statements are equivalent:

>>> print(term.orangered + 'All systems are offline' + term.normal)
>>> print(f'{term.orangered}All systems are offline{term.normal}')
>>> print(term.orangered('All systems are offline'))

To use a background color, prefix any color with on_:

>>> print(term.on_darkolivegreen('welcome to the army'))

And combine two colors using “_on_”, as in “foreground_on_background”:

>>> print(term.peru_on_seagreen('All systems functioning within defined parameters.'))

24-bit Colors

Most Terminal emulators, even Windows, has supported 24-bit colors since roughly 2016. To test or force-set whether the terminal emulator supports 24-bit colors, check or set the terminal attribute number_of_colors():

>>> print(term.number_of_colors == 1 << 24)
True

Even if the terminal only supports 256, or worse, 16 colors, the nearest color supported by the terminal is automatically mapped:

>>> term.number_of_colors = 1 << 24
>>> term.darkolivegreen
'\x1b[38;2;85;107;47m'
>>> term.number_of_colors = 256
>>> term.darkolivegreen
'\x1b[38;5;58m'
>>> term.number_of_colors = 16
>>> term.darkolivegreen
'\x1b[90m'

And finally, the direct (r, g, b) values of 0-255 can be used for color_rgb() and on_color_rgb() for foreground and background colors, to access each and every color!

All Terminal colors, by name
Name Image R G B H S V
red red 100.0% 0.0% 0.0% 0.0% 100.0% 100.0%
red2 red2 93.3% 0.0% 0.0% 0.0% 100.0% 93.3%
red3 red3 80.4% 0.0% 0.0% 0.0% 100.0% 80.4%
snow snow 100.0% 98.0% 98.0% 0.0% 2.0% 100.0%
snow2 snow2 93.3% 91.4% 91.4% 0.0% 2.1% 93.3%
snow3 snow3 80.4% 78.8% 78.8% 0.0% 2.0% 80.4%
snow4 snow4 54.5% 53.7% 53.7% 0.0% 1.4% 54.5%
brown brown 64.7% 16.5% 16.5% 0.0% 74.5% 64.7%
brown1 brown1 100.0% 25.1% 25.1% 0.0% 74.9% 100.0%
brown2 brown2 93.3% 23.1% 23.1% 0.0% 75.2% 93.3%
brown3 brown3 80.4% 20.0% 20.0% 0.0% 75.1% 80.4%
brown4 brown4 54.5% 13.7% 13.7% 0.0% 74.8% 54.5%
darkred darkred 54.5% 0.0% 0.0% 0.0% 100.0% 54.5%
indianred indianred 80.4% 36.1% 36.1% 0.0% 55.1% 80.4%
indianred1 indianred1 100.0% 41.6% 41.6% 0.0% 58.4% 100.0%
indianred2 indianred2 93.3% 38.8% 38.8% 0.0% 58.4% 93.3%
indianred3 indianred3 80.4% 33.3% 33.3% 0.0% 58.5% 80.4%
indianred4 indianred4 54.5% 22.7% 22.7% 0.0% 58.3% 54.5%
firebrick firebrick 69.8% 13.3% 13.3% 0.0% 80.9% 69.8%
firebrick1 firebrick1 100.0% 18.8% 18.8% 0.0% 81.2% 100.0%
firebrick2 firebrick2 93.3% 17.3% 17.3% 0.0% 81.5% 93.3%
firebrick3 firebrick3 80.4% 14.9% 14.9% 0.0% 81.5% 80.4%
firebrick4 firebrick4 54.5% 10.2% 10.2% 0.0% 81.3% 54.5%
webmaroon webmaroon 50.2% 0.0% 0.0% 0.0% 100.0% 50.2%
rosybrown rosybrown 73.7% 56.1% 56.1% 0.0% 23.9% 73.7%
rosybrown1 rosybrown1 100.0% 75.7% 75.7% 0.0% 24.3% 100.0%
rosybrown2 rosybrown2 93.3% 70.6% 70.6% 0.0% 24.4% 93.3%
rosybrown3 rosybrown3 80.4% 60.8% 60.8% 0.0% 24.4% 80.4%
rosybrown4 rosybrown4 54.5% 41.2% 41.2% 0.0% 24.5% 54.5%
lightcoral lightcoral 94.1% 50.2% 50.2% 0.0% 46.7% 94.1%
salmon salmon 98.0% 50.2% 44.7% 1.7% 54.4% 98.0%
mistyrose mistyrose 100.0% 89.4% 88.2% 1.7% 11.8% 100.0%
mistyrose2 mistyrose2 93.3% 83.5% 82.4% 1.8% 11.8% 93.3%
mistyrose3 mistyrose3 80.4% 71.8% 71.0% 1.4% 11.7% 80.4%
coral1 coral1 100.0% 44.7% 33.7% 2.8% 66.3% 100.0%
coral2 coral2 93.3% 41.6% 31.4% 2.7% 66.4% 93.3%
coral3 coral3 80.4% 35.7% 27.1% 2.7% 66.3% 80.4%
coral4 coral4 54.5% 24.3% 18.4% 2.7% 66.2% 54.5%
tomato tomato 100.0% 38.8% 27.8% 2.5% 72.2% 100.0%
tomato2 tomato2 93.3% 36.1% 25.9% 2.5% 72.3% 93.3%
tomato3 tomato3 80.4% 31.0% 22.4% 2.5% 72.2% 80.4%
tomato4 tomato4 54.5% 21.2% 14.9% 2.6% 72.7% 54.5%
mistyrose4 mistyrose4 54.5% 49.0% 48.2% 2.1% 11.5% 54.5%
salmon1 salmon1 100.0% 54.9% 41.2% 3.9% 58.8% 100.0%
salmon2 salmon2 93.3% 51.0% 38.4% 3.8% 58.8% 93.3%
salmon3 salmon3 80.4% 43.9% 32.9% 3.9% 59.0% 80.4%
salmon4 salmon4 54.5% 29.8% 22.4% 3.9% 59.0% 54.5%
coral coral 100.0% 49.8% 31.4% 4.5% 68.6% 100.0%
orangered orangered 100.0% 27.1% 0.0% 4.5% 100.0% 100.0%
orangered2 orangered2 93.3% 25.1% 0.0% 4.5% 100.0% 93.3%
orangered3 orangered3 80.4% 21.6% 0.0% 4.5% 100.0% 80.4%
orangered4 orangered4 54.5% 14.5% 0.0% 4.4% 100.0% 54.5%
darksalmon darksalmon 91.4% 58.8% 47.8% 4.2% 47.6% 91.4%
lightsalmon lightsalmon 100.0% 62.7% 47.8% 4.8% 52.2% 100.0%
lightsalmon2 lightsalmon2 93.3% 58.4% 44.7% 4.7% 52.1% 93.3%
lightsalmon3 lightsalmon3 80.4% 50.6% 38.4% 4.8% 52.2% 80.4%
lightsalmon4 lightsalmon4 54.5% 34.1% 25.9% 4.8% 52.5% 54.5%
sienna sienna 62.7% 32.2% 17.6% 5.4% 71.9% 62.7%
sienna1 sienna1 100.0% 51.0% 27.8% 5.3% 72.2% 100.0%
sienna2 sienna2 93.3% 47.5% 25.9% 5.3% 72.3% 93.3%
sienna3 sienna3 80.4% 40.8% 22.4% 5.3% 72.2% 80.4%
sienna4 sienna4 54.5% 27.8% 14.9% 5.4% 72.7% 54.5%
seashell seashell 100.0% 96.1% 93.3% 6.9% 6.7% 100.0%
chocolate chocolate 82.4% 41.2% 11.8% 6.9% 85.7% 82.4%
chocolate1 chocolate1 100.0% 49.8% 14.1% 6.9% 85.9% 100.0%
chocolate2 chocolate2 93.3% 46.3% 12.9% 6.9% 86.1% 93.3%
chocolate3 chocolate3 80.4% 40.0% 11.4% 6.9% 85.9% 80.4%
chocolate4 chocolate4 54.5% 27.1% 7.5% 6.9% 86.3% 54.5%
seashell2 seashell2 93.3% 89.8% 87.1% 7.3% 6.7% 93.3%
seashell3 seashell3 80.4% 77.3% 74.9% 7.1% 6.8% 80.4%
seashell4 seashell4 54.5% 52.5% 51.0% 7.4% 6.5% 54.5%
peachpuff peachpuff 100.0% 85.5% 72.5% 7.9% 27.5% 100.0%
peachpuff2 peachpuff2 93.3% 79.6% 67.8% 7.7% 27.3% 93.3%
peachpuff3 peachpuff3 80.4% 68.6% 58.4% 7.7% 27.3% 80.4%
peachpuff4 peachpuff4 54.5% 46.7% 39.6% 7.9% 27.3% 54.5%
sandybrown sandybrown 95.7% 64.3% 37.6% 7.7% 60.7% 95.7%
tan1 tan1 100.0% 64.7% 31.0% 8.1% 69.0% 100.0%
tan2 tan2 93.3% 60.4% 28.6% 8.2% 69.3% 93.3%
tan4 tan4 54.5% 35.3% 16.9% 8.2% 69.1% 54.5%
peru peru 80.4% 52.2% 24.7% 8.2% 69.3% 80.4%
linen linen 98.0% 94.1% 90.2% 8.3% 8.0% 98.0%
bisque3 bisque3 80.4% 71.8% 62.0% 8.9% 22.9% 80.4%
darkorange1 darkorange1 100.0% 49.8% 0.0% 8.3% 100.0% 100.0%
darkorange2 darkorange2 93.3% 46.3% 0.0% 8.3% 100.0% 93.3%
darkorange3 darkorange3 80.4% 40.0% 0.0% 8.3% 100.0% 80.4%
darkorange4 darkorange4 54.5% 27.1% 0.0% 8.3% 100.0% 54.5%
tan tan 82.4% 70.6% 54.9% 9.5% 33.3% 82.4%
bisque bisque 100.0% 89.4% 76.9% 9.0% 23.1% 100.0%
bisque2 bisque2 93.3% 83.5% 71.8% 9.1% 23.1% 93.3%
bisque4 bisque4 54.5% 49.0% 42.0% 9.4% 23.0% 54.5%
burlywood burlywood 87.1% 72.2% 52.9% 9.4% 39.2% 87.1%
burlywood1 burlywood1 100.0% 82.7% 60.8% 9.3% 39.2% 100.0%
burlywood2 burlywood2 93.3% 77.3% 56.9% 9.3% 39.1% 93.3%
burlywood3 burlywood3 80.4% 66.7% 49.0% 9.4% 39.0% 80.4%
burlywood4 burlywood4 54.5% 45.1% 33.3% 9.3% 38.8% 54.5%
darkorange darkorange 100.0% 54.9% 0.0% 9.2% 100.0% 100.0%
navajowhite navajowhite 100.0% 87.1% 67.8% 10.0% 32.2% 100.0%
navajowhite2 navajowhite2 93.3% 81.2% 63.1% 10.0% 32.4% 93.3%
antiquewhite antiquewhite 98.0% 92.2% 84.3% 9.5% 14.0% 98.0%
antiquewhite1 antiquewhite1 100.0% 93.7% 85.9% 9.3% 14.1% 100.0%
antiquewhite2 antiquewhite2 93.3% 87.5% 80.0% 9.3% 14.3% 93.3%
antiquewhite3 antiquewhite3 80.4% 75.3% 69.0% 9.2% 14.1% 80.4%
antiquewhite4 antiquewhite4 54.5% 51.4% 47.1% 9.6% 13.7% 54.5%
wheat wheat 96.1% 87.1% 70.2% 10.9% 26.9% 96.1%
wheat1 wheat1 100.0% 90.6% 72.9% 10.9% 27.1% 100.0%
wheat2 wheat2 93.3% 84.7% 68.2% 10.9% 26.9% 93.3%
wheat3 wheat3 80.4% 72.9% 58.8% 10.9% 26.8% 80.4%
wheat4 wheat4 54.5% 49.4% 40.0% 10.8% 26.6% 54.5%
orange orange 100.0% 64.7% 0.0% 10.8% 100.0% 100.0%
orange2 orange2 93.3% 60.4% 0.0% 10.8% 100.0% 93.3%
orange3 orange3 80.4% 52.2% 0.0% 10.8% 100.0% 80.4%
orange4 orange4 54.5% 35.3% 0.0% 10.8% 100.0% 54.5%
oldlace oldlace 99.2% 96.1% 90.2% 10.9% 9.1% 99.2%
moccasin moccasin 100.0% 89.4% 71.0% 10.6% 29.0% 100.0%
papayawhip papayawhip 100.0% 93.7% 83.5% 10.3% 16.5% 100.0%
navajowhite3 navajowhite3 80.4% 70.2% 54.5% 10.1% 32.2% 80.4%
navajowhite4 navajowhite4 54.5% 47.5% 36.9% 10.0% 32.4% 54.5%
blanchedalmond blanchedalmond 100.0% 92.2% 80.4% 10.0% 19.6% 100.0%
goldenrod goldenrod 85.5% 64.7% 12.5% 11.9% 85.3% 85.5%
goldenrod1 goldenrod1 100.0% 75.7% 14.5% 11.9% 85.5% 100.0%
goldenrod2 goldenrod2 93.3% 70.6% 13.3% 11.9% 85.7% 93.3%
goldenrod3 goldenrod3 80.4% 60.8% 11.4% 11.9% 85.9% 80.4%
goldenrod4 goldenrod4 54.5% 41.2% 7.8% 11.9% 85.6% 54.5%
floralwhite floralwhite 100.0% 98.0% 94.1% 11.1% 5.9% 100.0%
darkgoldenrod darkgoldenrod 72.2% 52.5% 4.3% 11.8% 94.0% 72.2%
darkgoldenrod1 darkgoldenrod1 100.0% 72.5% 5.9% 11.8% 94.1% 100.0%
darkgoldenrod2 darkgoldenrod2 93.3% 67.8% 5.5% 11.8% 94.1% 93.3%
darkgoldenrod3 darkgoldenrod3 80.4% 58.4% 4.7% 11.8% 94.1% 80.4%
darkgoldenrod4 darkgoldenrod4 54.5% 39.6% 3.1% 11.8% 94.2% 54.5%
cornsilk cornsilk 100.0% 97.3% 86.3% 13.3% 13.7% 100.0%
cornsilk2 cornsilk2 93.3% 91.0% 80.4% 13.6% 13.9% 93.3%
cornsilk3 cornsilk3 80.4% 78.4% 69.4% 13.7% 13.7% 80.4%
lightgoldenrod1 lightgoldenrod1 100.0% 92.5% 54.5% 13.9% 45.5% 100.0%
lightgoldenrod2 lightgoldenrod2 93.3% 86.3% 51.0% 13.9% 45.4% 93.3%
lightgoldenrod3 lightgoldenrod3 80.4% 74.5% 43.9% 14.0% 45.4% 80.4%
gold gold 100.0% 84.3% 0.0% 14.1% 100.0% 100.0%
gold2 gold2 93.3% 78.8% 0.0% 14.1% 100.0% 93.3%
gold3 gold3 80.4% 67.8% 0.0% 14.1% 100.0% 80.4%
gold4 gold4 54.5% 45.9% 0.0% 14.0% 100.0% 54.5%
cornsilk4 cornsilk4 54.5% 53.3% 47.1% 14.0% 13.7% 54.5%
lemonchiffon2 lemonchiffon2 93.3% 91.4% 74.9% 14.9% 19.7% 93.3%
lightgoldenrod lightgoldenrod 93.3% 86.7% 51.0% 14.0% 45.4% 93.3%
lightgoldenrod4 lightgoldenrod4 54.5% 50.6% 29.8% 14.0% 45.3% 54.5%
khaki khaki 94.1% 90.2% 54.9% 15.0% 41.7% 94.1%
khaki1 khaki1 100.0% 96.5% 56.1% 15.3% 43.9% 100.0%
khaki2 khaki2 93.3% 90.2% 52.2% 15.4% 44.1% 93.3%
khaki3 khaki3 80.4% 77.6% 45.1% 15.4% 43.9% 80.4%
khaki4 khaki4 54.5% 52.5% 30.6% 15.3% 43.9% 54.5%
darkkhaki darkkhaki 74.1% 71.8% 42.0% 15.4% 43.4% 74.1%
lemonchiffon lemonchiffon 100.0% 98.0% 80.4% 15.0% 19.6% 100.0%
lemonchiffon3 lemonchiffon3 80.4% 78.8% 64.7% 15.0% 19.5% 80.4%
lemonchiffon4 lemonchiffon4 54.5% 53.7% 43.9% 15.4% 19.4% 54.5%
palegoldenrod palegoldenrod 93.3% 91.0% 66.7% 15.2% 28.6% 93.3%
beige beige 96.1% 96.1% 86.3% 16.7% 10.2% 96.1%
olive olive 50.2% 50.2% 0.0% 16.7% 100.0% 50.2%
ivory ivory 100.0% 100.0% 94.1% 16.7% 5.9% 100.0%
ivory2 ivory2 93.3% 93.3% 87.8% 16.7% 5.9% 93.3%
ivory3 ivory3 80.4% 80.4% 75.7% 16.7% 5.9% 80.4%
ivory4 ivory4 54.5% 54.5% 51.4% 16.7% 5.8% 54.5%
yellow yellow 100.0% 100.0% 0.0% 16.7% 100.0% 100.0%
yellow2 yellow2 93.3% 93.3% 0.0% 16.7% 100.0% 93.3%
yellow3 yellow3 80.4% 80.4% 0.0% 16.7% 100.0% 80.4%
yellow4 yellow4 54.5% 54.5% 0.0% 16.7% 100.0% 54.5%
lightyellow lightyellow 100.0% 100.0% 87.8% 16.7% 12.2% 100.0%
lightyellow2 lightyellow2 93.3% 93.3% 82.0% 16.7% 12.2% 93.3%
lightyellow3 lightyellow3 80.4% 80.4% 70.6% 16.7% 12.2% 80.4%
lightyellow4 lightyellow4 54.5% 54.5% 47.8% 16.7% 12.2% 54.5%
lightgoldenrodyellow lightgoldenrodyellow 98.0% 98.0% 82.4% 16.7% 16.0% 98.0%
olivedrab olivedrab 42.0% 55.7% 13.7% 22.1% 75.4% 55.7%
olivedrab1 olivedrab1 75.3% 100.0% 24.3% 22.1% 75.7% 100.0%
olivedrab2 olivedrab2 70.2% 93.3% 22.7% 22.1% 75.6% 93.3%
olivedrab3 olivedrab3 60.4% 80.4% 19.6% 22.2% 75.6% 80.4%
olivedrab4 olivedrab4 41.2% 54.5% 13.3% 22.1% 75.5% 54.5%
darkolivegreen darkolivegreen 33.3% 42.0% 18.4% 22.8% 56.1% 42.0%
darkolivegreen1 darkolivegreen1 79.2% 100.0% 43.9% 22.8% 56.1% 100.0%
darkolivegreen2 darkolivegreen2 73.7% 93.3% 40.8% 22.9% 56.3% 93.3%
darkolivegreen3 darkolivegreen3 63.5% 80.4% 35.3% 22.9% 56.1% 80.4%
darkolivegreen4 darkolivegreen4 43.1% 54.5% 23.9% 22.9% 56.1% 54.5%
greenyellow greenyellow 67.8% 100.0% 18.4% 23.2% 81.6% 100.0%
lawngreen lawngreen 48.6% 98.8% 0.0% 25.1% 100.0% 98.8%
chartreuse chartreuse 49.8% 100.0% 0.0% 25.0% 100.0% 100.0%
chartreuse2 chartreuse2 46.3% 93.3% 0.0% 25.1% 100.0% 93.3%
chartreuse3 chartreuse3 40.0% 80.4% 0.0% 25.0% 100.0% 80.4%
chartreuse4 chartreuse4 27.1% 54.5% 0.0% 25.1% 100.0% 54.5%
green green 0.0% 100.0% 0.0% 33.3% 100.0% 100.0%
green2 green2 0.0% 93.3% 0.0% 33.3% 100.0% 93.3%
green3 green3 0.0% 80.4% 0.0% 33.3% 100.0% 80.4%
green4 green4 0.0% 54.5% 0.0% 33.3% 100.0% 54.5%
webgreen webgreen 0.0% 50.2% 0.0% 33.3% 100.0% 50.2%
honeydew honeydew 94.1% 100.0% 94.1% 33.3% 5.9% 100.0%
honeydew2 honeydew2 87.8% 93.3% 87.8% 33.3% 5.9% 93.3%
honeydew3 honeydew3 75.7% 80.4% 75.7% 33.3% 5.9% 80.4%
honeydew4 honeydew4 51.4% 54.5% 51.4% 33.3% 5.8% 54.5%
darkgreen darkgreen 0.0% 39.2% 0.0% 33.3% 100.0% 39.2%
palegreen palegreen 59.6% 98.4% 59.6% 33.3% 39.4% 98.4%
palegreen1 palegreen1 60.4% 100.0% 60.4% 33.3% 39.6% 100.0%
palegreen3 palegreen3 48.6% 80.4% 48.6% 33.3% 39.5% 80.4%
palegreen4 palegreen4 32.9% 54.5% 32.9% 33.3% 39.6% 54.5%
limegreen limegreen 19.6% 80.4% 19.6% 33.3% 75.6% 80.4%
lightgreen lightgreen 56.5% 93.3% 56.5% 33.3% 39.5% 93.3%
forestgreen forestgreen 13.3% 54.5% 13.3% 33.3% 75.5% 54.5%
darkseagreen darkseagreen 56.1% 73.7% 56.1% 33.3% 23.9% 73.7%
darkseagreen1 darkseagreen1 75.7% 100.0% 75.7% 33.3% 24.3% 100.0%
darkseagreen2 darkseagreen2 70.6% 93.3% 70.6% 33.3% 24.4% 93.3%
darkseagreen3 darkseagreen3 60.8% 80.4% 60.8% 33.3% 24.4% 80.4%
darkseagreen4 darkseagreen4 41.2% 54.5% 41.2% 33.3% 24.5% 54.5%
seagreen seagreen 18.0% 54.5% 34.1% 40.7% 66.9% 54.5%
seagreen1 seagreen1 32.9% 100.0% 62.4% 40.6% 67.1% 100.0%
seagreen2 seagreen2 30.6% 93.3% 58.0% 40.6% 67.2% 93.3%
seagreen3 seagreen3 26.3% 80.4% 50.2% 40.7% 67.3% 80.4%
mediumseagreen mediumseagreen 23.5% 70.2% 44.3% 40.8% 66.5% 70.2%
mintcream mintcream 96.1% 100.0% 98.0% 41.7% 3.9% 100.0%
springgreen springgreen 0.0% 100.0% 49.8% 41.6% 100.0% 100.0%
springgreen2 springgreen2 0.0% 93.3% 46.3% 41.6% 100.0% 93.3%
springgreen3 springgreen3 0.0% 80.4% 40.0% 41.6% 100.0% 80.4%
springgreen4 springgreen4 0.0% 54.5% 27.1% 41.6% 100.0% 54.5%
mediumspringgreen mediumspringgreen 0.0% 98.0% 60.4% 43.6% 100.0% 98.0%
aquamarine aquamarine 49.8% 100.0% 83.1% 44.4% 50.2% 100.0%
aquamarine2 aquamarine2 46.3% 93.3% 77.6% 44.4% 50.4% 93.3%
aquamarine3 aquamarine3 40.0% 80.4% 66.7% 44.3% 50.2% 80.4%
aquamarine4 aquamarine4 27.1% 54.5% 45.5% 44.5% 50.4% 54.5%
turquoise turquoise 25.1% 87.8% 81.6% 48.3% 71.4% 87.8%
lightseagreen lightseagreen 12.5% 69.8% 66.7% 49.1% 82.0% 69.8%
mediumturquoise mediumturquoise 28.2% 82.0% 80.0% 49.4% 65.6% 82.0%
teal teal 0.0% 50.2% 50.2% 50.0% 100.0% 50.2%
aqua aqua 0.0% 100.0% 100.0% 50.0% 100.0% 100.0%
cyan2 cyan2 0.0% 93.3% 93.3% 50.0% 100.0% 93.3%
cyan3 cyan3 0.0% 80.4% 80.4% 50.0% 100.0% 80.4%
cyan4 cyan4 0.0% 54.5% 54.5% 50.0% 100.0% 54.5%
azure azure 94.1% 100.0% 100.0% 50.0% 5.9% 100.0%
azure2 azure2 87.8% 93.3% 93.3% 50.0% 5.9% 93.3%
azure3 azure3 75.7% 80.4% 80.4% 50.0% 5.9% 80.4%
azure4 azure4 51.4% 54.5% 54.5% 50.0% 5.8% 54.5%
cadetblue cadetblue 37.3% 62.0% 62.7% 50.5% 40.6% 62.7%
lightcyan lightcyan 87.8% 100.0% 100.0% 50.0% 12.2% 100.0%
lightcyan2 lightcyan2 82.0% 93.3% 93.3% 50.0% 12.2% 93.3%
lightcyan3 lightcyan3 70.6% 80.4% 80.4% 50.0% 12.2% 80.4%
lightcyan4 lightcyan4 47.8% 54.5% 54.5% 50.0% 12.2% 54.5%
turquoise1 turquoise1 0.0% 96.1% 100.0% 50.7% 100.0% 100.0%
turquoise2 turquoise2 0.0% 89.8% 93.3% 50.6% 100.0% 93.3%
turquoise3 turquoise3 0.0% 77.3% 80.4% 50.7% 100.0% 80.4%
turquoise4 turquoise4 0.0% 52.5% 54.5% 50.6% 100.0% 54.5%
darkslategray darkslategray 18.4% 31.0% 31.0% 50.0% 40.5% 31.0%
darkslategray1 darkslategray1 59.2% 100.0% 100.0% 50.0% 40.8% 100.0%
darkslategray2 darkslategray2 55.3% 93.3% 93.3% 50.0% 40.8% 93.3%
darkslategray3 darkslategray3 47.5% 80.4% 80.4% 50.0% 41.0% 80.4%
darkslategray4 darkslategray4 32.2% 54.5% 54.5% 50.0% 41.0% 54.5%
darkturquoise darkturquoise 0.0% 80.8% 82.0% 50.2% 100.0% 82.0%
paleturquoise paleturquoise 68.6% 93.3% 93.3% 50.0% 26.5% 93.3%
paleturquoise1 paleturquoise1 73.3% 100.0% 100.0% 50.0% 26.7% 100.0%
paleturquoise2 paleturquoise2 68.2% 93.3% 93.3% 50.0% 26.9% 93.3%
paleturquoise3 paleturquoise3 58.8% 80.4% 80.4% 50.0% 26.8% 80.4%
paleturquoise4 paleturquoise4 40.0% 54.5% 54.5% 50.0% 26.6% 54.5%
cadetblue1 cadetblue1 59.6% 96.1% 100.0% 51.6% 40.4% 100.0%
cadetblue2 cadetblue2 55.7% 89.8% 93.3% 51.6% 40.3% 93.3%
cadetblue3 cadetblue3 47.8% 77.3% 80.4% 51.6% 40.5% 80.4%
cadetblue4 cadetblue4 32.5% 52.5% 54.5% 51.5% 40.3% 54.5%
powderblue powderblue 69.0% 87.8% 90.2% 51.9% 23.5% 90.2%
lightblue4 lightblue4 40.8% 51.4% 54.5% 53.8% 25.2% 54.5%
skyblue skyblue 52.9% 80.8% 92.2% 54.8% 42.6% 92.2%
lightblue lightblue 67.8% 84.7% 90.2% 54.1% 24.8% 90.2%
lightblue1 lightblue1 74.9% 93.7% 100.0% 54.2% 25.1% 100.0%
lightblue2 lightblue2 69.8% 87.5% 93.3% 54.2% 25.2% 93.3%
lightblue3 lightblue3 60.4% 75.3% 80.4% 54.2% 24.9% 80.4%
deepskyblue deepskyblue 0.0% 74.9% 100.0% 54.2% 100.0% 100.0%
deepskyblue2 deepskyblue2 0.0% 69.8% 93.3% 54.2% 100.0% 93.3%
deepskyblue3 deepskyblue3 0.0% 60.4% 80.4% 54.1% 100.0% 80.4%
deepskyblue4 deepskyblue4 0.0% 40.8% 54.5% 54.2% 100.0% 54.5%
lightskyblue3 lightskyblue3 55.3% 71.4% 80.4% 56.0% 31.2% 80.4%
skyblue1 skyblue1 52.9% 80.8% 100.0% 56.8% 47.1% 100.0%
skyblue2 skyblue2 49.4% 75.3% 93.3% 56.8% 47.1% 93.3%
skyblue3 skyblue3 42.4% 65.1% 80.4% 56.7% 47.3% 80.4%
skyblue4 skyblue4 29.0% 43.9% 54.5% 56.9% 46.8% 54.5%
lightskyblue lightskyblue 52.9% 80.8% 98.0% 56.4% 46.0% 98.0%
lightskyblue1 lightskyblue1 69.0% 88.6% 100.0% 56.1% 31.0% 100.0%
lightskyblue2 lightskyblue2 64.3% 82.7% 93.3% 56.1% 31.1% 93.3%
lightskyblue4 lightskyblue4 37.6% 48.2% 54.5% 56.2% 30.9% 54.5%
aliceblue aliceblue 94.1% 97.3% 100.0% 57.8% 5.9% 100.0%
steelblue steelblue 27.5% 51.0% 70.6% 57.6% 61.1% 70.6%
steelblue1 steelblue1 38.8% 72.2% 100.0% 57.6% 61.2% 100.0%
steelblue2 steelblue2 36.1% 67.5% 93.3% 57.5% 61.3% 93.3%
steelblue3 steelblue3 31.0% 58.0% 80.4% 57.5% 61.5% 80.4%
steelblue4 steelblue4 21.2% 39.2% 54.5% 57.6% 61.2% 54.5%
slategray slategray 43.9% 50.2% 56.5% 58.3% 22.2% 56.5%
slategray1 slategray1 77.6% 88.6% 100.0% 58.5% 22.4% 100.0%
slategray2 slategray2 72.5% 82.7% 93.3% 58.5% 22.3% 93.3%
slategray3 slategray3 62.4% 71.4% 80.4% 58.3% 22.4% 80.4%
slategray4 slategray4 42.4% 48.2% 54.5% 58.6% 22.3% 54.5%
dodgerblue dodgerblue 11.8% 56.5% 100.0% 58.2% 88.2% 100.0%
dodgerblue2 dodgerblue2 11.0% 52.5% 93.3% 58.3% 88.2% 93.3%
dodgerblue3 dodgerblue3 9.4% 45.5% 80.4% 58.2% 88.3% 80.4%
dodgerblue4 dodgerblue4 6.3% 30.6% 54.5% 58.3% 88.5% 54.5%
lightslategray lightslategray 46.7% 53.3% 60.0% 58.3% 22.2% 60.0%
lightsteelblue lightsteelblue 69.0% 76.9% 87.1% 59.4% 20.7% 87.1%
lightsteelblue1 lightsteelblue1 79.2% 88.2% 100.0% 59.4% 20.8% 100.0%
lightsteelblue2 lightsteelblue2 73.7% 82.4% 93.3% 59.3% 21.0% 93.3%
lightsteelblue3 lightsteelblue3 63.5% 71.0% 80.4% 59.3% 21.0% 80.4%
lightsteelblue4 lightsteelblue4 43.1% 48.2% 54.5% 59.2% 20.9% 54.5%
cornflowerblue cornflowerblue 39.2% 58.4% 92.9% 60.7% 57.8% 92.9%
royalblue royalblue 25.5% 41.2% 88.2% 62.5% 71.1% 88.2%
royalblue1 royalblue1 28.2% 46.3% 100.0% 62.5% 71.8% 100.0%
royalblue2 royalblue2 26.3% 43.1% 93.3% 62.5% 71.8% 93.3%
royalblue3 royalblue3 22.7% 37.3% 80.4% 62.5% 71.7% 80.4%
royalblue4 royalblue4 15.3% 25.1% 54.5% 62.5% 71.9% 54.5%
blue blue 0.0% 0.0% 100.0% 66.7% 100.0% 100.0%
blue2 blue2 0.0% 0.0% 93.3% 66.7% 100.0% 93.3%
blue3 blue3 0.0% 0.0% 80.4% 66.7% 100.0% 80.4%
blue4 blue4 0.0% 0.0% 54.5% 66.7% 100.0% 54.5%
navy navy 0.0% 0.0% 50.2% 66.7% 100.0% 50.2%
lavender lavender 90.2% 90.2% 98.0% 66.7% 8.0% 98.0%
ghostwhite ghostwhite 97.3% 97.3% 100.0% 66.7% 2.7% 100.0%
midnightblue midnightblue 9.8% 9.8% 43.9% 66.7% 77.7% 43.9%
slateblue slateblue 41.6% 35.3% 80.4% 69.0% 56.1% 80.4%
slateblue1 slateblue1 51.4% 43.5% 100.0% 69.0% 56.5% 100.0%
slateblue3 slateblue3 41.2% 34.9% 80.4% 69.0% 56.6% 80.4%
slateblue4 slateblue4 27.8% 23.5% 54.5% 69.0% 56.8% 54.5%
lightslateblue lightslateblue 51.8% 43.9% 100.0% 69.0% 56.1% 100.0%
slateblue2 slateblue2 47.8% 40.4% 93.3% 69.0% 56.7% 93.3%
darkslateblue darkslateblue 28.2% 23.9% 54.5% 69.0% 56.1% 54.5%
mediumslateblue mediumslateblue 48.2% 40.8% 93.3% 69.0% 56.3% 93.3%
mediumpurple mediumpurple 57.6% 43.9% 85.9% 72.1% 48.9% 85.9%
mediumpurple1 mediumpurple1 67.1% 51.0% 100.0% 72.1% 49.0% 100.0%
mediumpurple2 mediumpurple2 62.4% 47.5% 93.3% 72.1% 49.2% 93.3%
mediumpurple3 mediumpurple3 53.7% 40.8% 80.4% 72.1% 49.3% 80.4%
mediumpurple4 mediumpurple4 36.5% 27.8% 54.5% 72.1% 48.9% 54.5%
purple1 purple1 60.8% 18.8% 100.0% 75.3% 81.2% 100.0%
purple2 purple2 56.9% 17.3% 93.3% 75.3% 81.5% 93.3%
purple3 purple3 49.0% 14.9% 80.4% 75.3% 81.5% 80.4%
purple4 purple4 33.3% 10.2% 54.5% 75.4% 81.3% 54.5%
blueviolet blueviolet 54.1% 16.9% 88.6% 75.3% 81.0% 88.6%
rebeccapurple rebeccapurple 40.0% 20.0% 60.0% 75.0% 66.7% 60.0%
indigo indigo 29.4% 0.0% 51.0% 76.3% 100.0% 51.0%
purple purple 62.7% 12.5% 94.1% 76.9% 86.7% 94.1%
darkorchid darkorchid 60.0% 19.6% 80.0% 77.8% 75.5% 80.0%
darkorchid1 darkorchid1 74.9% 24.3% 100.0% 77.8% 75.7% 100.0%
darkorchid2 darkorchid2 69.8% 22.7% 93.3% 77.8% 75.6% 93.3%
darkorchid3 darkorchid3 60.4% 19.6% 80.4% 77.8% 75.6% 80.4%
darkorchid4 darkorchid4 40.8% 13.3% 54.5% 77.8% 75.5% 54.5%
darkviolet darkviolet 58.0% 0.0% 82.7% 78.4% 100.0% 82.7%
mediumorchid1 mediumorchid1 87.8% 40.0% 100.0% 80.0% 60.0% 100.0%
mediumorchid2 mediumorchid2 82.0% 37.3% 93.3% 80.0% 60.1% 93.3%
mediumorchid3 mediumorchid3 70.6% 32.2% 80.4% 79.9% 60.0% 80.4%
mediumorchid4 mediumorchid4 47.8% 21.6% 54.5% 80.0% 60.4% 54.5%
mediumorchid mediumorchid 72.9% 33.3% 82.7% 80.0% 59.7% 82.7%
plum plum 86.7% 62.7% 86.7% 83.3% 27.6% 86.7%
plum1 plum1 100.0% 73.3% 100.0% 83.3% 26.7% 100.0%
plum2 plum2 93.3% 68.2% 93.3% 83.3% 26.9% 93.3%
plum3 plum3 80.4% 58.8% 80.4% 83.3% 26.8% 80.4%
plum4 plum4 54.5% 40.0% 54.5% 83.3% 26.6% 54.5%
orchid orchid 85.5% 43.9% 83.9% 84.0% 48.6% 85.5%
orchid4 orchid4 54.5% 27.8% 53.7% 83.8% 48.9% 54.5%
violet violet 93.3% 51.0% 93.3% 83.3% 45.4% 93.3%
magenta2 magenta2 93.3% 0.0% 93.3% 83.3% 100.0% 93.3%
magenta3 magenta3 80.4% 0.0% 80.4% 83.3% 100.0% 80.4%
fuchsia fuchsia 100.0% 0.0% 100.0% 83.3% 100.0% 100.0%
thistle thistle 84.7% 74.9% 84.7% 83.3% 11.6% 84.7%
thistle1 thistle1 100.0% 88.2% 100.0% 83.3% 11.8% 100.0%
thistle2 thistle2 93.3% 82.4% 93.3% 83.3% 11.8% 93.3%
thistle3 thistle3 80.4% 71.0% 80.4% 83.3% 11.7% 80.4%
thistle4 thistle4 54.5% 48.2% 54.5% 83.3% 11.5% 54.5%
webpurple webpurple 50.2% 0.0% 50.2% 83.3% 100.0% 50.2%
darkmagenta darkmagenta 54.5% 0.0% 54.5% 83.3% 100.0% 54.5%
orchid1 orchid1 100.0% 51.4% 98.0% 84.0% 48.6% 100.0%
orchid2 orchid2 93.3% 47.8% 91.4% 84.1% 48.7% 93.3%
orchid3 orchid3 80.4% 41.2% 78.8% 84.0% 48.8% 80.4%
maroon1 maroon1 100.0% 20.4% 70.2% 89.6% 79.6% 100.0%
maroon2 maroon2 93.3% 18.8% 65.5% 89.6% 79.8% 93.3%
maroon3 maroon3 80.4% 16.1% 56.5% 89.5% 80.0% 80.4%
maroon4 maroon4 54.5% 11.0% 38.4% 89.5% 79.9% 54.5%
violetred violetred 81.6% 12.5% 56.5% 89.4% 84.6% 81.6%
mediumvioletred mediumvioletred 78.0% 8.2% 52.2% 89.5% 89.4% 78.0%
deeppink deeppink 100.0% 7.8% 57.6% 91.0% 92.2% 100.0%
deeppink2 deeppink2 93.3% 7.1% 53.7% 91.0% 92.4% 93.3%
deeppink4 deeppink4 54.5% 3.9% 31.4% 91.0% 92.8% 54.5%
hotpink hotpink 100.0% 41.2% 70.6% 91.7% 58.8% 100.0%
hotpink1 hotpink1 100.0% 43.1% 70.6% 92.0% 56.9% 100.0%
hotpink4 hotpink4 54.5% 22.7% 38.4% 91.8% 58.3% 54.5%
deeppink3 deeppink3 80.4% 6.3% 46.3% 91.0% 92.2% 80.4%
hotpink2 hotpink2 93.3% 41.6% 65.5% 92.3% 55.5% 93.3%
hotpink3 hotpink3 80.4% 37.6% 56.5% 92.7% 53.2% 80.4%
violetred1 violetred1 100.0% 24.3% 58.8% 92.4% 75.7% 100.0%
violetred2 violetred2 93.3% 22.7% 54.9% 92.4% 75.6% 93.3%
violetred3 violetred3 80.4% 19.6% 47.1% 92.5% 75.6% 80.4%
violetred4 violetred4 54.5% 13.3% 32.2% 92.4% 75.5% 54.5%
maroon maroon 69.0% 18.8% 37.6% 93.8% 72.7% 69.0%
lavenderblush4 lavenderblush4 54.5% 51.4% 52.5% 93.8% 5.8% 54.5%
lavenderblush lavenderblush 100.0% 94.1% 96.1% 94.4% 5.9% 100.0%
lavenderblush2 lavenderblush2 93.3% 87.8% 89.8% 94.0% 5.9% 93.3%
lavenderblush3 lavenderblush3 80.4% 75.7% 77.3% 94.4% 5.9% 80.4%
palevioletred palevioletred 85.9% 43.9% 57.6% 94.5% 48.9% 85.9%
palevioletred1 palevioletred1 100.0% 51.0% 67.1% 94.5% 49.0% 100.0%
palevioletred2 palevioletred2 93.3% 47.5% 62.4% 94.6% 49.2% 93.3%
palevioletred3 palevioletred3 80.4% 40.8% 53.7% 94.6% 49.3% 80.4%
palevioletred4 palevioletred4 54.5% 27.8% 36.5% 94.6% 48.9% 54.5%
pink1 pink1 100.0% 71.0% 77.3% 96.4% 29.0% 100.0%
pink2 pink2 93.3% 66.3% 72.2% 96.4% 29.0% 93.3%
pink3 pink3 80.4% 56.9% 62.0% 96.4% 29.3% 80.4%
pink4 pink4 54.5% 38.8% 42.4% 96.2% 28.8% 54.5%
crimson crimson 86.3% 7.8% 23.5% 96.7% 90.9% 86.3%
pink pink 100.0% 75.3% 79.6% 97.1% 24.7% 100.0%
lightpink lightpink 100.0% 71.4% 75.7% 97.5% 28.6% 100.0%
lightpink1 lightpink1 100.0% 68.2% 72.5% 97.7% 31.8% 100.0%
lightpink2 lightpink2 93.3% 63.5% 67.8% 97.6% 31.9% 93.3%
lightpink3 lightpink3 80.4% 54.9% 58.4% 97.7% 31.7% 80.4%
lightpink4 lightpink4 54.5% 37.3% 39.6% 97.7% 31.7% 54.5%
black black 0.0% 0.0% 0.0% 0.0% 0.0% 0.0%
gray1 gray1 1.2% 1.2% 1.2% 0.0% 0.0% 1.2%
gray2 gray2 2.0% 2.0% 2.0% 0.0% 0.0% 2.0%
gray3 gray3 3.1% 3.1% 3.1% 0.0% 0.0% 3.1%
gray4 gray4 3.9% 3.9% 3.9% 0.0% 0.0% 3.9%
gray5 gray5 5.1% 5.1% 5.1% 0.0% 0.0% 5.1%
gray6 gray6 5.9% 5.9% 5.9% 0.0% 0.0% 5.9%
gray7 gray7 7.1% 7.1% 7.1% 0.0% 0.0% 7.1%
gray8 gray8 7.8% 7.8% 7.8% 0.0% 0.0% 7.8%
gray9 gray9 9.0% 9.0% 9.0% 0.0% 0.0% 9.0%
gray10 gray10 10.2% 10.2% 10.2% 0.0% 0.0% 10.2%
gray11 gray11 11.0% 11.0% 11.0% 0.0% 0.0% 11.0%
gray12 gray12 12.2% 12.2% 12.2% 0.0% 0.0% 12.2%
gray13 gray13 12.9% 12.9% 12.9% 0.0% 0.0% 12.9%
gray14 gray14 14.1% 14.1% 14.1% 0.0% 0.0% 14.1%
gray15 gray15 14.9% 14.9% 14.9% 0.0% 0.0% 14.9%
gray16 gray16 16.1% 16.1% 16.1% 0.0% 0.0% 16.1%
gray17 gray17 16.9% 16.9% 16.9% 0.0% 0.0% 16.9%
gray18 gray18 18.0% 18.0% 18.0% 0.0% 0.0% 18.0%
gray19 gray19 18.8% 18.8% 18.8% 0.0% 0.0% 18.8%
gray20 gray20 20.0% 20.0% 20.0% 0.0% 0.0% 20.0%
gray21 gray21 21.2% 21.2% 21.2% 0.0% 0.0% 21.2%
gray22 gray22 22.0% 22.0% 22.0% 0.0% 0.0% 22.0%
gray23 gray23 23.1% 23.1% 23.1% 0.0% 0.0% 23.1%
gray24 gray24 23.9% 23.9% 23.9% 0.0% 0.0% 23.9%
gray25 gray25 25.1% 25.1% 25.1% 0.0% 0.0% 25.1%
gray26 gray26 25.9% 25.9% 25.9% 0.0% 0.0% 25.9%
gray27 gray27 27.1% 27.1% 27.1% 0.0% 0.0% 27.1%
gray28 gray28 27.8% 27.8% 27.8% 0.0% 0.0% 27.8%
gray29 gray29 29.0% 29.0% 29.0% 0.0% 0.0% 29.0%
gray30 gray30 30.2% 30.2% 30.2% 0.0% 0.0% 30.2%
gray31 gray31 31.0% 31.0% 31.0% 0.0% 0.0% 31.0%
gray32 gray32 32.2% 32.2% 32.2% 0.0% 0.0% 32.2%
gray33 gray33 32.9% 32.9% 32.9% 0.0% 0.0% 32.9%
gray34 gray34 34.1% 34.1% 34.1% 0.0% 0.0% 34.1%
gray35 gray35 34.9% 34.9% 34.9% 0.0% 0.0% 34.9%
gray36 gray36 36.1% 36.1% 36.1% 0.0% 0.0% 36.1%
gray37 gray37 36.9% 36.9% 36.9% 0.0% 0.0% 36.9%
gray38 gray38 38.0% 38.0% 38.0% 0.0% 0.0% 38.0%
gray39 gray39 38.8% 38.8% 38.8% 0.0% 0.0% 38.8%
gray40 gray40 40.0% 40.0% 40.0% 0.0% 0.0% 40.0%
dimgray dimgray 41.2% 41.2% 41.2% 0.0% 0.0% 41.2%
gray42 gray42 42.0% 42.0% 42.0% 0.0% 0.0% 42.0%
gray43 gray43 43.1% 43.1% 43.1% 0.0% 0.0% 43.1%
gray44 gray44 43.9% 43.9% 43.9% 0.0% 0.0% 43.9%
gray45 gray45 45.1% 45.1% 45.1% 0.0% 0.0% 45.1%
gray46 gray46 45.9% 45.9% 45.9% 0.0% 0.0% 45.9%
gray47 gray47 47.1% 47.1% 47.1% 0.0% 0.0% 47.1%
gray48 gray48 47.8% 47.8% 47.8% 0.0% 0.0% 47.8%
gray49 gray49 49.0% 49.0% 49.0% 0.0% 0.0% 49.0%
gray50 gray50 49.8% 49.8% 49.8% 0.0% 0.0% 49.8%
webgray webgray 50.2% 50.2% 50.2% 0.0% 0.0% 50.2%
gray51 gray51 51.0% 51.0% 51.0% 0.0% 0.0% 51.0%
gray52 gray52 52.2% 52.2% 52.2% 0.0% 0.0% 52.2%
gray53 gray53 52.9% 52.9% 52.9% 0.0% 0.0% 52.9%
gray54 gray54 54.1% 54.1% 54.1% 0.0% 0.0% 54.1%
gray55 gray55 54.9% 54.9% 54.9% 0.0% 0.0% 54.9%
gray56 gray56 56.1% 56.1% 56.1% 0.0% 0.0% 56.1%
gray57 gray57 56.9% 56.9% 56.9% 0.0% 0.0% 56.9%
gray58 gray58 58.0% 58.0% 58.0% 0.0% 0.0% 58.0%
gray59 gray59 58.8% 58.8% 58.8% 0.0% 0.0% 58.8%
gray60 gray60 60.0% 60.0% 60.0% 0.0% 0.0% 60.0%
gray61 gray61 61.2% 61.2% 61.2% 0.0% 0.0% 61.2%
gray62 gray62 62.0% 62.0% 62.0% 0.0% 0.0% 62.0%
gray63 gray63 63.1% 63.1% 63.1% 0.0% 0.0% 63.1%
gray64 gray64 63.9% 63.9% 63.9% 0.0% 0.0% 63.9%
gray65 gray65 65.1% 65.1% 65.1% 0.0% 0.0% 65.1%
gray66 gray66 65.9% 65.9% 65.9% 0.0% 0.0% 65.9%
darkgray darkgray 66.3% 66.3% 66.3% 0.0% 0.0% 66.3%
gray67 gray67 67.1% 67.1% 67.1% 0.0% 0.0% 67.1%
gray68 gray68 67.8% 67.8% 67.8% 0.0% 0.0% 67.8%
gray69 gray69 69.0% 69.0% 69.0% 0.0% 0.0% 69.0%
gray70 gray70 70.2% 70.2% 70.2% 0.0% 0.0% 70.2%
gray71 gray71 71.0% 71.0% 71.0% 0.0% 0.0% 71.0%
gray72 gray72 72.2% 72.2% 72.2% 0.0% 0.0% 72.2%
gray73 gray73 72.9% 72.9% 72.9% 0.0% 0.0% 72.9%
gray74 gray74 74.1% 74.1% 74.1% 0.0% 0.0% 74.1%
gray gray 74.5% 74.5% 74.5% 0.0% 0.0% 74.5%
gray75 gray75 74.9% 74.9% 74.9% 0.0% 0.0% 74.9%
silver silver 75.3% 75.3% 75.3% 0.0% 0.0% 75.3%
gray76 gray76 76.1% 76.1% 76.1% 0.0% 0.0% 76.1%
gray77 gray77 76.9% 76.9% 76.9% 0.0% 0.0% 76.9%
gray78 gray78 78.0% 78.0% 78.0% 0.0% 0.0% 78.0%
gray79 gray79 78.8% 78.8% 78.8% 0.0% 0.0% 78.8%
gray80 gray80 80.0% 80.0% 80.0% 0.0% 0.0% 80.0%
gray81 gray81 81.2% 81.2% 81.2% 0.0% 0.0% 81.2%
gray82 gray82 82.0% 82.0% 82.0% 0.0% 0.0% 82.0%
lightgray lightgray 82.7% 82.7% 82.7% 0.0% 0.0% 82.7%
gray83 gray83 83.1% 83.1% 83.1% 0.0% 0.0% 83.1%
gray84 gray84 83.9% 83.9% 83.9% 0.0% 0.0% 83.9%
gray85 gray85 85.1% 85.1% 85.1% 0.0% 0.0% 85.1%
gray86 gray86 85.9% 85.9% 85.9% 0.0% 0.0% 85.9%
gainsboro gainsboro 86.3% 86.3% 86.3% 0.0% 0.0% 86.3%
gray87 gray87 87.1% 87.1% 87.1% 0.0% 0.0% 87.1%
gray88 gray88 87.8% 87.8% 87.8% 0.0% 0.0% 87.8%
gray89 gray89 89.0% 89.0% 89.0% 0.0% 0.0% 89.0%
gray90 gray90 89.8% 89.8% 89.8% 0.0% 0.0% 89.8%
gray91 gray91 91.0% 91.0% 91.0% 0.0% 0.0% 91.0%
gray92 gray92 92.2% 92.2% 92.2% 0.0% 0.0% 92.2%
gray93 gray93 92.9% 92.9% 92.9% 0.0% 0.0% 92.9%
gray94 gray94 94.1% 94.1% 94.1% 0.0% 0.0% 94.1%
gray95 gray95 94.9% 94.9% 94.9% 0.0% 0.0% 94.9%
gray96 gray96 96.1% 96.1% 96.1% 0.0% 0.0% 96.1%
gray97 gray97 96.9% 96.9% 96.9% 0.0% 0.0% 96.9%
gray98 gray98 98.0% 98.0% 98.0% 0.0% 0.0% 98.0%
gray99 gray99 98.8% 98.8% 98.8% 0.0% 0.0% 98.8%
gray100 gray100 100.0% 100.0% 100.0% 0.0% 0.0% 100.0%

256 Colors

The built-in capability color() accepts a numeric index of any value between 0 and 254, I guess you could call this “Color by number…”, it not recommended, there are many common cases where the colors do not match across terminals!

16 Colors

Recommended for common CLI applications.

Traditional terminals are only capable of 8 colors:

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white

Prefixed with on_, the given color is used as the background color:

  • on_black
  • on_red
  • on_green
  • on_yellow
  • on_blue
  • on_magenta
  • on_cyan
  • on_white

The same colors, prefixed with bright_ or bold_, such as bright_blue, provides the other 8 colors of a 16-color terminal:

  • bright_black
  • bright_red
  • bright_green
  • bright_yellow
  • bright_blue
  • bright_magenta
  • bright_cyan
  • bright_white

Combined, there are actually three shades of grey for 16-color terminals, in ascending order of intensity:

  • bright_black: is dark grey.
  • white: a mild white.
  • bright_white: pure white (#ffffff).

Note

  • bright_black is actually a very dark shade of grey!
  • yellow is brown, only high-intensity yellow (bright_yellow) is yellow!
  • purple is magenta.

Warning

Terminal emulators use different values for any of these 16 colors, the most common of these are displayed at https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit. Users can customize these 16 colors as a common “theme”, so that one CLI application appears of the same color theme as the next.

When exact color values are needed, 24-bit Colors should be preferred, by their name or RGB value.

Monochrome

One small consideration for targeting legacy terminals, such as a vt220, which do not support colors but do support reverse video: select a foreground color, followed by reverse video, rather than selecting a background color directly:: the same desired background color effect as on_background:

>>>  print(term.on_green('This will not standout on a vt220'))
>>>  print(term.green_reverse('Though some terminals standout more than others'))

The second phrase appears as black on green on both color terminals and a green monochrome vt220.

Keyboard

The built-in function input() (or raw_input()) is pretty good for a basic game:

name = input("What is your name? ")
if sum(map(ord, name)) % 2:
    print(f"{name}?! What a beautiful name!")
else:
    print(f"How interesting, {name} you say?")

But it has drawbacks – it’s no good for interactive apps! This function will not return until the return key is pressed, so we can’t do any exciting animations, and we can’t understand or detect arrow keys and others required to make awesome, interactive apps and games!

Blessed fixes this issue with a context manager, cbreak(), and a single function for all keyboard input, inkey().

inkey()

Let’s just dive right into a rich “event loop”, that awaits a keypress for 3 seconds and tells us what key we pressed.

print(f"{term.home}{term.black_on_skyblue}{term.clear}")
print("press 'q' to quit.")
with term.cbreak():
    val = ''
    while val.lower() != 'q':
        val = term.inkey(timeout=3)
        if not val:
           print("It sure is quiet in here ...")
        elif val.is_sequence:
           print("got sequence: {0}.".format((str(val), val.name, val.code)))
        elif val:
           print("got {0}.".format(val))
    print(f'bye!{term.normal}')
A visual example of interacting with the Terminal.inkey() and cbreak() methods.

cbreak() enters a special mode that ensures os.read() on an input stream will return as soon as input is available, as explained in cbreak(3). This mode is combined with inkey() to decode multibyte sequences, such as \0x1bOA, into a unicode-derived Keystroke instance.

The Keystrok returned by inkey() is unicode – it may be printed, joined with, or compared to any other unicode strings. It also has these provides the special attributes:

  • is_sequence (bool): Whether it is an “application” key.
  • code (int): the keycode, for equality testing.
  • name (str): a human-readable name of any “application” key.

Keycodes

When the is_sequence property tests True, the value of code represents a unique application key of the keyboard.

code may then be compared with attributes of Terminal, which are duplicated from those found in curses(3), or those constants in curses beginning with phrase KEY_, as follows:

All Terminal class attribute Keyboard codes, by name
Name Value Example Sequence(s)
KEY_BACKSPACE 263 ‘\x08’, ‘\x7f’
KEY_BEGIN 354  
KEY_BTAB 353  
KEY_C1 351  
KEY_C3 352  
KEY_CANCEL 355  
KEY_CATAB 342  
KEY_CENTER 350  
KEY_CLEAR 333  
KEY_CLOSE 356  
KEY_COMMAND 357  
KEY_COPY 358  
KEY_CREATE 359  
KEY_CTAB 341  
KEY_DELETE 330 ‘\x1b[3~’
KEY_DL 328  
KEY_DOWN 258 ‘\x1b[B’, ‘\x1b[OB’
KEY_EIC 332  
KEY_END 360 ‘\x1b[F’, ‘\x1b[K’, ‘\x1b[8~’, ‘\x1b[OF’
KEY_ENTER 343 ‘\n’, ‘\r’, ‘\x1bOM’
KEY_EOL 335  
KEY_EOS 334  
KEY_ESCAPE 361 ‘\x1b’
KEY_F0 264  
KEY_F1 265 ‘\x1bOP’
KEY_F10 274  
KEY_F11 275  
KEY_F12 276  
KEY_F13 277  
KEY_F14 278  
KEY_F15 279  
KEY_F16 280  
KEY_F17 281  
KEY_F18 282  
KEY_F19 283  
KEY_F2 266 ‘\x1bOQ’
KEY_F20 284  
KEY_F21 285  
KEY_F22 286  
KEY_F23 287  
KEY_F3 267 ‘\x1bOR’
KEY_F4 268 ‘\x1bOS’
KEY_F5 269  
KEY_F6 270  
KEY_F7 271  
KEY_F8 272  
KEY_F9 273  
KEY_FIND 362 ‘\x1b[1~’
KEY_HELP 363  
KEY_HOME 262 ‘\x1b[H’, ‘\x1b[7~’, ‘\x1b[OH’
KEY_IL 329  
KEY_INSERT 331 ‘\x1b[2~’
KEY_KP_0 520 ‘\x1bOp’
KEY_KP_1 521 ‘\x1bOq’
KEY_KP_2 522 ‘\x1bOr’
KEY_KP_3 523 ‘\x1bOs’
KEY_KP_4 524 ‘\x1bOt’
KEY_KP_5 525 ‘\x1bOu’
KEY_KP_6 526 ‘\x1bOv’
KEY_KP_7 527 ‘\x1bOw’
KEY_KP_8 528 ‘\x1bOx’
KEY_KP_9 529 ‘\x1bOy’
KEY_KP_ADD 514 ‘\x1bOk’
KEY_KP_DECIMAL 517 ‘\x1bOn’
KEY_KP_DIVIDE 518 ‘\x1bOo’
KEY_KP_EQUAL 519 ‘\x1bOX’
KEY_KP_MULTIPLY 513 ‘\x1bOj’
KEY_KP_SEPARATOR 515 ‘\x1bOl’
KEY_KP_SUBTRACT 516 ‘\x1bOm’
KEY_LEFT 260 ‘\x1b[D’, ‘\x1b[OD’
KEY_LL 347  
KEY_MARK 364  
KEY_MAX 511  
KEY_MESSAGE 365  
KEY_MIN 257  
KEY_MOUSE 409  
KEY_MOVE 366  
KEY_NEXT 367  
KEY_OPEN 368  
KEY_OPTIONS 369  
KEY_PGDOWN 338 ‘\x1b[U’, ‘\x1b[6~’
KEY_PGUP 339 ‘\x1b[V’, ‘\x1b[5~’
KEY_PREVIOUS 370  
KEY_PRINT 346  
KEY_REDO 371  
KEY_REFERENCE 372  
KEY_REFRESH 373  
KEY_REPLACE 374  
KEY_RESET 345  
KEY_RESIZE 410  
KEY_RESTART 375  
KEY_RESUME 376  
KEY_RIGHT 261 ‘\x1b[C’, ‘\x1b[OC’
KEY_SAVE 377  
KEY_SBEG 378  
KEY_SCANCEL 379  
KEY_SCOMMAND 380  
KEY_SCOPY 381  
KEY_SCREATE 382  
KEY_SDC 383  
KEY_SDL 384  
KEY_SDOWN 336  
KEY_SELECT 385 ‘\x1b[4~’
KEY_SEND 386  
KEY_SEOL 387  
KEY_SEXIT 388  
KEY_SFIND 389  
KEY_SHELP 390  
KEY_SHOME 391  
KEY_SIC 392  
KEY_SLEFT 393  
KEY_SMESSAGE 394  
KEY_SMOVE 395  
KEY_SNEXT 396  
KEY_SOPTIONS 397  
KEY_SPREVIOUS 398  
KEY_SPRINT 399  
KEY_SREDO 400  
KEY_SREPLACE 401  
KEY_SRESET 344  
KEY_SRIGHT 402  
KEY_SRSUME 403  
KEY_SSAVE 404  
KEY_SSUSPEND 405  
KEY_STAB 340  
KEY_SUNDO 406  
KEY_SUP 337  
KEY_SUSPEND 407  
KEY_TAB 512 ‘\t’
KEY_UNDO 408  
KEY_UP 259 ‘\x1b[A’, ‘\x1b[OA’
KEY_UP_LEFT 348  
KEY_UP_RIGHT 349  

All such keystrokes can be decoded by blessed, there is a demonstration program, keymatrix.py that tests how many of them you can find !

delete

Typically, backspace is ^H (8, or 0x08) and delete is ^? (127, or 0x7f).

On some systems however, the key for backspace is actually labeled and transmitted as “delete”, though its function in the operating system behaves just as backspace. Blessed usually returns “backspace” in most situations.

It is highly recommend to accept both KEY_DELETE and KEY_BACKSPACE as having the same meaning except when implementing full screen editors, and provide a choice to enable the delete mode by configuration.

Alt/meta

Programs with GNU readline, like bash, have Alt combinators, such as ALT+u to uppercase the word after cursor. This is achieved by the configuration option altSendsEscape or metaSendsEscape in xterm.

The default for most terminals, however, is for this key to be bound by the operating system, or, used for inserting international keys, (where the combination ALT+u, a is used to insert the character ä).

It is therefore a recommendation to avoid alt or meta keys entirely in applications.

And instead prefer the ctrl-key combinations, maybe along with raw(), to avoid instructing users to custom-configure their terminal emulators to communicate Alt sequences.

If you still wish to optionall decode them, ALT+z becomes Escape + z (or, in raw form \x1bz). This is detected by blessings as two keystrokes, KEY_ESCAPE and 'z'. Blessings currently provides no further assistance in detecting these key combinations.

Location

If you just want to move the location of the cursor before writing text, and aren’t worried about returning, do something like this:

>>> print(term.home + term.clear)
>>> print(term.down(2) + term.move_right(20) + term.bright_red('fire!'))
>>> print(term.move_xy(20, 7) + term.bold('Direct hit!'))
>>> print(term.move_y(term.height - 3))

There are four direct movement capabilities:

move_xy(x, y)
Position cursor at given x, y.
move_x(x)
Position cursor at column x.
move_y(y)
Position cursor at row y.
home
Position cursor at (0, 0).

And four relative capabilities:

move_up or move_up(y)
Position cursor 1 or y row cells above the current position.
move_down(y)

Position cursor 1 or y row cells below the current position.

Note

move_down or is often valued as \n, which additionally returns the carriage to
column 0, and, depending on your terminal emulator, may also destroy any characters to end of line.

move_down(1) is always a safe non-destructive one-notch movement in the downward direction.

move_left or move_left(x)
Position cursor 1 or x column cells left of the current position.
move_right or move_right(x)
Position cursor 1 or x column cells right of the current position.

Example

The source code of bounce.py combines a small bit of Keyboard input with many of the Terminal location capabilities, home, width, height, and move_xy are used to create a classic game of tennis:

# std imports
from math import floor

# local
from blessed import Terminal


def roundxy(x, y):
    return int(floor(x)), int(floor(y))


term = Terminal()

x, y, xs, ys = 2, 2, 0.4, 0.3
with term.cbreak(), term.hidden_cursor():
    # clear the screen
    print(term.home + term.black_on_olivedrab4 + term.clear)

    # loop every 20ms
    while term.inkey(timeout=0.02) != 'q':
        # erase,
        txt_erase = term.move_xy(*roundxy(x, y)) + ' '

        # bounce,
        if x >= (term.width - 1) or x <= 0:
            xs *= -1
        if y >= term.height or y <= 0:
            ys *= -1

        # move,
        x, y = x + xs, y + ys

        # draw !
        txt_ball = term.move_xy(*roundxy(x, y)) + '█'
        print(txt_erase + txt_ball, end='', flush=True)
Animated screenshot of :ref:`bounce.py`

Context Manager

A contextlib.contextmanager(), location() is provided to move the cursor to an (x, y) screen position and restore the previous position on exit:

with term.location(0, term.height - 1):
    print('Here is the bottom.')

print('This is back where I came from.')

All parameters to location() are optional, we can use it without any arguments at all to restore the cursor location:

with term.location():
    print(term.move_xy(1, 1) + 'Hi Mom!' + term.clear_eol)

Note

calls to location() may not be nested.

Finding The Cursor

We can determine the cursor’s current position at anytime using get_location().

This uses a kind of “answer back” sequence that your terminal emulator responds to. Because the terminal may not respond, or may take some time to respond, the timeout keyword argument can be specified to return coordinates (-1, -1) after a blocking timeout:

>>> term.get_location(timeout=5)
(32, 0)

The return value of get_location() mirrors the arguments of location():

with term.location(12, 12):
     val = term.get_location()
print(val)

Produces output, (12, 12)

Although this wouldn’t be suggested in most applications because of its latency, it certainly simplifies many applications, and, can also be timed, to make a determination of the round-trip time, perhaps even the bandwidth constraints, of a remote terminal!

Measuring

Any string containing sequences can be measured by blessed using the length() method. This means that blessed can measure, right-align, center, or word-wrap its own output!

The height and width properties always provide a current readout of the size of the window:

>>> term.height, term.width
(34, 102)

By combining the measure of the printable width of strings containing sequences with the terminal width, the center(), ljust(), rjust(), and wrap() methods “just work” for strings that contain sequences.

with term.location(y=term.height // 2):
    print(term.center(term.bold('press return to begin!')))
    term.inkey()

In the following example, wrap() word-wraps a short poem containing sequences:

from blessed import Terminal

term = Terminal()

poem = (term.bold_cyan('Plan difficult tasks'),
        term.cyan('through the simplest tasks'),
        term.bold_cyan('Achieve large tasks'),
        term.cyan('through the smallest tasks'))

for line in poem:
    print('\n'.join(term.wrap(line, width=25, subsequent_indent=' ' * 4)))

Resizing

To detect when the size of the window changes, you can author a callback for SIGWINCH signals:

import signal
from blessed import Terminal

term = Terminal()

def on_resize(sig, action):
    print(f'height={term.height}, width={term.width}')

signal.signal(signal.SIGWINCH, on_resize)

# wait for keypress
term.inkey()
A visual animated example of the on_resize() function callback

Note

This is not compatible with Windows! We hope to make a cross-platform API for this in the future https://github.com/jquast/blessed/issues/131.

Sometimes it is necessary to make sense of sequences, and to distinguish them from plain text. The split_seqs() method can allow us to iterate over a terminal string by its characters or sequences:

>>> term.split_seqs(term.bold('bbq'))
['\x1b[1m', 'b', 'b', 'q', '\x1b(B', '\x1b[m']

Will display something like, ['\x1b[1m', 'b', 'b', 'q', '\x1b(B', '\x1b[m']

Method strip_seqs() can remove all sequences from a string:

>>> phrase = term.bold_black('coffee')
>>> phrase
'\x1b[1m\x1b[30mcoffee\x1b(B\x1b[m'
>>> term.strip_seqs(phrase)
'coffee'

Examples

A few programs are provided with blessed to help interactively test the various API features, but also serve as examples of using blessed to develop applications.

These examples are not distributed with the package – they are only available in the github repository. You can retrieve them by cloning the repository, or simply downloading the “raw” file link.

bounce.py

https://github.com/jquast/blessed/blob/master/bin/editor.py

This is a very brief, basic primitive non-interactive version of a “classic tennis” video game. It demonstrates basic timed refresh of a bouncing terminal cell.

cnn.py

https://github.com/jquast/blessed/blob/master/bin/cnn.py

This program uses 3rd-party BeautifulSoup and requests library to fetch the cnn website and display news article titles using the link() method, so that they may be clicked.

detect-multibyte.py

https://github.com/jquast/blessed/blob/master/bin/detect-multibyte.py

This program also demonstrates how the get_location() method can be used to reliably test whether the terminal emulator of the connecting client is capable of rendering multibyte characters as a single cell.

editor.py

https://github.com/jquast/blessed/blob/master/bin/editor.py

This program demonstrates using the directional keys and noecho input mode. It acts as a (very dumb) fullscreen editor, with support for saving a file, as well as including a rudimentary line-editor.

keymatrix.py

https://github.com/jquast/blessed/blob/master/bin/keymatrix.py

This program displays a “gameboard” of all known special KEY_NAME constants. When the key is depressed, it is highlighted, as well as displaying the unicode sequence, integer code, and friendly-name of any key pressed.

on_resize.py

https://github.com/jquast/blessed/blob/master/bin/on_resize.py

This program installs a SIGWINCH signal handler, which detects screen resizes while also polling for input, displaying keypresses.

This demonstrates how a program can react to screen resize events.

plasma.py

https://github.com/jquast/blessed/blob/master/bin/plasma.py

This demonstrates using only on_color_rgb() and the built-in colorsys module to quickly display all of the colors of a rainbow in a classic demoscene plasma effect

progress_bar.py

https://github.com/jquast/blessed/blob/master/bin/progress_bar.py

This program demonstrates a simple progress bar. All text is written to stderr, to avoid the need to “flush” or emit newlines, and makes use of the move_x (hpa) capability to “overstrike” the display a scrolling progress bar.

resize.py

https://github.com/jquast/blessed/blob/master/bin/resize.py

This program demonstrates the get_location() method, behaving similar to resize(1) : set environment and terminal settings to current window size. The window size is determined by eliciting an answerback sequence from the connecting terminal emulator.

tprint.py

https://github.com/jquast/blessed/blob/master/bin/tprint.py

This program demonstrates how users may customize FormattingString styles. Accepting a string style, such as “bold” or “bright_red” as the first argument, all subsequent arguments are displayed by the given style. This shows how a program could provide user-customizable compound formatting names to configure a program’s styling.

worms.py

https://github.com/jquast/blessed/blob/master/bin/worms.py

This program demonstrates how an interactive game could be made with blessed. It is similar to NIBBLES.BAS or “snake” of early mobile platforms.

x11_colorpicker.py

https://github.com/jquast/blessed/blob/master/bin/x11_colorpicker.py

This program shows all of the X11 colors, demonstrates a basic keyboard-interactive program and color selection, but is also a useful utility to pick colors!

API Documentation

color.py

Sub-module providing color functions.

References,

rgb_to_xyz(red, green, blue)[source]

Convert standard RGB color to XYZ color.

Parameters:
  • red (int) – RGB value of Red.
  • green (int) – RGB value of Green.
  • blue (int) – 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 (float) – XYZ value of X.
  • y_val (float) – XYZ value of Y.
  • z_val (float) – 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 (int) – RGB value of Red.
  • green (int) – RGB value of Green.
  • blue (int) – 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

Color reference data.

References,

class RGBColor[source]

Named tuple for an RGB color definition.

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
Returns:Color names with prefixes
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:

>>> from blessed import Terminal
>>> 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 (str) – parameterized string suitable for curses.tparm()
  • normal (str) – terminating sequence for this capability (optional).
  • name (str) – 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.

Raises:
Return type:

FormattingString or NullCallableString

Returns:

Callable string for given parameters

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_pair (tuple) – Two element tuple containing: - format string suitable for displaying terminal sequences - callable suitable for receiving __call__ arguments for formatting string
  • normal (str) – terminating sequence for this capability (optional).
  • name (str) – 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
Returns:Callable string for given parameters
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:

>>> from blessed import Terminal
>>> term = Terminal()
>>> 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 (str) – terminal attribute sequence.
  • normal (str) – terminating sequence for this attribute (optional).
__call__(*args)[source]

Return text joined by sequence and normal.

Raises:TypeError – Not a string type
Return type:str
Returns:Arguments wrapped in 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:

>>> from blessed import Terminal
>>> term = Terminal()
>>> 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).
  • target (str) – capability name for callable, eg ('x' + term.right(99)).
__call__(*args)[source]

Return text by target.

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
Returns:List of formating string segments
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.

is_sequence

Whether the value represents a multibyte sequence (bool).

name

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

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 keys 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
Returns:Dictionary of sequences term._cuf1, and term._cub1, valued as KEY_RIGHT, KEY_LEFT (when appropriate).

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

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().

Raises:ValueErrorself.width is not a positive integer
Return type:list
Returns:text chunks adjusted for width

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 (str) – 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 left-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, left-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'コンニチハ')
>>> Sequence(msg, term).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
Returns:string of sequences with leading and trailing whitespace removed.
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
Returns:string of sequences with leading removed.
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
Returns:string of sequences with trailing removed.
strip_seqs()[source]

Return text stripped of only its terminal sequences.

Return type:str
Returns:Text with terminal sequences removed
padd(strip=False)[source]

Return non-destructive horizontal movement as destructive spacing.

Parameters:strip (bool) – Strip terminal sequences
Return type:str
Returns:Text adjusted for horizontal movement
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
Returns:Length of the first sequence in the string

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.

kind

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

Return type:str
does_styling

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

Return type:bool
is_a_tty

Read-only property: Whether stream is a terminal.

Return type:bool
height

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

Return type:int
width

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

Return type:int
pixel_height

Read-only property: Height ofthe terminal (in pixels).

Return type:int
pixel_width

Read-only property: Width of terminal (in pixels).

Return type:int
location(x=None, y=None)[source]

Context manager for temporarily moving the cursor.

Parameters:
  • x (int) – horizontal position, from left, 0, to right edge of screen, self.width - 1.
  • y (int) – vertical position, from top, 0, to bottom of screen, self.height - 1.
Returns:

a context manager.

Return type:

Iterator

Move the cursor to a certain position on entry, do any kind of I/O, and upon exit let you print stuff there, then return the cursor to its original position:

term = Terminal()
with term.location(y=0, x=0):
    for row_num in range(term.height-1):
        print('Row #{row_num}')
print(term.clear_eol + 'Back to 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.

Calls cannot be nested: only one should be entered at a time.

Note

The argument order (x, y) differs from the return value order (y, x) of get_location(), or argument order (y, x) of move(). This is for API Compaibility with the blessings library, sorry for the trouble!

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 (y, x). When a timeout is specified, always ensure the return value is checked for (-1, -1).

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 (y, x) return value matches the parameter order of the move_xy() capability. The following sequence should cause the cursor to not move at all:

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

And the following should assert True with a terminal:

>>> term = Terminal()
>>> given_y, given_x = 10, 20
>>> with term.location(y=given_y, x=given_x):
...     result_y, result_x = term.get_location()
...
>>> assert given_x == result_x, (given_x, result_x)
>>> assert given_y == result_y, (given_y, result_y)
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, from left, 0, to right edge of screen, self.width - 1.
  • y (int) – vertical position, from top, 0, to bottom of screen, self.height - 1.
Return type:

ParameterizingString

Returns:

Callable string that moves the cursor to the given coordinates

move_yx(y, x)[source]

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

Parameters:
  • y (int) – vertical position, from top, 0, to bottom of screen, self.height - 1.
  • x (int) – horizontal position, from left, 0, to right edge of screen, self.width - 1.
Return type:

ParameterizingString

Returns:

Callable string that moves the cursor to the given coordinates

move_left

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

move_right

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

move_up

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

move_down

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

color

A callable string that sets the foreground color.

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]

Provides callable formatting string to set foreground color to the specified RGB color.

Parameters:
  • red (int) – RGB value of Red.
  • green (int) – RGB value of Green.
  • blue (int) – RGB value of Blue.
Return type:

FormattingString

Returns:

Callable string that sets the foreground color

If the terminal does not support RGB color, the nearest supported color will be determined using color_distance_algorithm.

on_color

A callable capability that sets the background color.

Return type:ParameterizingString
on_color_rgb(red, green, blue)[source]

Provides callable formatting string to set background color to the specified RGB color.

Parameters:
  • red (int) – RGB value of Red.
  • green (int) – RGB value of Green.
  • blue (int) – RGB value of Blue.
Return type:

FormattingString

Returns:

Callable string that sets the foreground color

If the terminal does not support RGB color, the nearest supported color will be determined using color_distance_algorithm.

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

Returns:

Color code of downconverted RGB color

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.

Display text that when touched or clicked, navigates to url.

Optional url_id may be specified, so that non-adjacent cells can reference a single target, all cells painted with the same “id” will highlight on hover, rather than any individual one, as described in “Hovering and underlining the id parameter” of gist https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda.

Parameters:
  • url (str) – Hyperlink URL.
  • text (str) – Clickable text.
  • url_id (str) – Optional ‘id’.
Return type:

str

Returns:

String of text as a hyperlink to url.

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().

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.

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

Returns:

String of text, left-aligned by width.

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

Returns:

String of text, right-aligned by width.

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

Returns:

String of text, centered by width

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
Returns:Text with leading and trailing whitespace removed
>>> 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
Returns:Text with terminal sequences and trailing whitespace removed
>>> 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
Returns:Text with terminal sequences and leading whitespace removed
>>> term.lstrip(u' \x1b[0;3m xyz ')
u'xyz '
strip_seqs(text)[source]

Return text stripped of only its terminal sequences.

Return type:str
Returns:Text with terminal sequences removed
>>> 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:
  • text (str) – String containing sequences
  • kwds – remaining keyword arguments for re.split().
Return type:

list[str]

Returns:

List of sequences and individual characters

>>> 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.
  • kwargs – See textwrap.TextWrapper
Return type:

list

Returns:

List of wrapped lines

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:text (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

Project

Bugs or suggestions? Visit the issue tracker and file an issue. We welcome your bug reports and feature suggestions!

Are you stuck and need support? Give stackoverflow a try. If you’re still having trouble, we’d like to hear about it! Open an issue in the issue tracker with a well-formed question.

Would you like to contribute? That’s awesome! Pull Requests are always welcome!

Fork

Blessed is a fork of blessings. Apologies for the fork, I just couldn’t get the Keyboard, and later Location or Measuring code accepted upstream after two major initiatives, the effort was better spent in a fork, where the code is accepted.

Furthermore, a project in the node.js language of the same name, blessed, is not related, or a fork of each other in any way.

License

Blessed is under the MIT License. See the LICENSE file. Please enjoy!

Running Tests

Install and run tox:

pip install --upgrade tox
tox

Py.test is used as the test runner, and with the tox target supporting positional arguments, you may for example use looponfailing with python 3.7, stopping at the first failing test case, and looping (retrying) after a filesystem save is detected:

tox -epy37 -- -fx

The test runner (tox) ensures all code and documentation complies with standard python style guides, pep8 and pep257, as well as various static analysis tools.

Warning

When you contribute a new feature, make sure it is covered by tests.

Likewise, some bug fixes should include a test demonstrating the bug.

Further Reading

As a developer’s API, blessed is often bundled with frameworks and toolsets that dive deeper into Terminal I/O programming than Terminal offers. Here are some recommended readings to help you along:

  • The terminfo(5) manpage of your preferred posix-like operating system. The capabilities available as attributes of Terminal are directly mapped to those listed in the column Cap-name.

  • The termios(3) of your preferred posix-like operating system.

  • The TTY demystified by Linus Åkesson.

  • A Brief Introduction to Termios by Nelson Elhage.

  • Richard Steven’s Advance Unix Programming (“AUP”) provides two very good chapters, “Terminal I/O” and “Pseudo Terminals”.

  • GNU’s The Termcap Manual by Richard M. Stallman.

  • Chapter 4 of CUNY’s course material for Introduction to System Programming, by Stewart Weiss

  • Chapter 11 of the IEEE Open Group Base Specifications Issue 7, “General Terminal Interface”

  • The GNU C Library documentation, section Low-Level Terminal Interface

  • The source code of many popular terminal emulators. If there is ever any question of “the meaning of a terminal capability”, or whether or not your preferred terminal emulator actually handles them, read the source! Many modern terminal emulators are now based on libvte.

  • The source code of the tty(4), pty(7), and the given “console driver” for any posix-like operating system. If you search thoroughly enough, you will eventually discover a terminal sequence decoder, usually a case switch that translates \x1b[0m into a “reset color” action towards the video driver. Though tty.c linked here is probably not the most interesting, it can get you started:

  • Thomas E. Dickey has been maintaining xterm, as well as a primary maintainer of many related packages such as ncurses for quite a long while. His consistent, well-documented, long-term dedication to xterm, curses, and the many related projects is world-renown.

  • termcap & terminfo (O’Reilly Nutshell) by Linda Mui, Tim O’Reilly, and John Strang.

  • Note that System-V systems, also known as Unix98 (SunOS, HP-UX, AIX and others) use a Streams interface. On these systems, the ioctl(2) interface provides the PUSH and POP parameters to communicate with a Streams device driver, which differs significantly from Linux and BSD.

    Many of these systems provide compatible interfaces for Linux, but they may not always be as complete as the counterpart they emulate, most especially in regards to managing pseudo-terminals.

The misnomer of ANSI

When people say ‘ANSI’, they are discussing:

  • Standard ECMA-48: Control Functions for Coded Character Sets
  • ANSI X3.64 from 1981, when the American National Standards Institute adopted the ECMA-48 as standard, which was later withdrawn in 1997 (so in this sense it is not an ANSI standard).
  • The ANSI.SYS driver provided in MS-DOS and clones. The popularity of the IBM Personal Computer and MS-DOS of the era, and its ability to display colored text further populated the idea that such text “is ANSI”.
  • The various code pages used in MS-DOS Personal Computers, providing “block art” characters in the 8th bit (int 127-255), paired with ECMA-48 sequences supported by the MS-DOS ANSI.SYS driver to create artwork, known as ANSI art.
  • The ANSI terminal database entry and its many descendants in the terminfo database. This is mostly due to terminals compatible with SCO UNIX, which was the successor of Microsoft’s Xenix, which brought some semblance of the Microsoft DOS ANSI.SYS driver capabilities.
  • Select Graphics Rendition (SGR) on vt100 clones, which include many of the common sequences in ECMA-48.
  • Any sequence started by the Control-Sequence-Inducer is often mistakenly termed as an “ANSI Escape Sequence” though not appearing in ECMA-48 or interpreted by the ANSI.SYS driver. The adjoining phrase “Escape Sequence” is so termed because it follows the ASCII character for the escape key (ESC, \x1b).

Version History

1.17
  • introduced: Hyperlinks, method link(), #116.
  • introduced: 24-bit color support, detected by term.number_of_colors == 1 << 24, and 24-bit color foreground method color_rgb() and background method on_color_rgb(), as well as 676 common X11 color attribute names are now possible, such as term.aquamarine_on_wheat, #60.
  • introduced: term.move_xy, recommended over built-in move capability, as the argument order, (x, y) matches the return value of get_location(), and all other common graphics library calls, #65.
  • introduced: move_up(), move_down(), Terminal.move_left(), move_right() which are strings that move the cursor one cell in the respective direction, are now also callables for moving n cells to the given direction, such as term.move_right(9).
  • introduced: pixel_width and pixel_height for libsixel support or general curiosity.
  • bugfix: prevent ValueError: I/O operation on closed file on sys.stdin in multiprocessing environments, where the keyboard wouldn’t work, anyway.
  • bugfix: prevent error condition, ValueError: underlying buffer has been detached in rare conditions where sys.__stdout__ has been detached in test frameworks. #126.
  • bugfix: off-by-one error in get_location(), now accounts for %i in cursor_report, #94.
  • bugfix split_seqs() and related functions failed to match when the color index was greater than 15, #101.
  • bugfix: Context Managers, fullscreen(), hidden_cursor(), and keypad() now flush the stream after writing their sequences.
  • bugfix: chr(127), \x7f has changed from keycode term.DELETE to the more common match, term.BACKSPACE, :ghissue:115` by jwezel.
  • bugfix: ensure FormattingOtherString may be pickled.
  • deprecated: the curses move() capability is no longer recommended, suggest to use move_xy(), which matches the return value of get_location().
  • deprecated: superscript, subscript, shadow, and dim are no longer “compoundable” with colors, such as in phrase Terminal.blue_subscript('a'). These attributes are not typically supported, anyway. Use Unicode text or 256 or 24-bit color codes instead.
  • deprecated: additional key names, such as KEY_TAB, are no longer “injected” into the curses module namespace.
  • bugfix: briefly tried calling curses.setupterm() with os.devnull as the file descriptor, reverted. #59.
  • deprecated: inkey() no longer raises RuntimeError when stream is not a terminal, programs using inkey() to block indefinitely if a keyboard is not attached. #69.
  • deprecated: using argument _intr_continue to method kbhit(), behavior is as though such value is always True since 1.9.
1.16
1.15
  • enhancement: disable timing integration tests for keyboard routines.
  • enhancement: Support python 3.7. PR #102.
  • enhancement: Various fixes to test automation PR #108
1.14
  • bugfix: wrap() misbehaved for text containing newlines, #74.
  • bugfix: TypeError when using PYTHONOPTIMIZE=2 environment variable, #84.
  • bugfix: define blessed.__version__ value, #92.
  • bugfix: detect sequences \x1b[0K and \x1b2K, #95.
1.13
  • enhancement: split_seqs() introduced, and 4x cost reduction in related sequence-aware functions, #29.
  • deprecated: blessed.sequences.measure_length function superseded by iter_parse() if necessary.
  • deprecated: warnings about “binary-packed capabilities” are no longer emitted on strange terminal types, making best effort.
1.12
  • enhancement: get_location() returns the (row, col) position of the cursor at the time of call for attached terminal.
  • enhancement: a keyboard now detected as stdin when stream is sys.stderr.
1.11
  • enhancement: inkey() can return more quickly for combinations such as Alt + Z when MetaSendsEscape is enabled, #30.
  • enhancement: FormattingString may now be nested, such as t.red('red', t.underline('rum')), #61
1.10
  • workaround: provide sc and rc for Terminals of kind='ansi', repairing location() #44.
  • bugfix: length of simple SGR reset sequence \x1b[m was not correctly determined on all terminal types, #45.
  • deprecated: _intr_continue arguments introduced in 1.8 are now marked deprecated in 1.10: beginning with python 3.5, the default behavior is as though this argument is always True, PEP-475, blessed does the same.
1.9
  • enhancement: break_long_words now supported by Terminal.wrap()
  • Ignore curses.error message 'tparm() returned NULL': this occurs on win32 or other platforms using a limited curses implementation, such as PDCurses, where curses.tparm() is not implemented, or no terminal capability database is available.
  • Context manager keypad() emits sequences that enable “application keys” such as the diagonal keys on the numpad. This is equivalent to curses.window.keypad().
  • bugfix: translate keypad application keys correctly.
  • enhancement: no longer depend on the ‘2to3’ tool for python 3 support.
  • enhancement: allow civis and cnorm (hide_cursor, normal_hide) to work with terminal-type ansi by emulating support by proxy.
  • enhancement: new public attribute: kind: the very same as given Terminal.__init__.kind keyword argument. Or, when not given, determined by and equivalent to the TERM Environment variable.
1.8
  • enhancement: export keyboard-read function as public method getch(), so that it may be overridden by custom terminal implementers.
  • enhancement: allow inkey() and kbhit() to return early when interrupted by signal by passing argument _intr_continue=False.
  • enhancement: allow hpa and vpa (move_x, move_y) to work on tmux(1) or screen(1) by emulating support by proxy.
  • enhancement: add rstrip() and lstrip(), strips both sequences and trailing or leading whitespace, respectively.
  • enhancement: include wcwidth library support for length(): the printable width of many kinds of CJK (Chinese, Japanese, Korean) ideographs and various combining characters may now be determined.
  • enhancement: better support for detecting the length or sequences of externally-generated ecma-48 codes when using xterm or aixterm.
  • bugfix: when locale.getpreferredencoding() returns empty string or an encoding that is not valid for codecs.getincrementaldecoder, fallback to ASCII and emit a warning.
  • bugfix: ensure FormattingString and ParameterizingString may be pickled.
  • bugfix: allow ~.inkey and related to be called without a keyboard.
  • change: term.keyboard_fd is set None if stream or sys.stdout is not a tty, making term.inkey(), term.cbreak(), term.raw(), no-op.
  • bugfix: \x1bOH (KEY_HOME) was incorrectly mapped as KEY_LEFT.
1.7
  • Forked github project erikrose/blessings to jquast/blessed, this project was previously known as blessings version 1.6 and prior.
  • introduced: context manager cbreak(), which is equivalent to entering terminal state by tty.setcbreak() and returning on exit, as well as the lesser recommended raw(), pairing from tty.setraw().
  • introduced: inkey(), which will return one or more characters received by the keyboard as a unicode sequence, with additional attributes code and name. This allows application keys (such as the up arrow, or home key) to be detected. Optional value timeout allows for timed poll.
  • introduced: center(), rjust(), ljust(), allowing text containing sequences to be aligned to detected horizontal screen width, or by width specified.
  • introduced: wrap() method. Allows text containing sequences to be word-wrapped without breaking mid-sequence, honoring their printable width.
  • introduced: strip(), strips all sequences and whitespace.
  • introduced: strip_seqs() strip only sequences.
  • introduced: rstrip() and lstrip() strips both sequences and trailing or leading whitespace, respectively.
  • bugfix: cannot call curses.setupterm() more than once per process (from Terminal.__init__()): Previously, blessed pretended to support several instances of different Terminal kind, but was actually using the kind specified by the first instantiation of Terminal. A warning is now issued. Although this is misbehavior is still allowed, a warnings.WarningMessage is now emitted to notify about subsequent terminal misbehavior.
  • bugfix: resolved issue where number_of_colors fails when does_styling is False. Resolves issue where piping tests output would fail.
  • bugfix: warn and set does_styling to False when the given kind is not found in the terminal capability database.
  • bugfix: allow unsupported terminal capabilities to be callable just as supported capabilities, so that the return value of color(n) may be called on terminals without color capabilities.
  • bugfix: for terminals without underline, such as vt220, term.underline('text') would emit 'text' + term.normal. Now it emits only 'text'.
  • enhancement: some attributes are now properties, raise exceptions when assigned.
  • enhancement: pypy is now a supported python platform implementation.
  • enhancement: removed pokemon curses.error exceptions.
  • enhancement: do not ignore curses.error exceptions, unhandled curses errors are legitimate errors and should be reported as a bug.
  • enhancement: converted nose tests to pytest, merged travis and tox.
  • enhancement: pytest fixtures, paired with a new @as_subprocess decorator are used to test a multitude of terminal types.
  • enhancement: test accessories @as_subprocess resolves various issues with different terminal types that previously went untested.
  • deprecation: python2.5 is no longer supported (as tox does not supported).
1.6
  • Add does_styling. This takes force_styling into account and should replace most uses of is_a_tty.
  • Make is_a_tty a read-only property like does_styling. Writing to it never would have done anything constructive.
  • Add fullscreen`() and hidden_cursor() to the auto-generated docs.
1.5.1
  • Clean up fabfile, removing the redundant test command.
  • Add Travis support.
  • Make python setup.py test work without spurious errors on 2.6.
  • Work around a tox parsing bug in its config file.
  • Make context managers clean up after themselves even if there’s an exception (Vitja Makarov #29 <https://github.com/erikrose/blessings/pull/29>).
  • Parameterizing a capability no longer crashes when there is no tty (<Vitja Makarov #31 <https://github.com/erikrose/blessings/pull/31>)
1.5
  • Add syntactic sugar and documentation for enter_fullscreen and exit_fullscreen.
  • Add context managers fullscreen() and hidden_cursor().
  • Now you can force a Terminal to never to emit styles by passing keyword argument force_styling=None.
1.4
  • Add syntactic sugar for cursor visibility control and single-space-movement capabilities.
  • Endorse the location() context manager for restoring cursor position after a series of manual movements.
  • Fix a bug in which location() that wouldn’t do anything when passed zeros.
  • Allow tests to be run with python setup.py test.
1.3
  • Added number_of_colors, which tells you how many colors the terminal supports.
  • Made color(n) and on_color(n) callable to wrap a string, like the named colors can. Also, make them both fall back to the setf and setb capabilities (like the named colors do) if the termcap entries for setaf and setab are not available.
  • Allowed color to act as an unparametrized string, not just a callable.
  • Made height and width examine any passed-in stream before falling back to stdout (This rarely if ever affects actual behavior; it’s mostly philosophical).
  • Made caching simpler and slightly more efficient.
  • Got rid of a reference cycle between Terminal and FormattingString.
  • Updated docs to reflect that terminal addressing (as in location()) is 0-based.
1.2
  • Added support for Python 3! We need 3.2.3 or greater, because the curses library couldn’t decide whether to accept strs or bytes before that (https://bugs.python.org/issue10570).
  • Everything that comes out of the library is now unicode. This lets us support Python 3 without making a mess of the code, and Python 2 should continue to work unless you were testing types (and badly). Please file a bug if this causes trouble for you.
  • Changed to the MIT License for better world domination.
  • Added Sphinx docs.
1.1
  • Added nicely named attributes for colors.
  • Introduced compound formatting.
  • Added wrapper behavior for styling and colors.
  • Let you force capabilities to be non-empty, even if the output stream is not a terminal.
  • Added is_a_tty to determine whether the output stream is a terminal.
  • Sugared the remaining interesting string capabilities.
  • Allow location() to operate on just an x or y coordinate.
1.0