From 6a7c28877032984b15be8afe6f9df70c1f93de78 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Wed, 11 Jun 2025 15:06:22 +0200 Subject: [PATCH] On prompt history scroll, move cursor to end of retrieved record. --- ircplom.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ircplom.py b/ircplom.py index 83870d1..2280276 100755 --- a/ircplom.py +++ b/ircplom.py @@ -542,6 +542,7 @@ class PromptWidget(ScrollableWidget): _width: int _prompt: str = PROMPT_TEMPLATE _history_idx = 0 + _cursor_x: int def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) @@ -588,20 +589,25 @@ class PromptWidget(ScrollableWidget): self._write(to_write[cursor_x_to_write + 1:]) def _scroll(self, up: bool = True) -> None: + + def set_to_record_at_idx() -> None: + self._input_buffer = self._history[self._history_idx][:] + self._cursor_x = len(self._input_buffer) + 1 + if up and -(self._history_idx) < len(self._history): if self._history_idx == 0 and self._input_buffer: self._history += [self._input_buffer[:]] self._clear() self._history_idx -= 1 self._history_idx -= 1 - self._input_buffer = self._history[self._history_idx][:] + set_to_record_at_idx() elif not up: if self._history_idx < 0: self._history_idx += 1 if self._history_idx == 0: self._clear() else: - self._input_buffer = self._history[self._history_idx][:] + set_to_record_at_idx() elif self._input_buffer: self._history += [self._input_buffer[:]] self._clear() -- 2.30.2