23 lines
562 B
Python
23 lines
562 B
Python
"""ASCII emitter — read CharGrid and output plain text.
|
|
|
|
Reads only cell.char from each cell. No color, no style tags.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from uframe.grid import CharGrid
|
|
|
|
|
|
def emit_ascii(grid: CharGrid) -> str:
|
|
"""Emit the CharGrid as plain ASCII text."""
|
|
lines: list[str] = []
|
|
for row in range(grid.height):
|
|
line = "".join(cell.char for cell in grid.cells[row]).rstrip()
|
|
lines.append(line)
|
|
|
|
# Strip trailing blank lines
|
|
while lines and not lines[-1]:
|
|
lines.pop()
|
|
|
|
return "\n".join(lines)
|