bar filler: refill path
refill path needs to fill filling first
Vladimir Bauer
2 years ago
| 207 | 207 | |
| 208 | 208 | var tip component |
| 209 | 209 | var refilling, filling, padding []byte |
| 210 | var fillCount, refWidth int | |
| 210 | var fillCount int | |
| 211 | 211 | curWidth := int(internal.PercentageRound(stat.Total, stat.Current, uint(width))) |
| 212 | 212 | |
| 213 | 213 | if curWidth != 0 && !stat.Completed || s.tipOnComplete { |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | if stat.Refill != 0 { |
| 220 | refWidth = int(internal.PercentageRound(stat.Total, stat.Refill, uint(width))) | |
| 220 | refWidth := int(internal.PercentageRound(stat.Total, stat.Refill, uint(width))) | |
| 221 | 221 | curWidth -= refWidth |
| 222 | 222 | refWidth += curWidth |
| 223 | } | |
| 224 | ||
| 225 | for curWidth-fillCount >= s.components[iFiller].width { | |
| 226 | filling = append(filling, s.components[iFiller].bytes...) | |
| 227 | fillCount += s.components[iFiller].width | |
| 228 | } | |
| 229 | ||
| 230 | for refWidth-fillCount >= s.components[iRefiller].width { | |
| 231 | refilling = append(refilling, s.components[iRefiller].bytes...) | |
| 232 | fillCount += s.components[iRefiller].width | |
| 223 | for curWidth-fillCount >= s.components[iFiller].width { | |
| 224 | filling = append(filling, s.components[iFiller].bytes...) | |
| 225 | fillCount += s.components[iFiller].width | |
| 226 | } | |
| 227 | for refWidth-fillCount >= s.components[iRefiller].width { | |
| 228 | refilling = append(refilling, s.components[iRefiller].bytes...) | |
| 229 | fillCount += s.components[iRefiller].width | |
| 230 | } | |
| 231 | } else { | |
| 232 | for curWidth-fillCount >= s.components[iFiller].width { | |
| 233 | filling = append(filling, s.components[iFiller].bytes...) | |
| 234 | fillCount += s.components[iFiller].width | |
| 235 | } | |
| 233 | 236 | } |
| 234 | 237 | |
| 235 | 238 | for width-fillCount >= s.components[iPadding].width { |