home
·
contact
·
privacy
projects
/
ircplom
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9993c39
)
Minor code polishing.
master
author
Christian Heller
<c.heller@plomlompom.de>
Wed, 26 Nov 2025 05:33:04 +0000
(06:33 +0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Wed, 26 Nov 2025 05:33:04 +0000
(06:33 +0100)
src/ircplom/tui_base.py
patch
|
blob
|
history
diff --git
a/src/ircplom/tui_base.py
b/src/ircplom/tui_base.py
index cfd2e612f080bc9837ea9e9c42370ab53748f9bb..7c55ebf9761f1ef4404e5f44081a19b422fc5418 100644
(file)
--- a/
src/ircplom/tui_base.py
+++ b/
src/ircplom/tui_base.py
@@
-204,12
+204,12
@@
class _Widget(ABC):
self.taint()
self._sizes = sizes
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.'
'Build line of static left, right scrolled with cursor_x if too large.'
- to_write = left
+ to_write = left
[:]
offset = 0
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:
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:
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 += ' '
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')
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
def _draw(self) -> None:
cursor_x = 0
- focus
ed
= None
+ focus = None
win_listing = ''
for w in self._windows:
win_listing += ' ' if w.idx > 0 else '('
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:
if w.history.has_unread_highlight:
item = f'*{item}'
if w.idx == self.idx_focus:
- focus
ed
= w
+ focus = w
item = f'[{item}]'
cursor_x = len(win_listing) + (len(item) // 2)
win_listing += item
item = f'[{item}]'
cursor_x = len(win_listing) + (len(item) // 2)
win_listing += item
- assert isinstance(focus
ed
, 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:
class Window: