minor: onComplete inside tip
Vladimir Bauer
1 year, 10 months ago
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | 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 | |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
| 154 | 154 | |
| 155 | 155 | func (s barStyle) Build() BarFiller { |
| 156 | 156 | bf := &bFiller{ |
| 157 | meta: s.metaFuncs, | |
| 158 | tipOnComplete: s.tipOnComplete, | |
| 157 | meta: s.metaFuncs, | |
| 159 | 158 | } |
| 160 | 159 | bf.components[iLbound] = component{ |
| 161 | 160 | width: runewidth.StringWidth(s.style[iLbound]), |
| 177 | 176 | width: runewidth.StringWidth(s.style[iPadding]), |
| 178 | 177 | bytes: []byte(s.style[iPadding]), |
| 179 | 178 | } |
| 179 | bf.tip.onComplete = s.tipOnComplete | |
| 180 | 180 | bf.tip.frames = make([]component, len(s.tipFrames)) |
| 181 | 181 | for i, t := range s.tipFrames { |
| 182 | 182 | bf.tip.frames[i] = component{ |
| 235 | 235 | curWidth := int(internal.PercentageRound(stat.Total, stat.Current, uint(width))) |
| 236 | 236 | |
| 237 | 237 | if curWidth != 0 { |
| 238 | if !stat.Completed || s.tipOnComplete { | |
| 238 | if !stat.Completed || s.tip.onComplete { | |
| 239 | 239 | tip = s.tip.frames[s.tip.count%uint(len(s.tip.frames))] |
| 240 | 240 | s.tip.count++ |
| 241 | 241 | fillCount += tip.width |