The emoji selection is working

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2020-12-21 16:04:07 +01:00
parent 5a212750e6
commit 9fcc0c30a7
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 19 additions and 3 deletions

View File

@ -118,13 +118,29 @@ class Squinnondation:
if y == curses.LINES - 1 and x >= curses.COLS - 3:
# Click on the emoji
squirrel.emoji_panel_page *= -1
else:
squirrel.add_message(f"<system> *mouse click at ({y}, {x}): {attr}*")
if squirrel.emoji_panel_page > 0 and y == curses.LINES - 4 and x >= curses.COLS - 5:
elif squirrel.emoji_panel_page > 0 and y == curses.LINES - 4 and x >= curses.COLS - 5:
squirrel.emoji_panel_page += 1
elif squirrel.emoji_panel_page > 1 and y == curses.LINES - curses.LINES // 2 - 1 \
and x >= curses.COLS - 5:
squirrel.emoji_panel_page -= 1
elif squirrel.emoji_panel_page > 0 and y >= curses.LINES // 2 - 1 and x >= curses.COLS // 2 - 1:
pad_y, pad_x = y - (curses.LINES - curses.LINES // 2) + 1,\
(x - (curses.COLS - curses.COLS // 3)) // 2
height, width = squirrel.emoji_pad.getmaxyx()
height -= 1
width -= 1
emojis = list(unicode_codes.UNICODE_EMOJI)
emojis = [c for c in emojis if len(c) == 1]
size = (height - 2) * (width - 4) // 2
page = emojis[(squirrel.emoji_panel_page - 1) * size:squirrel.emoji_panel_page * size]
index = pad_y * (width - 4) // 2 + pad_x
char = page[index]
if char:
demojized = emoji.demojize(char)
if char != demojized:
for c in reversed(demojized):
curses.ungetch(c)
continue
elif len(key) > 1:
squirrel.add_message(f"<system> *unmanaged key press: {key}*")