Emojize texts

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2020-12-21 16:04:03 +01:00
parent b007f4fce5
commit 9835fff1f9
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 7 additions and 1 deletions

View File

@ -0,0 +1 @@
emoji~=0.6

View File

@ -10,6 +10,8 @@ from ipaddress import IPv6Address
from threading import Thread from threading import Thread
from typing import Any, List, Optional, Tuple from typing import Any, List, Optional, Tuple
import emoji
from squinnondation.term_manager import TermManager from squinnondation.term_manager import TermManager
@ -486,11 +488,14 @@ class Squirrel(Hazelnut):
len_after = self.print_markdown(pad, y, x + len_before + len_mid, after, bold, italic, underline, strike) len_after = self.print_markdown(pad, y, x + len_before + len_mid, after, bold, italic, underline, strike)
return len_before + len_mid + len_after return len_before + len_mid + len_after
# Replace :emoji_name: by the good emoji
msg = emoji.emojize(msg, use_aliases=True)
size = len(msg)
attrs = 0 attrs = 0
attrs |= curses.A_BOLD if bold else 0 attrs |= curses.A_BOLD if bold else 0
attrs |= curses.A_ITALIC if italic else 0 attrs |= curses.A_ITALIC if italic else 0
attrs |= curses.A_UNDERLINE if underline else 0 attrs |= curses.A_UNDERLINE if underline else 0
size = len(msg)
if strike: if strike:
msg = "".join(c + "\u0336" for c in msg) msg = "".join(c + "\u0336" for c in msg)
pad.addstr(y, x, msg, attrs) pad.addstr(y, x, msg, attrs)