From: Christian Heller Date: Wed, 26 Nov 2025 05:33:04 +0000 (+0100) Subject: Minor code polishing. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/condition?a=commitdiff_plain;p=ircplom Minor code polishing. --- diff --git a/src/ircplom/tui_base.py b/src/ircplom/tui_base.py index cfd2e61..7c55ebf 100644 --- a/src/ircplom/tui_base.py +++ b/src/ircplom/tui_base.py @@ -204,12 +204,12 @@ class _Widget(ABC): self.taint() self._sizes = sizes - def make_x_scroll(self, padchar: str, cursor_x: int, left: str, right: str - ) -> tuple[int, str]: + def _make_x_scroll(self, padchar: str, cursor_x: int, left: str, right: str + ) -> tuple[int, str]: 'Build line of static left, right scrolled with cursor_x if too large.' - to_write = left + to_write = left[:] offset = 0 - width_gap = self._sizes.x - len(left) - len(right) + width_gap = self._sizes.x - len(left + right) if width_gap < 0: half_width = (self._sizes.x - len(left)) // 2 if cursor_x > half_width: @@ -435,14 +435,13 @@ class PromptWidget(_ScrollableWidget): self._input_buffer_unsafe = content[:] def _draw(self) -> None: - prefix = self.prefix[:] content = self.input_buffer if self._cursor_x == len(self.input_buffer): content += ' ' - x_cursor, to_write = self.make_x_scroll(padchar=' ', - cursor_x=self._cursor_x, - left=prefix, - right=content) + x_cursor, to_write = self._make_x_scroll(padchar=' ', + cursor_x=self._cursor_x, + left=self.prefix[:], + right=content) self._write(self._sizes.y, FormattingString(to_write[:x_cursor]) + FormattingString(to_write[x_cursor]).attrd('reverse') @@ -519,7 +518,7 @@ class _StatusLine(_Widget): def _draw(self) -> None: cursor_x = 0 - focused = None + focus = None win_listing = '' for w in self._windows: win_listing += ' ' if w.idx > 0 else '(' @@ -529,15 +528,15 @@ class _StatusLine(_Widget): if w.history.has_unread_highlight: item = f'*{item}' if w.idx == self.idx_focus: - focused = w + focus = w item = f'[{item}]' cursor_x = len(win_listing) + (len(item) // 2) win_listing += item - assert isinstance(focused, Window) - self._write(self._sizes.y, self.make_x_scroll(padchar='=', - cursor_x=cursor_x, - left=focused.title + ')', - right=win_listing)[1]) + assert isinstance(focus, Window) + self._write(self._sizes.y, self._make_x_scroll(padchar='=', + cursor_x=cursor_x, + left=focus.title + ')', + right=win_listing)[1]) class Window: