forked from genewildish/Mainline
feat: update scroll.py to use theme message gradient
Add msg_gradient() helper function to render.py that applies message (ntfy) gradient using the active theme's message_gradient property. This replaces hardcoded magenta gradient in scroll.py with a theme-aware approach that uses complementary colors from the active theme. - Add msg_gradient(rows, offset) helper in render.py with fallback to default magenta gradient when no theme is active - Update scroll.py imports to use msg_gradient instead of lr_gradient_opposite - Replace lr_gradient_opposite() call with msg_gradient() in message overlay rendering - Add 6 comprehensive tests for msg_gradient covering theme usage, fallback behavior, and edge cases All tests pass (121 passed), no regressions detected. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -254,6 +254,29 @@ def lr_gradient_opposite(rows, offset=0.0):
|
||||
return lr_gradient(rows, offset, _default_magenta_gradient())
|
||||
|
||||
|
||||
def msg_gradient(rows, offset):
|
||||
"""Apply message (ntfy) gradient using theme complementary colors.
|
||||
|
||||
Returns colored rows using ACTIVE_THEME.message_gradient if available,
|
||||
falling back to default magenta if no theme is set.
|
||||
|
||||
Args:
|
||||
rows: List of text strings to colorize
|
||||
offset: Gradient offset (0.0-1.0) for animation
|
||||
|
||||
Returns:
|
||||
List of rows with ANSI color codes applied
|
||||
"""
|
||||
from engine import config
|
||||
|
||||
cols = (
|
||||
_color_codes_to_ansi(config.ACTIVE_THEME.message_gradient)
|
||||
if config.ACTIVE_THEME
|
||||
else _default_magenta_gradient()
|
||||
)
|
||||
return lr_gradient(rows, offset, cols)
|
||||
|
||||
|
||||
# ─── HEADLINE BLOCK ASSEMBLY ─────────────────────────────
|
||||
def make_block(title, src, ts, w):
|
||||
"""Render a headline into a content block with color."""
|
||||
|
||||
@@ -18,7 +18,7 @@ from engine.effects import (
|
||||
noise,
|
||||
vis_trunc,
|
||||
)
|
||||
from engine.render import big_wrap, lr_gradient, lr_gradient_opposite, make_block
|
||||
from engine.render import big_wrap, lr_gradient, msg_gradient, make_block
|
||||
from engine.terminal import CLR, RST, W_COOL, th, tw
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ def stream(items, ntfy_poller, mic_monitor):
|
||||
_msg_cache = (cache_key, msg_rows)
|
||||
else:
|
||||
msg_rows = _msg_cache[1]
|
||||
msg_rows = lr_gradient_opposite(
|
||||
msg_rows = msg_gradient(
|
||||
msg_rows, (time.monotonic() * config.GRAD_SPEED) % 1.0
|
||||
)
|
||||
# Layout: rendered text + meta + border
|
||||
|
||||
Reference in New Issue
Block a user