class documentation

class Terminal256Formatter(Formatter):

Known subclasses: pygments.formatters.terminal256.TerminalTrueColorFormatter

View In Hierarchy

Format tokens with ANSI color sequences, for output in a 256-color terminal or console. Like in TerminalFormatter color sequences are terminated at newlines, so that paging the output works correctly.

The formatter takes colors from a style defined by the style option and converts them to nearest ANSI 256-color escape sequences. Bold and underline attributes from the style are preserved (and displayed).

New in version 0.9.
Changed in version 2.2: If the used style defines foreground colors in the form #ansi*, then Terminal256Formatter will map these to non extended foreground color. See :ref:`AnsiTerminalStyle` for more information.
Changed in version 2.4: The ANSI color names have been updated with names that are easier to understand and align with colornames of other projects and terminals. See :ref:`this table <new-ansi-color-names>` for more information.

Options accepted:

style
The style to use, can be a string or a Style subclass (default: 'default').
linenos
Set to True to have line numbers on the terminal output as well (default: False = no line numbers).
Method __init__ Undocumented
Method ​_build​_color​_table Undocumented
Method ​_closest​_color Undocumented
Method ​_color​_index Undocumented
Method ​_setup​_styles Undocumented
Method ​_write​_lineno Undocumented
Method format Format tokensource, an iterable of (tokentype, tokenstring) tuples and write it into outfile.
Method format​_unencoded Undocumented
Class Variable aliases Undocumented
Class Variable filenames Undocumented
Class Variable name Undocumented
Instance Variable ​_lineno Undocumented
Instance Variable best​_match Undocumented
Instance Variable linenos Undocumented
Instance Variable style​_string Undocumented
Instance Variable usebold Undocumented
Instance Variable useitalic Undocumented
Instance Variable useunderline Undocumented
Instance Variable xterm​_colors Undocumented

Inherited from Formatter:

Method get​_style​_defs Return the style definitions for the current style as a string.
Class Variable unicodeoutput Undocumented
Instance Variable encoding Undocumented
Instance Variable full Undocumented
Instance Variable options Undocumented
Instance Variable style Undocumented
Instance Variable title Undocumented
def __init__(self, **options):

Undocumented

def _build_color_table(self):
def _closest_color(self, r, g, b):

Undocumented

def _color_index(self, color):

Undocumented

def _setup_styles(self):
def _write_lineno(self, outfile):

Undocumented

def format(self, tokensource, outfile):
Format tokensource, an iterable of (tokentype, tokenstring) tuples and write it into outfile.
def format_unencoded(self, tokensource, outfile):

Undocumented

_lineno: int =

Undocumented

best_match: dict =

Undocumented

linenos =

Undocumented

style_string: dict =

Undocumented

usebold =

Undocumented

useitalic =

Undocumented

useunderline =

Undocumented

xterm_colors: list =

Undocumented