feat: Apply a distinct background color to firehose lines.

This commit is contained in:
2026-03-15 01:08:17 -07:00
parent b00b612da0
commit 0f762475b5

View File

@@ -15,9 +15,10 @@ from engine.render import big_wrap, lr_gradient, make_block
from engine.effects import noise, glitch_bar, fade_line, vis_trunc, next_headline, firehose_line
_ANSI_LINE_RE = re.compile(r"^(\033\[[0-9;]*m)(.*)(\033\[0m)$")
FIREHOSE_BG = "\033[48;5;233m"
def _overlay_segments(ansi_line):
def _overlay_segments(ansi_line, bg=""):
"""Return (1-indexed column, colored chunk) for non-space runs in a line."""
m = _ANSI_LINE_RE.match(ansi_line)
if m:
@@ -34,7 +35,10 @@ def _overlay_segments(ansi_line):
while j < len(text) and text[j] != " ":
j += 1
chunk = text[i:j]
segs.append((i + 1, f"{color}{chunk}{RST}" if color else chunk))
if bg or color:
segs.append((i + 1, f"{bg}{color}{chunk}{RST}"))
else:
segs.append((i + 1, chunk))
i = j
return segs
@@ -223,7 +227,9 @@ def stream(items, ntfy_poller, mic_monitor):
scr_row = firehose_top + fr + 1
if scr_row <= msg_h or scr_row > h:
continue
for col, chunk in _overlay_segments(fline):
# Opaque row backdrop to distinguish firehose from ticker beneath it.
buf.append(f"\033[{scr_row};1H{FIREHOSE_BG}{' ' * w}{RST}")
for col, chunk in _overlay_segments(fline, FIREHOSE_BG):
buf.append(f"\033[{scr_row};{col}H{chunk}")
sys.stdout.buffer.write("".join(buf).encode())