Open ns-cn opened 2 years ago
When working with characters that occupy more than one cell, you have to handle it yourself. There are handy libs like: https://github.com/mattn/go-runewidth, which can help you with that. Sadly I don't have much experience with it. There are examples contributed by other people though which use runewidth lib:
Maybe try running them with Chinese input/text and if it works properly for you then look at the code. And I would suggest looking at alternative UI libs as well, such as https://github.com/rivo/tview. Proper text handling is complicated and most libs I saw use the mentioned above runewidth lib, e.g.: https://github.com/rivo/tview/blob/0e6b21a48e9606d07c6bf79171d6ce05d159f9f9/util.go#L456
My terminal application using github.com/jroimartin/gocui which based on
termbox-go
, but I found some display issues.The following issues are caused by setCell with Chinese character.
It works well when I tried to input Chinese characters one by one ,but characters overlapped likes this
Some characters disappear when I tried to input more than one Chinese characters , like this