fitzzftw.patch.base¶
base¶
This module provides the core visual and behavioral foundations for the fitzzftw patch framework, focusing on terminal output and protocol safety.
Core Features:¶
TerminalColorMixin: A reusable component that adds ANSI color support to any class. It includes a global toggle (
use_colors) and a specialized Test-Mode for predictable assertions in automated environments.Protocol-Enforced Printing: The
print()method validates the host class against theLineLikeprotocol. If requirements (like prefix, orig_line, or _color_map) are missing, it raises a detailedFtwProtocolErrorwith implementation guidance.Visual Diagnostics: Includes
color_terminal_check(), a utility to verify ANSI support and semantic color mapping directly from the CLI.
The module ensures that terminal output is not only visually rich but also structurally sound and testable.
Classes
Provides colorization capabilities for CLI output. |
Functions
Performs a visual diagnostic of ANSI color support in the current terminal. |
- color_terminal_check()[source]¶
Performs a visual diagnostic of ANSI color support in the current terminal.
This function prints a structured test pattern showcasing ‘green’, ‘red’, and ‘cyan’ in both standard and bold variations. It then repeats the pattern with colors disabled to verify the fallback mechanism.
Usage via CLI:
$ ftw-terminal-colorVisual Output: - A header ‘Visual Terminal Color Check’ centered in a 39-character block. - An ‘Enabled’ row showing colorized and bold tags. - A ‘Disabled’ row showing plain text tags.