Prevent curses errors
This commit is contained in:
parent
2797b9ddc5
commit
4a79fcaabe
|
@ -715,13 +715,19 @@ class User(Peer):
|
||||||
_text_: italic
|
_text_: italic
|
||||||
~~text~~: strikethrough
|
~~text~~: strikethrough
|
||||||
"""
|
"""
|
||||||
|
msg = msg.replace("\0", "")
|
||||||
|
|
||||||
# Replace :emoji_name: by the good emoji
|
# Replace :emoji_name: by the good emoji
|
||||||
if not self.squinnondation.no_emoji:
|
if not self.squinnondation.no_emoji:
|
||||||
import emoji
|
import emoji
|
||||||
msg = emoji.emojize(msg, use_aliases=True)
|
msg = emoji.emojize(msg, use_aliases=True)
|
||||||
|
|
||||||
if self.squinnondation.no_markdown:
|
if self.squinnondation.no_markdown:
|
||||||
pad.addstr(y, x, msg)
|
try:
|
||||||
|
pad.addstr(y, x, msg)
|
||||||
|
except curses.error:
|
||||||
|
# Should not happen
|
||||||
|
pass
|
||||||
return len(msg)
|
return len(msg)
|
||||||
|
|
||||||
underline_match = re.match("(.*)__(.*)__(.*)", msg)
|
underline_match = re.match("(.*)__(.*)__(.*)", msg)
|
||||||
|
@ -788,7 +794,11 @@ class User(Peer):
|
||||||
space_left_on_line = (curses.COLS - 2) - (x % (curses.COLS - 1))
|
space_left_on_line = (curses.COLS - 2) - (x % (curses.COLS - 1))
|
||||||
msg = msg[:space_left_on_line + max(0, (curses.COLS - 1) * (remaining_lines - 1))]
|
msg = msg[:space_left_on_line + max(0, (curses.COLS - 1) * (remaining_lines - 1))]
|
||||||
if msg:
|
if msg:
|
||||||
pad.addstr(y + x // (curses.COLS - 1), x % (curses.COLS - 1), msg, attrs)
|
try:
|
||||||
|
pad.addstr(y + x // (curses.COLS - 1), x % (curses.COLS - 1), msg, attrs)
|
||||||
|
except curses.error:
|
||||||
|
# Should not happen
|
||||||
|
pass
|
||||||
return size
|
return size
|
||||||
|
|
||||||
def refresh_history(self) -> None:
|
def refresh_history(self) -> None:
|
||||||
|
|
Loading…
Reference in New Issue