DefaultBarStyle -> BarDefaultStyle
Vladimir Bauer
5 years ago
| 19 | 19 |
rRefill
|
| 20 | 20 |
)
|
| 21 | 21 |
|
| 22 | |
// DefaultBarStyle is a string containing 7 runes.
|
| 23 | |
// Each rune is a building block of a progress bar.
|
|
22 |
// BarDefaultStyle is a style for rendering a progress bar.
|
|
23 |
// It consist of 7 ordered runes:
|
| 24 | 24 |
//
|
| 25 | 25 |
// '1st rune' stands for left boundary rune
|
| 26 | 26 |
//
|
|
| 36 | 36 |
//
|
| 37 | 37 |
// '7th rune' stands for refill rune
|
| 38 | 38 |
//
|
| 39 | |
const DefaultBarStyle string = "[=>-]<+"
|
|
39 |
const BarDefaultStyle string = "[=>-]<+"
|
| 40 | 40 |
|
| 41 | 41 |
type barFiller struct {
|
| 42 | 42 |
format [][]byte
|
|
| 62 | 62 |
// NewBarFillerRev same as NewBarFiller but with explicit reverse option.
|
| 63 | 63 |
func NewBarFillerRev(style string, rev func() bool) BarFiller {
|
| 64 | 64 |
bf := &barFiller{
|
| 65 | |
format: make([][]byte, len(DefaultBarStyle)),
|
| 66 | |
rwidth: make([]int, len(DefaultBarStyle)),
|
| 67 | 65 |
reverse: rev(),
|
|
66 |
format: make([][]byte, len(BarDefaultStyle)),
|
|
67 |
rwidth: make([]int, len(BarDefaultStyle)),
|
| 68 | 68 |
}
|
| 69 | |
bf.parse(DefaultBarStyle)
|
| 70 | |
if style != "" && style != DefaultBarStyle {
|
|
69 |
bf.parse(BarDefaultStyle)
|
|
70 |
if style != "" && style != BarDefaultStyle {
|
| 71 | 71 |
bf.parse(style)
|
| 72 | 72 |
}
|
| 73 | 73 |
return bf
|
| 96 | 96 |
|
| 97 | 97 |
// AddBar creates a new progress bar and adds it to the rendering queue.
|
| 98 | 98 |
func (p *Progress) AddBar(total int64, options ...BarOption) *Bar {
|
| 99 | |
return p.Add(total, NewBarFiller(DefaultBarStyle), options...)
|
|
99 |
return p.Add(total, NewBarFiller(BarDefaultStyle), options...)
|
| 100 | 100 |
}
|
| 101 | 101 |
|
| 102 | 102 |
// AddSpinner creates a new spinner bar and adds it to the rendering queue.
|