from typing import List import logging import os from .screen import Screen class TerminalScreen(Screen): def __init__(self): super().__init__() self.type = "Terminal Screen" self.width, self.height = os.get_terminal_size() def setDefaultFont(self): return 0 def setFont(self, font: str, size: int): logging.debug(f"TerminalScreen doesn't support custom fonts, can't set font to {font}, or size to {size}") raise NotImplementedError("TerminalScreen doesn't support custom fonts") def displayLines(self, lines: List[str], x_padding: int = 0, y_padding: int = 0): # displays text on the screen self.clearScreen() y = 0 x = 0 for i, line in enumerate(lines): # TODO: Calculate x and y before printing to check if we are going to go off the terminal print('\n' * int(y+(y_padding*i)), end='') print(' ' * int(x+(x_padding*i)), end='') print(line, end='') def clearScreen(self): print("\033c", end='')