CJK contents does not display correctly in termui

Labels: kind/bug

Timeline

ProgramFan (ProgramFan) opened

When I add issues in Chinese, the characters are not displayed correctly in termui. For example, I get default for default

Michael Muré (MichaelMure) commented

I looked at this, and it's actually a problem in git-bug, not in gocui. Working on a fix.

Michael Muré (MichaelMure) added label kind/bug

Michael Muré (MichaelMure) commented

Could you try the latest revision from git to see if it's fixed ?

ProgramFan (ProgramFan) commented (edited)

Still not working, why? default Shall be: default

ProgramFan (ProgramFan) commented (edited)

I found that the Chinese characters are skipped interleavedly. Like the above example:

LibFind 支 Targets,便

The ones in bold are skipped. The English chars are kept.

Michael Muré (MichaelMure) commented

Indeed, more fixes are needed. What happen is that the Chinese characters actually take two column in a terminal instead of always one as with the latin alphabet. It breaks an algorithm in git-bug, but it seems it also break gocui itself.

There is a PR with a fix in gocui (https://github.com/jroimartin/gocui/pull/173) but the project seems unmaintained for some month now.... That means I would need to fork gocui and maintain it ...

ProgramFan (ProgramFan) commented

After looking into the PR, I step into the fork from lazygit authors: https://github.com/jesseduffield/gocui, which seems to have fixed the problems (also 28+ commits newer than original gocui). This fork is used in lazygit, and it works: default

ProgramFan (ProgramFan) commented

I tried to replace the gocui module in go-bug, but it seems lazygit changed the calling signature.

termui/label_select.go:119:22: not enough arguments in call to g.SetView
	have (string, int, int, int, int)
	want (string, int, int, int, int, byte)

ProgramFan (ProgramFan) commented

I managed to replace gocui with that from lazygit and CJK contents are displayed correctly in termui. I am still fixing the block wrap and will submit a PR after that. default

ProgramFan (ProgramFan) commented

I just found your new commits handling these issues. Do you still want the PR?

Michael Muré (MichaelMure) commented

There is still LeftPadMaxLine to be fixed but it seems you have done it ? Could you do a PR for it ?

ProgramFan (ProgramFan) commented

Yes. Actually, we need to improve both LeftPadMaxLine and Wrap. I implement a simple algorithm in Wrap so that line breaks at both word boundary and multibyte chars, like that in vim with fomatoptions+=Mm. I am doing the PR.

Michael Muré (MichaelMure) commented

Fixed with #86

Michael Muré (MichaelMure) closed the bug