From d8d559a6e9bfabfd1717a9bbc295c3b9a172f15a Mon Sep 17 00:00:00 2001 From: vvihorev Date: Fri, 5 Apr 2024 18:32:00 +0200 Subject: [PATCH] Add support for Cyrillic characters in get_keys() --- tg/views.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tg/views.py b/tg/views.py index d0aef6f..f0f0db9 100644 --- a/tg/views.py +++ b/tg/views.py @@ -91,15 +91,19 @@ class View: for _ in range(MAX_KEYBINDING_LENGTH): ch = self.stdscr.getch() - log.info("raw ch without unctrl: %s", ch) - try: - key = curses.unctrl(ch).decode() - except Exception: - log.warning("cant uncrtl: %s", ch) - break - if key.isdigit(): - repeat_factor += key - continue + if ch == 208 or ch == 209: + second_ch = self.stdscr.getch() + key = (ch.to_bytes() + second_ch.to_bytes()).decode('utf-8') + else: + log.info("raw ch without unctrl: %s", ch) + try: + key = curses.unctrl(ch).decode() + except Exception: + log.warning("cant uncrtl: %s", ch) + break + if key.isdigit(): + repeat_factor += key + continue keys += key # if match found or there are not any shortcut matches at all if all(