From 5964c0910f8a5358f813e4c3c127419b3d379ced Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Fri, 30 May 2025 17:01:35 +0200 Subject: [PATCH] Wrap log lines to terminal width. --- ircplom.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ircplom.py b/ircplom.py index 1bf4141..2c55117 100755 --- a/ircplom.py +++ b/ircplom.py @@ -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) -- 2.30.2