home · contact · privacy
Remove some redundant drawing code.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 11 Aug 2025 00:47:20 +0000 (02:47 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 11 Aug 2025 00:47:20 +0000 (02:47 +0200)
ircplom/tui_base.py

index 3c2d46a14c7b07847ab53688f23b44aea566f423..c829bbf180f288fb5753266ce2d13db4c5206201 100644 (file)
@@ -328,7 +328,6 @@ class Window(_Widget):
         return f'{self.idx}) {self._title}'
 
     def draw(self) -> bool:
-        self._term.clear()
         if not super().draw():
             if self._term.size.x > 0:
                 lines = ['']
@@ -341,8 +340,8 @@ class Window(_Widget):
             return False
         title_box = f'{self.status_title}]'
         status_line = title_box + '=' * (self._term.size.x - len(title_box))
-        self.history.draw()
         self._term.write(status_line, self._y_status)
+        self.history.draw()
         self.prompt.draw()
         return True
 
@@ -418,7 +417,7 @@ class BaseTui(QueueMixin):
 
     def _switch_window(self, idx: int) -> None:
         self._window_idx = idx
-        self.window.draw()
+        self.window.tainted = True
 
     @property
     def _commands(self) -> dict[str, tuple[Callable[..., None | Optional[str]],
@@ -563,7 +562,7 @@ class Terminal(QueueMixin):
     @contextmanager
     def setup(self) -> Generator:
         'Combine multiple contexts into one and run keypress loop.'
-        self.clear()
+        print(self._blessed.clear, end='')
         with (self._blessed.raw(),
               self._blessed.fullscreen(),
               self._blessed.hidden_cursor(),
@@ -583,10 +582,6 @@ class Terminal(QueueMixin):
         '(Re-)calculate .size..'
         self.size = _YX(self._blessed.height, self._blessed.width)
 
-    def clear(self) -> None:
-        'Clear terminal.'
-        print(self._blessed.clear, end='')
-
     def flush(self) -> None:
         'Flush terminal.'
         print('', end='', flush=True)