diff --git a/bar.go b/bar.go index dfe648c..92ef92c 100644 --- a/bar.go +++ b/bar.go @@ -193,10 +193,10 @@ } // SetRefill sets refill, if supported by underlying Filler. -func (b *Bar) SetRefill(upto int) { +func (b *Bar) SetRefill(amount int64) { b.operateState <- func(s *bState) { - if f, ok := s.filler.(interface{ SetRefill(int) }); ok { - f.SetRefill(upto) + if f, ok := s.filler.(interface{ SetRefill(int64) }); ok { + f.SetRefill(amount) } } } diff --git a/bar_filler.go b/bar_filler.go index 2a8be40..afd714a 100644 --- a/bar_filler.go +++ b/bar_filler.go @@ -21,9 +21,9 @@ var defaultBarStyle = "[=>-]<+" type barFiller struct { - format [][]byte - refillCount int - reverse bool + format [][]byte + refillAmount int64 + reverse bool } func newDefaultBarFiller() Filler { @@ -49,8 +49,8 @@ s.reverse = true } -func (s *barFiller) SetRefill(count int) { - s.refillCount = count +func (s *barFiller) SetRefill(amount int64) { + s.refillAmount = amount } func (s *barFiller) Fill(w io.Writer, width int, stat *decor.Statistics) { @@ -75,12 +75,12 @@ bb[i] = s.format[rFill] } - if s.refillCount > 0 { + if s.refillAmount > 0 { var rwidth int - if s.refillCount > cwidth { + if s.refillAmount > stat.Current { rwidth = cwidth } else { - rwidth = int(internal.Percentage(stat.Total, int64(s.refillCount), int64(width))) + rwidth = int(internal.Percentage(stat.Total, int64(s.refillAmount), int64(width))) } for i := 0; i < rwidth; i++ { bb[i] = s.format[rRefill]