-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cursor behavior for full/ambiguous width characters #9
Comments
Hello, can you please submit a test case for the patch? |
there is also wcwidth.py, a port of the same in .c, which i happen to use in similar capacity https://github.com/jquast/x84/blob/master/x84/bbs/wcwidth.py#L197 |
Hello, Jeff, thank you for the link. Do you now if there a standalone Python implementation somewhere? If not, did you consider using |
|
I agree with Jeff, the pure python wcwidth.py works wonderfully, but it shouldn't be in the x84 repository. Copy it over to the pyte library, or make a standalone Python package of it. |
I'll make a standalone. Just so we're clear, コンニチハ in a terminal, when selected, should highlight two cells, not one, even though its only 5 glyphs, its 10 cells.
|
Thanks, @jquast, for me that's perfect. Can you put that on pypi? And are you willing to maintain that package? (if there is any maintenance.) If you could add some tests and docs to the project, that would be even nicer. ;) |
Sounds good to me as well. Also, +1 for the tests, there should be some for the |
yup, working on it now. |
still working on it. https://github.com/jquast/wcwidth/ Learning a lot about this stuff... I wrote a viewer utility to check my work, https://asciinema.org/a/8683 Plan to write some tests first out of what is there, then, do a rewrite of something that should be automatically maintainable by just feeding the latest unicode spec docs. Then I'll publish to pypi, eta sunday or so. I think the wcwidth() and wcswidth() interfaces, as module wcwidth will remain. eta to pypi about 5 days or so. |
Great! |
libc comparison complete, error report here: https://travis-ci.org/jquast/wcwidth/jobs/23326096 @superbobry you should inspect this error report regarding your request for tests compared to libc -- libc is grossly out of date compared to the spec, producing thousands of wrong results! presumably libc conforms to a posix standard that conforms to a unicode specification that is about 10+ years behind today's monospaced fonts. unicode specifications provide accurate report, will continue my efforts to work against those. how else would you know the true width of a snowman, afterall. libc=-1, ours=1, name=SNOWMAN WITHOUT SNOW, url http://codepoints.net/U+26C4 --oo⛄oo-- [ I do see a few errors, esp. regarding combining, (report as 1 but should actually be -1), but this is unicodedata.combining() reporting that they are not when they most certainly are. not sure if i want to fix that far in. ] |
@jquast thank you, you've done an impressive amount of work with this! I'll try to change I don't see any issues with being incompatible with libc as long as |
I've released to pypi, https://pypi.python.org/pypi/wcwidth Took a lot of (manual, visual) testing -- its all plugged into travis and coveralls -- let me know if you have any suggestions, there is some ambiguous areas regarding control, combining, and emoticon characters. |
I've been thinking about integrating def draw(self, ch):
# ...
width = wcswidth(ch)
for offset in range(width - 1):
self.buffer[self.cursor.y][self.cursor.x] = stub_character but this is obviously a nasty hack, which might require more hacks in the future. For instance, imagine we have the following character matrix ["コ", S]
^
|
cursor is here where screen.insert_characters(1) We need to insert an empty character right after the cursor erasing whatever there is, but the current character has |
I think we should replace the stub character by a space. Try this: echo -e "你好\e[Dx" # Print double width characters, move cursor one position left and print an 'x' You'll see that we get a space there. (on some terminals, you should use |
I've tried this in Guake with $ echo -e "你好\e[Dx"
你好x Can you post the expected output? |
I think it should print:
(We print "你好", cursor one position left, and print 'x') Just tried xfce4-terminal. He prints the left half of the 好 character, and prints the letter 'x' on top of the right part. |
I've finally managed to add this to |
Currently I'm using following hack in my program:
there should be a similar but cleaner way to determine character width, and especially, there is a set of "east-asian ambiguous width" characters, its width depends on locale, I treat it as fullwidth (*2) in my case.
http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt
https://github.com/buganini/bsdconv/blob/master/codecs/inter/WIDTH.c
The text was updated successfully, but these errors were encountered: