X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=plomrogue_client%2Ftui.py;fp=plomrogue_client%2Ftui.py;h=7cfc01139c35a8cbb75aa0039640fc353b98a109;hb=d9970cdde3a9f232efbfcacae0217b63e8389551;hp=ec04304b0b0358b1083b62b90038ab5096dab8a3;hpb=d1b7ae346e13f77a72926173a3092d1e83663a9d;p=plomrogue2 diff --git a/plomrogue_client/tui.py b/plomrogue_client/tui.py index ec04304..7cfc011 100644 --- a/plomrogue_client/tui.py +++ b/plomrogue_client/tui.py @@ -3,12 +3,13 @@ import curses -class CursesScreen: +class TUI: - def wrap_loop(self, loop): - curses.wrapper(self.start_loop, loop) + def __init__(self): + self._log = [] + curses.wrapper(self.run_loop) - def safe_addstr(self, y, x, line, attr=0): + def addstr(self, y, x, line, attr=0): if y < self.size.y - 1 or x + len(line) < self.size.x: self.stdscr.addstr(y, x, line, attr) else: # workaround to @@ -25,11 +26,19 @@ class CursesScreen: self.size = self.size - YX(self.size.y % 4, 0) self.size = self.size - YX(0, self.size.x % 4) - def start_loop(self, stdscr, loop): - self.stdscr = stdscr + def init_loop(self): curses.curs_set(0) # hide cursor - stdscr.timeout(10) - loop() + self.stdscr.timeout(10) + self.reset_size() + + def run_loop(self, stdscr): + self.stdscr = stdscr + self.init_loop() + while True: + self.loop() + + def log(self, msg): + self._log += [msg]