43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""
|
||
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)
|