feat: added a twist

This commit is contained in:
2026-04-01 00:53:55 +02:00
parent 0b7deee59e
commit b40c6436cd
76 changed files with 15121 additions and 64 deletions

View File

@@ -0,0 +1,22 @@
"""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)