fitzzftw.patch.static.Color

class Color[source]

Bases: object

Internal class for color and style management in terminal output.

Controls whether ANSI escape sequences, plain text, or semantic tags (test mode) are returned. This class should not be instantiated directly; use the provided ‘colors’ instance instead.

Public Data Attributes:

mode

Get or set the current output mode.

defined_colors

defined_keys

RED

The ANSI sequence or marker for red.

GREEN

The ANSI sequence or marker for green.

YELLOW

The ANSI sequence or marker for dark yellow.

CYAN

The ANSI sequence or marker for cyan.

RESET

The ANSI sequence or marker to reset styling.

BOLD

The ANSI sequence or marker for bold text.

TERMINAL

The ANSI sequence or marker for terminal color.

Public Methods:

__init__()

Initializes the color manager with default mode 'NORMAL'.

switch_to_testmode([enabled])

Convenience method to toggle between TEST and NORMAL mode.

__getitem__(key)

Enables dictionary-like access for style names.

get(color[, default])

Get a color value by key with a fallback default.

Private Data Attributes:

_VALID_MODES

_mode

Private Methods:

_get_value(name)

Returns the appropriate string representation for a style name based on the current mode.


property BOLD: str

The ANSI sequence or marker for bold text.

Returns:

Bold style string.

property CYAN: str

The ANSI sequence or marker for cyan.

Returns:

Cyan style string.

Return type:

str

property GREEN: str

The ANSI sequence or marker for green.

Returns:

Green style string.

property RED: str

The ANSI sequence or marker for red.

Returns:

Red style string.

property RESET: str

The ANSI sequence or marker to reset styling.

Returns:

Reset style string.

Return type:

str

property TERMINAL: str

The ANSI sequence or marker for terminal color.

Returns:

Terminal style string.

Return type:

str

property YELLOW: str

The ANSI sequence or marker for dark yellow.

__init__()[source]

Initializes the color manager with default mode ‘NORMAL’.

get(color, default=None)[source]

Get a color value by key with a fallback default.

Parameters:
  • key – The name of the color (e.g., ‘red’).

  • default (_T) – The value to return if the key is not found.

Returns:

The color string or the default value.

Return type:

_T | str

property mode: 'NORMAL' | 'PLAIN' | 'TEST'

Get or set the current output mode.

Returns:

The current mode (‘NORMAL’, ‘PLAIN’, or ‘TEST’).

Raises:

ValueError – If the assigned mode is not in allowed.

switch_to_testmode(enabled=True)[source]

Convenience method to toggle between TEST and NORMAL mode.

Parameters:

enabled (bool) – If True, sets mode to ‘TEST’, otherwise to ‘NORMAL’.