The emoji selection is working
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
parent
5a212750e6
commit
9fcc0c30a7
|
@ -118,13 +118,29 @@ class Squinnondation:
|
||||||
if y == curses.LINES - 1 and x >= curses.COLS - 3:
|
if y == curses.LINES - 1 and x >= curses.COLS - 3:
|
||||||
# Click on the emoji
|
# Click on the emoji
|
||||||
squirrel.emoji_panel_page *= -1
|
squirrel.emoji_panel_page *= -1
|
||||||
else:
|
elif squirrel.emoji_panel_page > 0 and y == curses.LINES - 4 and x >= curses.COLS - 5:
|
||||||
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:
|
|
||||||
squirrel.emoji_panel_page += 1
|
squirrel.emoji_panel_page += 1
|
||||||
elif squirrel.emoji_panel_page > 1 and y == curses.LINES - curses.LINES // 2 - 1 \
|
elif squirrel.emoji_panel_page > 1 and y == curses.LINES - curses.LINES // 2 - 1 \
|
||||||
and x >= curses.COLS - 5:
|
and x >= curses.COLS - 5:
|
||||||
squirrel.emoji_panel_page -= 1
|
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
|
continue
|
||||||
elif len(key) > 1:
|
elif len(key) > 1:
|
||||||
squirrel.add_message(f"<system> *unmanaged key press: {key}*")
|
squirrel.add_message(f"<system> *unmanaged key press: {key}*")
|
||||||
|
|
Loading…
Reference in New Issue