Skip to content

Commit

Permalink
basewidget: get_input: Work around incorrect UTF-8 partitioning.
Browse files Browse the repository at this point in the history
To get a complete UTF-8 char, convert terminal input from bytes to str,
then back again.

This is not ideal, but the whole terminal input handling needs to be
reworked later anyway.
  • Loading branch information
pfalcon committed Dec 25, 2017
1 parent c1b8119 commit 243accf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions picotui/basewidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ def get_input(self):
else:
key = os.read(0, 32)
if key[0] != 0x1b:
self.kbuf = key[1:]
key = key[0:1]
key = key.decode()
self.kbuf = key[1:].encode()
key = key[0:1].encode()
key = KEYMAP.get(key, key)

if isinstance(key, bytes) and key.startswith(b"\x1b[M") and len(key) == 6:
Expand Down

0 comments on commit 243accf

Please sign in to comment.