From: Christian Heller Date: Wed, 11 Jun 2025 13:06:22 +0000 (+0200) Subject: On prompt history scroll, move cursor to end of retrieved record. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%22https:/validator.w3.org/test?a=commitdiff_plain;h=6a7c28877032984b15be8afe6f9df70c1f93de78;p=ircplom On prompt history scroll, move cursor to end of retrieved record. --- 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()