diff --git a/mainline.py b/mainline.py index 128721b..c377492 100755 --- a/mainline.py +++ b/mainline.py @@ -826,6 +826,7 @@ def stream(items): MSG_COLOR = "\033[1;38;5;87m" # sky cyan MSG_META = "\033[38;5;245m" # cool grey MSG_BORDER = "\033[2;38;5;37m" # dim teal + _msg_cache = (None, None) # (cache_key, rendered_rows) while queued < HEADLINE_LIMIT or active: t0 = time.monotonic() @@ -846,11 +847,16 @@ def stream(items): if msg_active: # ── MESSAGE state: freeze scroll, render message ── buf = [] - # Render message text with OTF font + # Render message text with OTF font (cached across frames) display_text = m_body or m_title or "(empty)" display_text = re.sub(r"\s+", " ", display_text.upper()) - msg_rows = _big_wrap(display_text, w - 4) - msg_rows = _lr_gradient(msg_rows) + cache_key = (display_text, w) + if _msg_cache[0] != cache_key: + msg_rows = _big_wrap(display_text, w - 4) + msg_rows = _lr_gradient(msg_rows) + _msg_cache = (cache_key, msg_rows) + else: + msg_rows = _msg_cache[1] # Center vertically in scroll zone total_h = len(msg_rows) + 4 # +4 for border + meta + padding y_off = max(0, (sh - total_h) // 2)