-
Notifications
You must be signed in to change notification settings - Fork 372
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
Wide unicode characters take two units #18
Comments
The problem is that with termbox it has no control over the terminal which in turn draws runes. It's possible to make a termbox implementation which will be drawing runes by itself, but it was never done so far, at the moment I have only a terminal-based backend. So, termbox simply assumes that each rune takes exactly one terminal cell and I know this assumption is false for some CJK rune cases. But I will need to read more about it, when and why terminals draw double-width runes. Will think what can I do about this. |
Here's what I think. Even though it's possible to hack termbox so that it understands that CJK runes take 2 termbox cells, this approach isn't portable (on windows probably it doesn't work like that) and every termbox-based application should be aware of that fact too and handle the stuff in a special manner. So, I don't think I will do anything about it. If you want CJK support, hack termbox to suit your needs (it's a very simple library after all). Honestly I just don't know how to make it work using current termbox abstractions. Termbox was designed around a notion of "cells" and this thing breaks it really hard. Perhaps there are terminals which render CJK runes with width == 1, but not sure how readable is that. |
Thanks for getting back to it. Sure I'll try hacking it and send a pull request or something if I work out. I don't think terminals that render CJK with width == 1 would be readable at all... |
See also: #21 Should work now on linux/darwin. You can install https://github.com/nsf/godit to test it out. |
work on winxp,and ssh on ubuntu.
|
Looks like it's working now. Just tested on OS X with iTerm2. Thanks! |
I have to say the real output sequence is somthing like '\033[1;1H你\033[1;3H好\033[1;5H世\033[1;7H界' which inlcudes unnecessary CSI code. Anyway it is better than nothing. |
I recommend to use |
Hey, I was just trying out termbox (and it's great by the way!) and found out a problem for wide unicode characters. Actually it's a problem for wide runes displayed in fix-width font. My terminal (iTerm) prints wide characters twice as wide as ascii characters. As a result, if there's a wide rune, the drawn characters won't be aligned properly. Try this code:
I'm not sure what should be changed to fix it yet. Should it
The text was updated successfully, but these errors were encountered: