refill refactoring
Vladimir Bauer
4 years ago
| 198 | 198 | |
| 199 | 199 | if stat.Refill > 0 { |
| 200 | 200 | refWidth := int(internal.PercentageRound(stat.Total, stat.Refill, uint(width))) |
| 201 | available := curWidth | |
| 202 | bound := available - refWidth | |
| 203 | for i := len(filling) - 1; available > bound && i > 0; i-- { | |
| 201 | if refWidth == curWidth { | |
| 202 | refWidth -= tip.width | |
| 203 | } | |
| 204 | for i := len(filling) - 1; i >= 0; i-- { | |
| 205 | if refWidth < s.components[iRefiller].width { | |
| 206 | break | |
| 207 | } | |
| 204 | 208 | filling[i] = s.components[iRefiller].bytes |
| 205 | available -= s.components[iRefiller].width | |
| 209 | refWidth -= s.components[iRefiller].width | |
| 206 | 210 | } |
| 207 | 211 | } |
| 208 | 212 |