Next: , Previous: , Up: Python API   [Contents][Index]


23.3.2.36 Python representation of colors

You can assign instance of gdb.Color to the value of a Parameter instance created with PARAM_COLOR.

gdb.Color may refer to an index from a color palette or contain components of a color from some color space.

Function: Color.__init__ ([value [, color_space]])

value is None (meaning the terminal’s default color), an integer index of a color in palette, tuple with color components or a string. String can be a hex RGB triplet in ‘#RRGGBB’ format or one of the following color names: ‘none’ (meaning the terminal’s default color), ‘black’, ‘red’, ‘green’, ‘yellow’, ‘blue’, ‘magenta’, ‘cyan’, or ‘white’.

color_space should be one of the ‘COLORSPACE_’ constants listed below. This argument tells GDB which color space value belongs.

Variable: Color.is_none

This attribute is boolean. If its value is True then color is terminal’s default.

Variable: Color.is_indexed

This attribute is boolean. If its value is True then color is indexed, i.e. belongs to some palette.

Variable: Color.is_direct

This attribute is boolean. If its value is True then this object describes direct colour in the sense of ISO/IEC 8613-6.

Variable: Color.index

This attribute exist if is_indexed is True. Its integer value is index of a color in a palette.

Variable: Color.components

This attribute exist if is_direct is True. Its value is tuple with integer components of a color.

Function: Color.escape_sequence (is_foreground)

Returns string to change terminal’s color to this.

If is_foreground is True, then the returned sequence will change foreground color. Otherwise, the returned sequence will change background color.

If styling is currently disabled (see set style enabled), then this method will return an empty string.

When color is initialized, its color space must be specified. The available color spaces are represented by constants defined in the gdb module:

gdb.COLORSPACE_MONOCHROME

Palette with only terminal’s default color.

gdb.COLORSPACE_ANSI_8COLOR

Palette with eight standard colors of ISO/IEC 6429 "black", "red", "green", etc.

gdb.COLORSPACE_AIXTERM_16COLOR

Palette with 16 colors. First eight are standard colors of ISO/IEC 6429 "black", "red", "green", etc. Next eight are their bright version.

gdb.COLORSPACE_XTERM_256COLOR

Palette with 256 colors. First 16 are from COLORSPACE_AIXTERM_16COLOR. Next 216 colors are 6x6x6 RGB cube. And last 24 colors form grayscale ramp.

gdb.COLORSPACE_RGB_24BIT

Direct 24-bit RGB colors.

It is not possible to sub-class the Color class.


Next: , Previous: , Up: Python API   [Contents][Index]