You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB
Python

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='')