fitzzftw.patch.static.Color¶
- class Color[source]¶
Bases:
objectInternal 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:
Get or set the current output mode.
defined_colorsdefined_keysThe ANSI sequence or marker for red.
The ANSI sequence or marker for green.
The ANSI sequence or marker for dark yellow.
The ANSI sequence or marker for cyan.
The ANSI sequence or marker to reset styling.
The ANSI sequence or marker for bold text.
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_modePrivate Methods:
_get_value(name)Returns the appropriate string representation for a style name based on the current mode.
- property RESET: str¶
The ANSI sequence or marker to reset styling.
- Returns:
Reset style string.
- Return type:
- property TERMINAL: str¶
The ANSI sequence or marker for terminal color.
- Returns:
Terminal style string.
- Return type:
- 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.