From e8781acf198ae7fc59342cedf11673ee359eec71 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Fri, 30 May 2025 17:37:47 +0200 Subject: [PATCH] Scroll with PgUp/PgDown and larger distances. --- ircplom.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ircplom.py b/ircplom.py index f355660..d4c04e0 100755 --- a/ircplom.py +++ b/ircplom.py @@ -24,8 +24,8 @@ INPUT_PROMPT = ':' KEYBINDINGS = { 'KEY_BACKSPACE': 'prompt_backspace', 'KEY_ENTER': 'prompt_enter', - 'KEY_UP': 'scroll_up', - 'KEY_DOWN': 'scroll_down', + 'KEY_PGUP': 'scroll_up', + 'KEY_PGDOWN': 'scroll_down', } IRCSPEC_LINE_SEPARATOR = b'\r\n' @@ -398,13 +398,12 @@ class TuiLoop(Loop): self._draw_prompt() def _kb__scroll_up(self) -> None: - if len(self._log_buffer) > self._upscroll: - self._upscroll += 1 + self._upscroll = min(len(self._log_buffer) - 1, + self._upscroll + self._y_pgscroll) self._draw_log() def _kb__scroll_down(self) -> None: - if self._upscroll > 1: - self._upscroll -= 1 + self._upscroll = max(0, self._upscroll - self._y_pgscroll) self._draw_log() def _calc_and_draw_all(self) -> None: @@ -412,6 +411,7 @@ class TuiLoop(Loop): self._term.calc_geometry() self._y_prompt = self._term.size.y - 1 self._y_separator = self._term.size.y - 2 + self._y_pgscroll = self._y_separator // 2 self._draw_frame() self._draw_log() self._draw_prompt() -- 2.30.2