in internal/pkg/term/progress/spinner.go [94:123]
func (s *Spinner) Events(events []TabRow) {
done := make(chan struct{})
go func() {
s.lock()
defer s.unlock()
// Erase previous entries, and move the cursor back to the spinner.
for i := 0; i < len(s.pastEvents); i++ {
s.cur.Down(1)
s.cur.EraseLine()
}
if len(s.pastEvents) > 0 {
s.cur.Up(len(s.pastEvents))
}
// Add new status updates, and move cursor back to the spinner.
for _, event := range events {
fmt.Fprintf(s.eventsWriter, "\n%s", event)
}
s.eventsWriter.Flush()
if len(events) > 0 {
s.cur.Up(len(events))
}
// Move the cursor to the beginning so the spinner can delete the existing line.
fmt.Fprintf(s.eventsWriter, "\r")
s.eventsWriter.Flush()
s.pastEvents = events
close(done)
}()
<-done
}