Use get_wch() to support unicode input in the CLI
The CLI interface should now allow non-ASCII characters, including those used in non-English languages.
@@ -34,7 +34,6 @@ import os
import os.path
import time
import curses
-import curses.ascii
import textwrap
import json
import mycroft.version
@@ -727,7 +726,7 @@ def show_help():
CLR_HEADING)
scr.refresh()
- c = scr.getch() # blocks
+ scr.get_wch() # blocks
screen_mode = 0 # back to main screen
draw_screen()
@@ -861,7 +860,7 @@ def handle_cmd(cmd):
if message and 'skills' in message.data:
show_skills(message.data['skills'])
- c = scr.getch() # blocks
+ scr.get_wch() # blocks
screen_mode = 0 # back to main screen
draw_screen()
# TODO: More commands
@@ -894,12 +893,12 @@ def gui_main(stdscr):
while True:
draw_screen()
- c = scr.getch()
+ c = scr.get_wch()
# Convert VT100 ESC codes generated by some terminals
if c == 27:
- c1 = scr.getch()
- c2 = scr.getch()
+ c1 = scr.get_wch()
+ c2 = scr.get_wch()
if c1 == 79 and c2 == 120:
c = curses.KEY_UP
elif c1 == 79 and c2 == 116:
@@ -922,7 +921,7 @@ def gui_main(stdscr):
else:
last_key = str(c)
- if c == curses.KEY_ENTER or c == 10 or c == 13:
+ if c == '\n' or c == 10 or c == 13:
# ENTER sends the typed line to be processed by Mycroft
if line == "":
continue
@@ -989,7 +988,7 @@ def gui_main(stdscr):
# resizeterm() causes another curses.KEY_RESIZE, so
# we need to capture that to prevent a loop of resizes
- c = scr.getch()
+ c = scr.get_wch()
elif c == curses.KEY_BACKSPACE or c == 127:
# Backspace to erase a character in the utterance
line = line[:-1]
@@ -1003,9 +1002,9 @@ def gui_main(stdscr):
# End the find session
find_str = None
rebuild_filtered_log()
- elif curses.ascii.isascii(c):
+ elif isinstance(c, str):
# Accept typed character in the utterance
- line += chr(c)
+ line += c
# DEBUG: Uncomment the following code to see what key codes
# are generated when an unknown key is pressed.
