AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.08k stars 351 forks source link

Handle CJK input #274

Closed execjosh closed 4 years ago

execjosh commented 4 years ago

CJK runes are rendered using two cells in the console. So, look at the rune to decide how many cells to move during rendering.

I am not sure how to test this, though.

This fixes #272.

execjosh commented 4 years ago

So, main is redeclared inside some packages (i.e., v2/{test,exaple}s/), which is causing go get -v -t ./... (executed via travis_install_go_dependencies 1.12 -v) to fail. As far as I can tell, this problem has nothing to with the changes introduced by this pull request.

``` $ go get -v -t ./... github.com/AlecAivazis/survey/v2/examples github.com/AlecAivazis/survey/v2/tests # github.com/AlecAivazis/survey/v2/tests tests/confirm.go:41:6: main redeclared in this block previous declaration at tests/ask.go:29:6 tests/doubleSelect.go:9:5: simpleQs redeclared in this block previous declaration at tests/ask.go:10:5 tests/doubleSelect.go:28:6: main redeclared in this block previous declaration at tests/confirm.go:41:6 tests/editor.go:11:5: answer redeclared in this block previous declaration at tests/confirm.go:8:5 tests/editor.go:13:5: goodTable redeclared in this block previous declaration at tests/confirm.go:10:5 tests/editor.go:57:6: main redeclared in this block previous declaration at tests/doubleSelect.go:28:6 tests/help.go:16:5: goodTable redeclared in this block previous declaration at tests/editor.go:13:5 tests/help.go:53:6: main redeclared in this block previous declaration at tests/editor.go:57:6 tests/input.go:29:6: main redeclared in this block previous declaration at tests/help.go:53:6 tests/longSelect.go:5:6: main redeclared in this block previous declaration at tests/input.go:29:6 tests/longSelect.go:5:6: too many errors # github.com/AlecAivazis/survey/v2/examples examples/longlist.go:32:6: main redeclared in this block previous declaration at examples/countrylist.go:265:6 examples/longmulti.go:265:6: main redeclared in this block previous declaration at examples/longlist.go:32:6 examples/map.go:10:5: simpleQs redeclared in this block previous declaration at examples/longlist.go:10:5 examples/map.go:28:6: main redeclared in this block previous declaration at examples/longmulti.go:265:6 examples/simple.go:10:5: simpleQs redeclared in this block previous declaration at examples/map.go:10:5 examples/simple.go:29:6: main redeclared in this block previous declaration at examples/map.go:28:6 examples/validation.go:30:6: main redeclared in this block previous declaration at examples/simple.go:29:6 ```
AlecAivazis commented 4 years ago

Ooo this is a much cleaner solution than what I've tried to do to fix this. Nice!

I fixed the CI issue in the v1 branch, will port that over now.

AlecAivazis commented 4 years ago

hey @execjosh! If you rebase onto the current master, you should pick up the fixes. Thanks for being patient

AlecAivazis commented 4 years ago

I think this also addresses an issue that @mritd ran into

execjosh commented 4 years ago

@AlecAivazis Great! Thanks for taking a look 😄 Hmm, I needed to go mod vendor it, otherwise the tests wouldn't run with GOFLAGS='-mod=vendor' set. Some of the previously vendored packages disappeared, though 🤷‍♂ Let me know if you prefer to just add golang.org/x/text and not remove the others.

execjosh commented 4 years ago

Great! Glad I was able to help 😄