Skip to content

Commit

Permalink
Fixed handling wide character for input prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
wustho committed Aug 14, 2021
1 parent f0a5af7 commit 55f938c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions epy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""


__version__ = "2021.7.16"
__version__ = "2021.8.14"
__license__ = "GPL-3.0"
__author__ = "Benawi Adha"
__email__ = "benawiadha@gmail.com"
Expand Down Expand Up @@ -1189,7 +1189,15 @@ def input_prompt(prompt):

try:
while True:
ipt = stat.getch()
# NOTE: getch() only handles ascii
# to handle wide char like: é, use get_wch()
# ipt = stat.getch()
ipt = stat.get_wch()
# get_wch() return ambiguous type
# str for string input but int for function or special keys
if type(ipt) == str:
ipt = ord(ipt)

if ipt == 27:
stat.clear()
stat.refresh()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name="epy-reader",
version="2021.7.16",
version="2021.8.14",
description="Terminal/CLI Ebook (epub, fb2, mobi, azw3) Reader",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 55f938c

Please sign in to comment.