home · contact · privacy
Wrap log lines to terminal width.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 30 May 2025 15:01:35 +0000 (17:01 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 30 May 2025 15:01:35 +0000 (17:01 +0200)
ircplom.py

index 1bf4141a9842eedf6c27c0210a9fe52a36e9e6c9..2c551177885cf2928bfa63b3133a904f4a76b5a9 100755 (executable)
@@ -90,6 +90,10 @@ class Terminal:
         'Flush terminal.'
         print('', end='', flush=True)
 
+    def wrap(self, line: str) -> list[str]:
+        'Wrap line to list of lines fitting into terminal width.'
+        return self._blessed.wrap(line, width=self.size.x)
+
     def write_yx(self, offset: YX, msg: str) -> None:
         'Starting at offset, write line with msg, padded at end with spaces.'
         print(self._blessed.move_yx(offset.y, offset.x), end='')
@@ -404,7 +408,9 @@ class TuiLoop(Loop):
         self._term.write_yx(YX(self._y_prompt, 0), INPUT_PROMPT)
 
     def _draw_log(self) -> None:
-        temp_buffer = ([''] * self._term.size.y) + self._log_buffer[:]
+        temp_buffer = [''] * self._term.size.y
+        for line in self._log_buffer:
+            temp_buffer += self._term.wrap(line)
         for i, line in enumerate(temp_buffer[-self._y_separator:]):
             self._term.write_yx(YX(i, 0), line)