Codebase list golang-github-vbauerster-mpb / f97705a
minor: onComplete inside tip Vladimir Bauer 1 year, 10 months ago
1 changed file(s) with 10 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
4949 }
5050
5151 type bFiller struct {
52 components [components]component
53 meta [components]func(io.Writer, []byte) error
54 flush func(io.Writer, ...flushSection) error
55 tipOnComplete bool
56 tip struct {
57 frames []component
58 count uint
52 components [components]component
53 meta [components]func(io.Writer, []byte) error
54 flush func(io.Writer, ...flushSection) error
55 tip struct {
56 onComplete bool
57 count uint
58 frames []component
5959 }
6060 }
6161
154154
155155 func (s barStyle) Build() BarFiller {
156156 bf := &bFiller{
157 meta: s.metaFuncs,
158 tipOnComplete: s.tipOnComplete,
157 meta: s.metaFuncs,
159158 }
160159 bf.components[iLbound] = component{
161160 width: runewidth.StringWidth(s.style[iLbound]),
177176 width: runewidth.StringWidth(s.style[iPadding]),
178177 bytes: []byte(s.style[iPadding]),
179178 }
179 bf.tip.onComplete = s.tipOnComplete
180180 bf.tip.frames = make([]component, len(s.tipFrames))
181181 for i, t := range s.tipFrames {
182182 bf.tip.frames[i] = component{
235235 curWidth := int(internal.PercentageRound(stat.Total, stat.Current, uint(width)))
236236
237237 if curWidth != 0 {
238 if !stat.Completed || s.tipOnComplete {
238 if !stat.Completed || s.tip.onComplete {
239239 tip = s.tip.frames[s.tip.count%uint(len(s.tip.frames))]
240240 s.tip.count++
241241 fillCount += tip.width