Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Workaround issue with get_wch on older ncurses #2591

Merged
merged 1 commit into from
Jun 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions mycroft/client/text/text_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ def prepare_page():
scr.addstr(curses.LINES - 1, 0,
center(23) + "Press any key to continue", CLR_HEADING)
scr.refresh()
scr.get_wch() # blocks
wait_for_any_key()
prepare_page()
elif row == curses.LINES - 2:
# Reached bottom of screen, start at top and move output to a
Expand Down Expand Up @@ -1065,6 +1065,21 @@ def _get_cmd_param(cmd, keyword):
return parts[-1]


def wait_for_any_key():
"""Block until key is pressed.

This works around curses.error that can occur on old versions of ncurses.
"""
while True:
try:
scr.get_wch() # blocks
except curses.error:
# Loop if get_wch throws error
time.sleep(0.05)
else:
break


def handle_cmd(cmd):
global show_meter
global screen_mode
Expand Down Expand Up @@ -1142,7 +1157,8 @@ def handle_cmd(cmd):

if message:
show_skills(message.data)
scr.get_wch() # blocks
wait_for_any_key()

screen_mode = SCR_MAIN
set_screen_dirty()
elif "deactivate" in cmd:
Expand Down