ticterm.esc

Classes

class ticterm.esc.Style(value, value_off='\\x1b[m')

Terminal escape code style

Parameters:
  • value (str) – Escape sequence to enable style

  • value_off (str) – Escape sequence to disable style

static combine(*styles)

Combines multiple Style objects into one.

Return type:

Self

add(*styles)

Combines self with all styles

Return type:

Self

replace_normal(item)

Replaces all instances of ticterm.esc.color.normal in items.

Parameters:
  • style

  • items

Return type:

str

replace_normal_many(items)

Maps Style.replace_normal() to items iterable

Parameters:

items (iter)

Return type:

map

wrap(item)

Wraps str(item) with value and value_off (if available)

Parameters:

item (str | Any)

Return type:

str

wrap_many(items)

Maps Style.wrap() to items iterable

Parameters:

items (iter)

Return type:

map

value: str
value_off: str

ticterm.esc.color

Constants

ticterm.esc.color.color_names: list[str] = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']

List of color names.

ticterm.esc.color.color_bright_map: dict[str, str] = {'brblack': 'black', 'brblue': 'blue', 'brcyan': 'cyan', 'brgreen': 'green', 'brmagenta': 'magenta', 'brred': 'red', 'brwhite': 'white', 'bryellow': 'yellow'}

List of color names prepended with ‘br’ mapped to their non-bright counterparts.

ticterm.esc.color.color_map: dict[str, int] = {'black': 30, 'blue': 34, 'cyan': 36, 'green': 32, 'magenta': 35, 'red': 31, 'white': 37, 'yellow': 33}

Map of color names to their ansi escape code ids.

Color Constants

ticterm.esc.color.black
ticterm.esc.color.red
ticterm.esc.color.green
ticterm.esc.color.yellow
ticterm.esc.color.blue
ticterm.esc.color.magenta
ticterm.esc.color.cyan
ticterm.esc.color.white
ticterm.esc.color.brblack
ticterm.esc.color.brred
ticterm.esc.color.brgreen
ticterm.esc.color.bryellow
ticterm.esc.color.brblue
ticterm.esc.color.brmagenta
ticterm.esc.color.brcyan
ticterm.esc.color.brwhite

Functions

ticterm.esc.color.get(color, *, bg=False)

Get color or style from input. Accepts Style objects, ansi color ids, or names.

Parameters:
  • color (Style | int | str)

  • bg (bool) – Should background color escape code be returned instead of foreground?

Return type:

Style

ticterm.esc.color.replace_normal(style, *items)

Replaces all instances of normal in items.

Parameters:
  • style (Style | int | str)

  • items (str)

Return type:

list[str] | str

ticterm.esc.style

Style Constants

ticterm.esc.style.bold
ticterm.esc.style.dim
ticterm.esc.style.italic
ticterm.esc.style.underline
ticterm.esc.style.blinking
ticterm.esc.style.inverse