Closed 404name closed 1 year ago
The termbox-go v1.1.1 version handles wide characters and solves the problem I mentioned above. The code is roughly as follows. But it seems to be incompatible with 3.1.0 of the current project, and many sample files are out of order.
https://github.com/nsf/termbox-go/blob/master/api_windows.go#L121
for _, char := range diff.chars { if runewidth.RuneWidth(rune(char.char)) > 1 { char.attr |= common_lvb_leading_byte chars = append(chars, char) chars = append(chars, char_info{ char: char.char, attr: char.attr | common_lvb_trailing_byte, }) } else { chars = append(chars, char) } }
I got a perfect solution, if you encounter a situation similar to mine, and it is a windows platform. It is necessary to change the termbox-go version of this project and use utf-8 encoding to run. At the same time, it is necessary to delete the processing of adding spaces to wide characters in the Render() function of termbox-go (this is for GBK, utf-8 does not need it)
there are two problem i cant resolve
so here i just Modify locally
https://github.com/nsf/termbox-go/blob/2ff630277754813b198ae96036e28e254d2c72bf/api_windows.go
$GOPATH\pkg\mod\github.com\nsf\termbox-go@v0.0.0-20190121233118-02980233997d\api_windows.go
exec.Command("chcp","65001")
If the system default encoding is gbkby doing so,Any cmd window on the windows platform can be executed correctly
@404name Hi I bumped termbox version in master branch, things should be fixed.
I've run the examples with utf8(Chinese) characters , but can't see right result in vscode