diff --git a/bar.go b/bar.go index 41b2487..2eb74e2 100644 --- a/bar.go +++ b/bar.go @@ -17,7 +17,7 @@ // Filler interface. // Bar renders by calling Filler's Fill method. You can literally have // any bar kind, by implementing this interface and passing it to the -// mpb.Add function. +// *Progress.Add method. type Filler interface { Fill(w io.Writer, width int, stat *decor.Statistics) } @@ -27,6 +27,14 @@ func (f FillerFunc) Fill(w io.Writer, width int, stat *decor.Statistics) { f(w, width, stat) +} + +// BaseFiller interface. +// If you ever need to implement a custom Filler based on mpb.NewBarFiller, +// then you may need to implement this one as well, in order to retain +// functionality of some `BarOption`s and method like *Bar.SetRefill. +type BaseFiller interface { + BaseFiller() Filler } // Bar represents a progress Bar. diff --git a/progress.go b/progress.go index d6ed3f2..4a0f3c1 100644 --- a/progress.go +++ b/progress.go @@ -343,6 +343,10 @@ }, } + if f, ok := filler.(BaseFiller); ok { + bs.baseF = f.BaseFiller() + } + for _, opt := range options { if opt != nil { opt(bs)