pfalcon / picotui

Lightweight, pure-Python Text User Interface (TUI) widget toolkit with minimal dependencies. Dedicated to the Pycopy project.
https://github.com/pfalcon/pycopy
MIT License
811 stars 70 forks source link

Crash with Unicode input #22

Closed fiee closed 6 years ago

fiee commented 6 years ago

I’m using OSX Terminal.app with a German keyboard. As soon as I type an umlaut or accented character, I get this error:

Traceback (most recent call last): File "picowidgets.py", line 60, in res = d.loop() File ".../python3.6/site-packages/picotui/basewidget.py", line 76, in loop res = self.handle_input(key) File ".../python3.6/site-packages/picotui/basewidget.py", line 69, in handle_input res = self.handle_key(inp) File ".../python3.6/site-packages/picotui/widgets.py", line 104, in handle_key res = self.focus_w.handle_key(key) File ".../python3.6/site-packages/picotui/editor.py", line 183, in handle_key return self.handle_edit_key(key) File ".../python3.6/site-packages/picotui/editor.py", line 210, in handle_edit_key l = l[:self.col + self.margin] + str(key, "utf-8") + l[self.col + self.margin:] UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 0: unexpected end of data

fiee commented 6 years ago

... additionally, mouse input doesn’t work, but that seems expected, as you say in issue #3 (please document that in example or README).

pfalcon commented 6 years ago

... additionally, mouse input doesn’t work, but that seems expected, as you say in issue #3 (please document that in example or README).

Well, I say there that I don't use MacOS, so have no idea what happens there. If you're interested in tracking that issue, it should be submitted as a separate, clearly named ticket.

pfalcon commented 6 years ago

Anyway, I can reproduce this on Linux too.

243accff6a2601871b8004f92adf025377517629 adds a workaround which works for me on Linux. Feel free to reopen if it still doesn't work for you on MacOS.

The underlying problem is deeper though, and tracked as #23.

pfalcon commented 6 years ago

243accf adds a workaround

Released as 0.9.4.