diff --git a/bar.go b/bar.go index 643941e..58c59a1 100644 --- a/bar.go +++ b/bar.go @@ -50,6 +50,7 @@ reqWidth int total int64 current int64 + refill int64 lastN int64 iterated bool trimSpace bool @@ -132,13 +133,8 @@ // Given default bar style is "[=>-]<+", refill rune is '+'. // To set bar style use mpb.BarStyle(string) BarOption. func (b *Bar) SetRefill(amount int64) { - type refiller interface { - SetRefill(int64) - } b.operateState <- func(s *bState) { - if f, ok := s.baseF.(refiller); ok { - f.SetRefill(amount) - } + s.refill = amount } } @@ -446,10 +442,11 @@ func newStatistics(tw int, s *bState) decor.Statistics { return decor.Statistics{ ID: s.id, - Completed: s.completeFlushed, + AvailableWidth: tw, Total: s.total, Current: s.current, - AvailableWidth: tw, + Refill: s.refill, + Completed: s.completeFlushed, } } diff --git a/bar_filler_bar.go b/bar_filler_bar.go index 8a2143f..2b6d31a 100644 --- a/bar_filler_bar.go +++ b/bar_filler_bar.go @@ -94,10 +94,6 @@ s.reverse = reverse } -func (s *barFiller) SetRefill(amount int64) { - s.refill = amount -} - func (s *barFiller) Fill(w io.Writer, reqWidth int, stat decor.Statistics) { width := internal.WidthForBarFiller(reqWidth, stat.AvailableWidth) @@ -126,8 +122,8 @@ index++ } - if s.refill > 0 { - refill = int(internal.PercentageRound(stat.Total, int64(s.refill), width)) - index + if stat.Refill > 0 { + refill = int(internal.PercentageRound(stat.Total, int64(stat.Refill), width)) - index if refill > cwidth { refill = cwidth } diff --git a/decor/decorator.go b/decor/decorator.go index 206fe79..e81fae3 100644 --- a/decor/decorator.go +++ b/decor/decorator.go @@ -48,10 +48,11 @@ // may need. type Statistics struct { ID int - Completed bool + AvailableWidth int Total int64 Current int64 - AvailableWidth int + Refill int64 + Completed bool } // Decorator interface.