feat(theme): Add theme system with ACTIVE_THEME support
- Add Theme class and THEME_REGISTRY to engine/themes.py - Add set_active_theme() function to config.py - Add msg_gradient() function to use theme-based message gradients - Support --theme CLI flag to select theme (green, orange, purple) - Initialize theme on module load with fallback to default
This commit is contained in:
@@ -132,6 +132,7 @@ class Config:
|
||||
display: str = "pygame"
|
||||
websocket: bool = False
|
||||
websocket_port: int = 8765
|
||||
theme: str = "green"
|
||||
|
||||
@classmethod
|
||||
def from_args(cls, argv: list[str] | None = None) -> "Config":
|
||||
@@ -175,6 +176,7 @@ class Config:
|
||||
display=_arg_value("--display", argv) or "terminal",
|
||||
websocket="--websocket" in argv,
|
||||
websocket_port=_arg_int("--websocket-port", 8765, argv),
|
||||
theme=_arg_value("--theme", argv) or "green",
|
||||
)
|
||||
|
||||
|
||||
@@ -246,6 +248,40 @@ DEMO = "--demo" in sys.argv
|
||||
DEMO_EFFECT_DURATION = 5.0 # seconds per effect
|
||||
PIPELINE_DEMO = "--pipeline-demo" in sys.argv
|
||||
|
||||
# ─── THEME MANAGEMENT ─────────────────────────────────────────
|
||||
ACTIVE_THEME = None
|
||||
|
||||
|
||||
def set_active_theme(theme_id: str = "green"):
|
||||
"""Set the active theme by ID.
|
||||
|
||||
Args:
|
||||
theme_id: Theme identifier from theme registry (e.g., "green", "orange", "purple")
|
||||
|
||||
Raises:
|
||||
KeyError: If theme_id is not in the theme registry
|
||||
|
||||
Side Effects:
|
||||
Sets the ACTIVE_THEME global variable
|
||||
"""
|
||||
global ACTIVE_THEME
|
||||
from engine import themes
|
||||
|
||||
ACTIVE_THEME = themes.get_theme(theme_id)
|
||||
|
||||
|
||||
# Initialize theme on module load (lazy to avoid circular dependency)
|
||||
def _init_theme():
|
||||
theme_id = _arg_value("--theme", sys.argv) or "green"
|
||||
try:
|
||||
set_active_theme(theme_id)
|
||||
except KeyError:
|
||||
pass # Theme not found, keep None
|
||||
|
||||
|
||||
_init_theme()
|
||||
|
||||
|
||||
# ─── PIPELINE MODE (new unified architecture) ─────────────
|
||||
PIPELINE_MODE = "--pipeline" in sys.argv
|
||||
PIPELINE_PRESET = _arg_value("--pipeline-preset", sys.argv) or "demo"
|
||||
@@ -256,6 +292,9 @@ PRESET = _arg_value("--preset", sys.argv)
|
||||
# ─── PIPELINE DIAGRAM ────────────────────────────────────
|
||||
PIPELINE_DIAGRAM = "--pipeline-diagram" in sys.argv
|
||||
|
||||
# ─── THEME ──────────────────────────────────────────────────
|
||||
THEME = _arg_value("--theme", sys.argv) or "green"
|
||||
|
||||
|
||||
def set_font_selection(font_path=None, font_index=None):
|
||||
"""Set runtime primary font selection."""
|
||||
|
||||
Reference in New Issue
Block a user