refactoring tip assigment
Vladimir Bauer
4 years ago
| 169 | 169 | |
| 170 | 170 | var filling [][]byte |
| 171 | 171 | var padding [][]byte |
| 172 | var tip *component | |
| 173 | 172 | var refWidth int |
| 174 | 173 | curWidth := int(internal.PercentageRound(stat.Total, stat.Current, width)) |
| 175 | 174 | filled := curWidth |
| 176 | 175 | |
| 177 | if stat.Current == stat.Total { | |
| 178 | if s.tip.onCompleteIndex >= uint(len(s.tip.frames)) { | |
| 179 | s.tip.onCompleteIndex = 0 | |
| 180 | } | |
| 181 | tip = s.tip.frames[s.tip.onCompleteIndex] | |
| 182 | } else { | |
| 183 | tip = s.tip.frames[s.tip.count%uint(len(s.tip.frames))] | |
| 184 | } | |
| 176 | tip := s.tip.frames[s.tip.count%uint(len(s.tip.frames))] | |
| 185 | 177 | |
| 186 | 178 | if s.tip.inclusive { |
| 187 | 179 | if curWidth > 0 { |
| 180 | if stat.Current == stat.Total { | |
| 181 | if s.tip.onCompleteIndex >= uint(len(s.tip.frames)) { | |
| 182 | s.tip.onCompleteIndex = 0 | |
| 183 | } | |
| 184 | tip = s.tip.frames[s.tip.onCompleteIndex] | |
| 185 | } | |
| 188 | 186 | filling = append(filling, tip.bytes) |
| 189 | 187 | curWidth -= tip.width |
| 190 | 188 | s.tip.count++ |