Skip to content
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

termbox-go v1.1.1 incompatibility issues and wide character related issues #322

Closed
404name opened this issue Dec 30, 2022 · 3 comments
Closed

Comments

@404name
Copy link

404name commented Dec 30, 2022

I've run the examples with utf8(Chinese) characters , but can't see right result in vscode

My vscode uses the system cmd, which is in UTF-8 format like the system cmd configuration. But when running the sample file, there are two results. There is an extra space in Chinese in vscode, and it occupies the position of other characters. I don’t know if there is a solution or it’s just a problem with my vocode configuration, thanks
image

@404name 404name closed this as completed Jan 3, 2023
@404name
Copy link
Author

404name commented Jan 3, 2023

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)
	}
}

image

@404name 404name reopened this Jan 3, 2023
@404name 404name changed the title UTF-8 characters have more spaces in vscode termbox-go v1.1.1 incompatibility issues and wide character related issues Jan 3, 2023
@404name
Copy link
Author

404name commented Jan 3, 2023

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

  1. copy the filehttps://github.com/nsf/termbox-go/blob/2ff630277754813b198ae96036e28e254d2c72bf/api_windows.go
  2. replace your local file$GOPATH\pkg\mod\github.com\nsf\[email protected]\api_windows.go
  3. Delete lines 130 to 134
  4. run before exec.Command("chcp","65001") If the system default encoding is gbk

by doing so,Any cmd window on the windows platform can be executed correctly

@gizak
Copy link
Owner

gizak commented Nov 11, 2023

@404name Hi I bumped termbox version in master branch, things should be fixed.

@gizak gizak closed this as completed Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants