Codebase list golang-github-vbauerster-mpb / 39c0c7d
make sure BarStyle, BarReverse doesn't depend on order if BarFillerMiddleware used Vladimir Bauer 6 years ago
3 changed file(s) with 13 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
4343 type extFunc func(in io.Reader, reqWidth int, st decor.Statistics) (out io.Reader, lines int)
4444
4545 type bState struct {
46 filler BarFiller
4746 id int
47 priority int
4848 reqWidth int
4949 total int64
5050 current int64
5555 toComplete bool
5656 completeFlushed bool
5757 ignoreComplete bool
58 dropOnComplete bool
5859 noPop bool
5960 aDecorators []decor.Decorator
6061 pDecorators []decor.Decorator
6263 ewmaDecorators []decor.EwmaDecorator
6364 shutdownListeners []decor.ShutdownListener
6465 bufP, bufB, bufA *bytes.Buffer
66 filler BarFiller
67 middleware func(BarFiller) BarFiller
6568 extender extFunc
6669
67 // priority overrides *Bar's priority, if set
68 priority int
69 // dropOnComplete propagates to *Bar
70 dropOnComplete bool
7170 // runningBar is a key for *pState.parkedBars
7271 runningBar *Bar
7372
9090 // BarFillerMiddleware provides a way to augment default BarFiller.
9191 func BarFillerMiddleware(middle func(BarFiller) BarFiller) BarOption {
9292 return func(s *bState) {
93 s.filler = middle(s.filler)
93 s.middleware = middle
9494 }
9595 }
9696
338338
339339 func (s *pState) makeBarState(total int64, filler BarFiller, options ...BarOption) *bState {
340340 bs := &bState{
341 id: s.idCount,
342 priority: s.idCount,
343 reqWidth: s.reqWidth,
341344 total: total,
342345 filler: filler,
343 priority: s.idCount,
344 id: s.idCount,
345 reqWidth: s.reqWidth,
346 extender: func(r io.Reader, _ int, _ decor.Statistics) (io.Reader, int) { return r, 0 },
346347 debugOut: s.debugOut,
347 extender: func(r io.Reader, _ int, _ decor.Statistics) (io.Reader, int) {
348 return r, 0
349 },
350348 }
351349
352350 for _, opt := range options {
353351 if opt != nil {
354352 opt(bs)
355353 }
354 }
355
356 if bs.middleware != nil {
357 bs.filler = bs.middleware(filler)
356358 }
357359
358360 if s.popCompleted && !bs.noPop {