diff --git a/squinnondation/squinnondation.py b/squinnondation/squinnondation.py index 369f6f3..029a233 100644 --- a/squinnondation/squinnondation.py +++ b/squinnondation/squinnondation.py @@ -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" *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" *unmanaged key press: {key}*")