[GH-ISSUE #462] How To: Use TextView with Spinner (io.Writer) like yacspin #331

Closed
opened 2026-03-04 01:04:05 +03:00 by kerem · 1 comment
Owner

Originally created by @ghostsquad on GitHub (Jun 15, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/462

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?

Originally created by @ghostsquad on GitHub (Jun 15, 2020). Original GitHub issue: https://github.com/rivo/tview/issues/462 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: ```go 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: <img width="227" alt="image" src="https://user-images.githubusercontent.com/903488/84618167-39fdb380-ae86-11ea-9b74-807181128dce.png"> 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?
kerem closed this issue 2026-03-04 01:04:05 +03:00
Author
Owner

@ghostsquad commented on GitHub (Jun 17, 2020):

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

<!-- gh-comment-id:645107176 --> @ghostsquad commented on GitHub (Jun 17, 2020): I found an exceedingly simple alternative to yacspin that will work for my needs here: https://github.com/tj/go-spin
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#331
No description provided.