refactoring WidthForBarFiller
Vladimir Bauer
6 years ago
| 98 | 98 |
}
|
| 99 | 99 |
|
| 100 | 100 |
func (s *barFiller) Fill(w io.Writer, reqWidth int, stat decor.Statistics) {
|
| 101 | |
width := internal.CalcWidthForBarFiller(reqWidth, stat.AvailableWidth)
|
|
101 |
width := internal.WidthForBarFiller(reqWidth, stat.AvailableWidth)
|
| 102 | 102 |
|
| 103 | 103 |
if brackets := s.rwidth[rLeft] + s.rwidth[rRight]; width < brackets {
|
| 104 | 104 |
return
|
| 40 | 40 |
}
|
| 41 | 41 |
|
| 42 | 42 |
func (s *spinnerFiller) Fill(w io.Writer, reqWidth int, stat decor.Statistics) {
|
| 43 | |
width := internal.CalcWidthForBarFiller(reqWidth, stat.AvailableWidth)
|
|
43 |
width := internal.WidthForBarFiller(reqWidth, stat.AvailableWidth)
|
| 44 | 44 |
|
| 45 | 45 |
frame := s.frames[s.count%uint(len(s.frames))]
|
| 46 | 46 |
frameWidth := utf8.RuneCountInString(frame)
|
| 0 | 0 |
package internal
|
| 1 | 1 |
|
| 2 | |
func CalcWidthForBarFiller(reqWidth, available int) int {
|
|
2 |
func WidthForBarFiller(reqWidth, available int) int {
|
| 3 | 3 |
if reqWidth <= 0 || reqWidth >= available {
|
| 4 | 4 |
return available
|
| 5 | 5 |
}
|