mirror of
https://github.com/paul-nameless/tg
synced 2025-02-16 18:48:24 +00:00
fix multiline problems
This commit is contained in:
parent
6006c8c814
commit
9d81476bec
1 changed files with 14 additions and 7 deletions
21
tg/views.py
21
tg/views.py
|
@ -393,17 +393,24 @@ class MsgView:
|
|||
for attr, elem in zip(self._msg_attributes(selected), elements):
|
||||
if not elem:
|
||||
continue
|
||||
full_line = self.w - column - len(elem) == 0
|
||||
last_line = self.h - 1 == line_num
|
||||
lines = (column + len(elem)) // self.w
|
||||
last_line = self.h == line_num + lines
|
||||
# work around agaist curses behaviour, when you cant write
|
||||
# char to the lower right coner of the window
|
||||
# see https://stackoverflow.com/questions/21594778/how-to-fill-to-lower-right-corner-in-python-curses/27517397#27517397
|
||||
if full_line and last_line:
|
||||
# insstr does not wraps long strings
|
||||
draw_func = self.win.insstr
|
||||
if last_line:
|
||||
start, stop = 0, self.w - column
|
||||
for i in range(lines):
|
||||
# insstr does not wraps long strings
|
||||
self.win.insstr(
|
||||
line_num + i,
|
||||
column if not i else 0,
|
||||
elem[start:stop],
|
||||
attr,
|
||||
)
|
||||
start, stop = stop, stop + self.w
|
||||
else:
|
||||
draw_func = self.win.addstr
|
||||
draw_func(line_num, column, elem, attr)
|
||||
self.win.addstr(line_num, column, elem, attr)
|
||||
column += len(elem)
|
||||
|
||||
self._refresh()
|
||||
|
|
Loading…
Add table
Reference in a new issue