-
Notifications
You must be signed in to change notification settings - Fork 608
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
Visually wide character support #74
base: master
Are you sure you want to change the base?
Conversation
forgot to mention |
First of all, thanks for your contribution! :) I'm in the process of rewriting the edition mode (issue #60) and I'd prefer to finish it before considering to merge PRs that can be incompatible with this refactoring. Also, this rewrite should fix several issues like the null byte one that you mentioned. Of course, I'll take into account your PR because I'd definitely like to support variable width runes in the new version. |
But need to wait to merge jroimartin/gocui#74
I encountered the same problem, I'm using mattn/go-runewidth as a solution for now. hope this problem can get properly solved. |
@jroimartin |
@jroimartin Will reconsider including this please? Thanks for your library and it works almost well but missing wide characters support is very critical issue. For example, jesseduffield/lazygit depends on this library and commit messages including wide characters mess up. Thanks. |
@itchyny I may as well say this here :) I'm going to merge this PR into my gocui fork because it seems to do the trick. If it ends up being merged into the main gocui repo down the line I'll revisit this and try to stay at parity with the main repo. @jroimartin Thankyou for all your effort so far with gocui it's been a massive help to me :) |
It is currently assumed a rune is exactly 1 column wide. Drawing japanese hiragana for example results in only half of the runes in
View.lines
to be copied toView.viewLines
(visually) because the x offset of each character, as passed tov.setRune
, is incremented by 1 instead of 2.Same goes for wrapping and most methods in editor.go.
What does the
nul
byte in editor.go's writeRune do? It breaks unicode code points that contain that byte, which results in every hiragana character to be (visually) separated with a space after a call toView.Buffer
. This should be fixed inView.Buffer
andView.ViewBuffer
but since I'm not sure of its use, you should double check my 'fix'.I think most changes should not break existing code that uses gocui except for
MoveCursor
which now moves entire runes instead of columns. It would be trivial to rename this though and expose the originalmoveCursor
again.I have only done some really basic testing with demo.go and my own cli-app that uses gocui.
ps: I'm no unicode nor mattn/go-runewidth expert by any means so forgive me if I did something stupid ;)
And thank for your great work on gocui btw.