This documentation is for an old version of IPython. You can find docs for newer versions here.

Module: qt.console.ansi_code_processor

Utilities for processing ANSI escape codes and special ASCII characters.

2 Classes

class IPython.qt.console.ansi_code_processor.AnsiCodeProcessor

Bases: object

Translates special ASCII characters and ANSI escape codes into readable attributes. It also supports a few non-standard, xterm-specific codes.


Reset graphics attributs to their default values.

set_csi_code(command, params=[])

Set attributes based on CSI (Control Sequence Introducer) code.


command : str

The code identifier, i.e. the final character in the sequence.

params : sequence of integers, optional

The parameter codes for the command.


Set attributes based on OSC (Operating System Command) parameters.


params : sequence of str

The parameters for the command.


Set attributes based on SGR (Select Graphic Rendition) codes.


params : sequence of ints

A list of SGR codes for one or more SGR commands. Usually this sequence will have one element per command, although certain xterm-specific commands requires multiple elements.


Yields substrings for which the same escape code applies.

class IPython.qt.console.ansi_code_processor.QtAnsiCodeProcessor

Bases: IPython.qt.console.ansi_code_processor.AnsiCodeProcessor

Translates ANSI escape codes into QTextCharFormats.

get_color(color, intensity=0)

Returns a QColor for a given color code, or None if one cannot be constructed.


Returns a QTextCharFormat that encodes the current style attributes.


Given a background color (a QColor), attempt to set a color map that will be aesthetically pleasing.