mirror of
https://github.com/paul-nameless/tg
synced 2025-02-16 10:38:23 +00:00
Fix layout problems due to emodjies in ChatView (#78)
This commit is contained in:
parent
492371c754
commit
1f40cbc444
1 changed files with 8 additions and 3 deletions
11
tg/views.py
11
tg/views.py
|
@ -137,7 +137,7 @@ class ChatView:
|
|||
|
||||
def resize(self, rows: int, cols: int, p: float = 0.25) -> None:
|
||||
self.h = rows - 1
|
||||
self.w = round(cols * p)
|
||||
self.w = round(cols * p) - 1
|
||||
self.win.resize(self.h, self.w)
|
||||
|
||||
def _msg_color(self, is_selected: bool = False) -> int:
|
||||
|
@ -186,7 +186,9 @@ class ChatView:
|
|||
truncate_to_len(elem, max(0, self.w - offset - 1)),
|
||||
attr,
|
||||
)
|
||||
offset += len(elem)
|
||||
offset += len(elem) + sum(
|
||||
map(len, emoji_pattern.findall(elem))
|
||||
)
|
||||
|
||||
last_msg = " " + last_msg.replace("\n", " ")
|
||||
last_msg = truncate_to_len(last_msg, max(0, self.w - offset))
|
||||
|
@ -196,9 +198,12 @@ class ChatView:
|
|||
)
|
||||
|
||||
if flags := self._get_flags(unread_count, is_pinned, chat):
|
||||
flags_len = len(flags) + sum(
|
||||
map(len, emoji_pattern.findall(flags))
|
||||
)
|
||||
self.win.addstr(
|
||||
i,
|
||||
self.w - len(flags) - 1,
|
||||
self.w - flags_len - 1,
|
||||
flags,
|
||||
self._unread_color(is_selected),
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue