This repository has been archived on 2025-12-01. You can view files and clone it, but cannot push or open issues or pull requests.
Telefact_archive/src/core/telefact_frame.py

43 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Telefact Frame (model)
- Defines a 40×24 grid and logical regions.
- No rendering here—pure data model.
"""
class TelefactFrame:
def __init__(self, cols: int = 40, rows: int = 24):
self.cols = cols
self.rows = rows
self.header_rows = 1
self.footer_rows = 1
self.body_rows = self.rows - (self.header_rows + self.footer_rows)
# grid[row][col] -> (char, color_name)
self.grid = [[(" ", "white") for _ in range(self.cols)] for _ in range(self.rows)]
# basic cell ops
def set_cell(self, col: int, row: int, char: str, color: str = "white"):
if 0 <= col < self.cols and 0 <= row < self.rows and char:
self.grid[row][col] = (char[0], color)
def get_cell(self, col: int, row: int):
if 0 <= col < self.cols and 0 <= row < self.rows:
return self.grid[row][col]
return (" ", "white")
def clear(self, char: str = " ", color: str = "white"):
for r in range(self.rows):
for c in range(self.cols):
self.grid[r][c] = (char, color)
# regions
def header_region(self):
return range(0, self.header_rows)
def body_region(self):
return range(self.header_rows, self.header_rows + self.body_rows)
def footer_region(self):
return range(self.rows - self.footer_rows, self.rows)