terminal widgets not support chinese
nxsre opened this issue · comments
Hi - thanks for your bug report. Could you help me understand your example a little better? I think your screenshot shows filenames in a list. Am I right that those filenames contain GBK characters? Do you know what encoding is used for the names when the files are saved e.g. UTF-8, or maybe if it's Windows it's a specific codepage? Would it be possible for you to share some of your example code to help me understand?
In looking into this, I have found that there are several places in gowid that do not correctly handle runes that need >1 screen cell to display (independent of encoding). I'll open a separate issue for that.
Ah, thanks @soopsio , I misunderstood - the problem's in the terminal widget. I'll investigate!
I'm really looking forward to it. I'm thinking about using it in a production environment.
Hi - I've pushed some changes to the branch widerunes on github, all around
non-ASCII characters in gowid - runes that take up >1 space when rendered, and
also some bugs handling UTF-8-encoded runes. Please do give it a try and let
me know. There are tests, but I don't consider this solid yet. If you have
module support in go (1.11 or higher), you can start a project using the
widerunes branch with something like this:
$ mkdir project
$ cd project
$ export GO111MODULE=on
$ go mod init project
$ go get github.com/gcla/gowid@widerunes
Then your go files under project/ that use gowid will compile against the
widerunes branch.
Your English is very good and much better than my Mandarin! ;-)
I am having trouble trying to make these artifacts appear. I see the problem in your screenshot - the a, b, i at the start of the prompt. I can't trigger it on my linux laptop. Would it be possible for you to send your .zshrc? Maybe some setting in there will help me reproduce the problem. Thanks!
Uploading attachments always fails, so I removed the comments and pasted the text.
the zshrc:
`
export ZSH=/Users/****/.oh-my-zsh
ZSH_THEME="agnoster"
plugins=(
git zsh-autosuggestions zsh-syntax-highlighting
)
source $ZSH/oh-my-zsh.sh
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
DEFAULT_USER="****"
`
Unfortunately I still can't reproduce it. :-( I have two more favors to ask. When you're running your go terminal widget application, at the shell prompt, type
$ script
It'll start another zsh. If you can then reproduce the problem i.e. your display shows unexpected artifacts, like characters in the wrong place, then exit the shell and there should be a file called typescript in the directory. If you look with an editor, you'll see the commands you typed, along with a bunch of ansi terminal codes that are emitted by zsh. I'd love to be able to see that file - I can then type
$ cat typescript
in my terminal to replay your session and see if I see the same artifacts. I think that typescript should have nothing more sensitive/private in it than the screenshot above. Second favor - could you tell me the terminal application (and OS) and the value of $TERM? Many thanks!
It is easier to reproduce character errors at the bottom of the terminal widget
typescript 2.zip
Sorry I've not had time the last couple of days to look at this, but will try this weekend. I'm sorry to keep asking you for data - but looking at the typescript above, I think you generated it something like this
$ script
$ go run tui.go
... gowid app runs, draws three terminals...
... exit app
$ exit
My initial instructions weren't very good - would it be possible to generate the typescript from within your app instead? So something like this
$ go run tui.go
... gowid app runs, draws three terminals...
... in main terminal, run script
... show weird characters appearing
... exit script
... exit app
This is typescript documented in the main terminal
typescript.gz
Please could you try setting this in your environment before running your tui.go program?
export RUNEWIDTH_EASTASIAN=0
I need to understand better how go-runewidth works, but I was able to reproduce similar artifacts by artificially setting that variable to 1 in my environment. Without the variable, go-runewidth guesses an appropriate value based on LANG, locale, etc - so for you I expect the value is on by default and for me it's off.
Thanks!
Perfect, problem solved after setting RUNEWIDTH_EASTASIAN=0.
There is also a problem found when typing Chinese, will echo twice.
typescript.zip
Thanks for the new bug report. I've pushed a change to master that I think fixes this issue. Would you let me know if it doesn't work for you?
There are no more questions now. Thanks!