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

How To: Use TextView with Spinner (io.Writer) like yacspin #462

Closed
ghostsquad opened this issue Jun 15, 2020 · 1 comment
Closed

How To: Use TextView with Spinner (io.Writer) like yacspin #462

ghostsquad opened this issue Jun 15, 2020 · 1 comment

Comments

@ghostsquad
Copy link

https://github.com/theckman/yacspin supports providing an io.Writer to write to via the spinner config. I tried just giving the spinner the TextView, and hooking up an "on changed" func per the wiki:

myTextView := tview.NewTextView()
myTextView.SetChangedFunc(func() {
	app.Draw()
})
menu.AddItem(myTextView, 1, 1, 1,1, 0, 0, false)

cfg := yacspin.Config{
	Frequency:         refreshInterval,
	CharSet:           yacspin.CharSets[14],
	StopCharacter:     "✓",
	StopColors:        []string{"fgGreen"},
	Writer: myTextView,
}

spinner, err := yacspin.New(cfg)
if err != nil {
	panic(err)
}

err = spinner.Start()
if err != nil {
	panic(err)
}

But I end up with this:

image

Ignoring for the moment the color incompatibility issue... it appears that the carriage return \r is not being respected, as that's I believe how yacspin returns the the beginning to rewrite.

Is there a correct way to do this?

@ghostsquad
Copy link
Author

I found an exceedingly simple alternative to yacspin that will work for my needs here: https://github.com/tj/go-spin

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

1 participant