squirrel-battle/squirrelbattle/display/logsdisplay.py
Nicolas Margulies 1e5bb26f57 Test logs
2020-11-19 20:02:44 +01:00

24 lines
801 B
Python

from squirrelbattle.display.display import Display
from squirrelbattle.interfaces import Logs
class LogsDisplay(Display):
def __init__(self, *args) -> None:
super().__init__(*args)
self.pad = self.newpad(self.rows, self.cols)
def update_logs(self, logs: Logs) -> None:
self.logs = logs
def display(self) -> None:
print(type(self.logs.messages), flush=True)
messages = self.logs.messages[-self.height:]
messages = messages[::-1]
self.pad.clear()
for i in range(min(self.height, len(messages))):
self.pad.addstr(self.height - i - 1, self.x,
messages[i][:self.width])
self.pad.refresh(0, 0, self.y, self.x, self.y + self.height,
self.x + self.width)