make sure spinner's frame not skipped
Vladimir Bauer
7 years ago
| 25 | 25 |
type spinnerDecorator struct {
|
| 26 | 26 |
WC
|
| 27 | 27 |
frames []string
|
|
28 |
count uint
|
| 28 | 29 |
complete *string
|
| 29 | 30 |
}
|
| 30 | 31 |
|
|
| 32 | 33 |
if st.Completed && d.complete != nil {
|
| 33 | 34 |
return d.FormatMsg(*d.complete)
|
| 34 | 35 |
}
|
| 35 | |
frame := d.frames[st.Current%int64(len(d.frames))]
|
|
36 |
frame := d.frames[d.count%uint(len(d.frames))]
|
|
37 |
d.count++
|
| 36 | 38 |
return d.FormatMsg(frame)
|
| 37 | 39 |
}
|
| 38 | 40 |
|
| 21 | 21 |
|
| 22 | 22 |
type spinnerFiller struct {
|
| 23 | 23 |
frames []string
|
|
24 |
count uint
|
| 24 | 25 |
alignment SpinnerAlignment
|
| 25 | 26 |
}
|
| 26 | 27 |
|
| 27 | 28 |
func (s *spinnerFiller) Fill(w io.Writer, width int, stat *decor.Statistics) {
|
| 28 | 29 |
|
| 29 | |
frame := s.frames[stat.Current%int64(len(s.frames))]
|
|
30 |
frame := s.frames[s.count%uint(len(s.frames))]
|
| 30 | 31 |
frameWidth := utf8.RuneCountInString(frame)
|
| 31 | 32 |
|
| 32 | 33 |
if width < frameWidth {
|
|
| 42 | 43 |
case SpinnerOnRight:
|
| 43 | 44 |
io.WriteString(w, strings.Repeat(" ", rest)+frame)
|
| 44 | 45 |
}
|
|
46 |
s.count++
|
| 45 | 47 |
}
|