matimatik/fbless — pull request #19 by ashinkarov (2012-07-27 09:56:43+00:00)
Title: Handle utf8 properly in search and goto_percentage

Когда удаляешь utf8 символ backspace-ом, то при использовании getstr нужно нажимать пробел несколько раз. Плюс, если нажать недостаточное количество раз, то строка будет содержать некорректные символы.

There is a well-known curses bug (or feature?) that it cannot
handle utf8 typing properly, as getch on multi-byte characters
return only one byte, where backspace removes one byte as well.
This leads to the fact that user has to press backspace multiple
times in order to delete multi-byte character, and the string
may contain errors (in case there were not enough backspace hits).

Now, for utf-8 we mimic getstr functionality manually --
first byte of each utf8 character encodes the number of bytes
needed for the upcoming character representation. We use this
information, and adjust backspace functionality accordingly.

* main.py (MainWindow.get_utf8_string):
New function. Handles correct obtaining of utf8 string.
* main.py (MainWindow.search):
Adjust to use get_utf8_string.
* main.py (MainWindow.goto_percent):
Adjust to use get_utf8_string.