| 54 | 54 |
}
|
| 55 | 55 |
|
| 56 | 56 |
// NewBarFiller returns a BarFiller implementation which renders a
|
| 57 | |
// classic progress bar. To be used with *Progress.Add(...) *Bar method.
|
|
57 |
// progress bar in regular direction. If style is empty string,
|
|
58 |
// BarDefaultStyle is applied. To be used with `*Progress.Add(...)
|
|
59 |
// *Bar` method.
|
| 58 | 60 |
func NewBarFiller(style string) BarFiller {
|
| 59 | |
return NewBarFillerRev(style, func() bool { return false })
|
|
61 |
return newBarFiller(style, false)
|
| 60 | 62 |
}
|
| 61 | 63 |
|
| 62 | |
// NewBarFillerRev same as NewBarFiller but with explicit reverse option.
|
| 63 | |
func NewBarFillerRev(style string, rev func() bool) BarFiller {
|
|
64 |
// NewBarFillerRev returns a BarFiller implementation which renders a
|
|
65 |
// progress bar in reverse direction. If style is empty string,
|
|
66 |
// BarDefaultStyle is applied. To be used with `*Progress.Add(...)
|
|
67 |
// *Bar` method.
|
|
68 |
func NewBarFillerRev(style string) BarFiller {
|
|
69 |
return newBarFiller(style, true)
|
|
70 |
}
|
|
71 |
|
|
72 |
// PickBarFiller pick between regular and reverse BarFiller implementation
|
|
73 |
// based on rev param. To be used with `*Progress.Add(...) *Bar` method.
|
|
74 |
func PickBarFiller(style string, rev bool) BarFiller {
|
|
75 |
return newBarFiller(style, rev)
|
|
76 |
}
|
|
77 |
|
|
78 |
func newBarFiller(style string, rev bool) BarFiller {
|
| 64 | 79 |
bf := &barFiller{
|
| 65 | |
reverse: rev(),
|
| 66 | 80 |
format: make([][]byte, len(BarDefaultStyle)),
|
| 67 | 81 |
rwidth: make([]int, len(BarDefaultStyle)),
|
|
82 |
reverse: rev,
|
| 68 | 83 |
}
|
| 69 | 84 |
bf.parse(BarDefaultStyle)
|
| 70 | 85 |
if style != "" && style != BarDefaultStyle {
|