summaryrefslogtreecommitdiff
path: root/internal/progress/progress.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/progress/progress.go')
-rw-r--r--internal/progress/progress.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/internal/progress/progress.go b/internal/progress/progress.go
index 1e00836..c6caade 100644
--- a/internal/progress/progress.go
+++ b/internal/progress/progress.go
@@ -107,6 +107,18 @@ func WithFillCharacters(steps []FillStep) Option {
}
}
+// WithBinaryFill results in a less granular but possible more widely compatible
+// progress bar as only two characters are used to represent completion of a
+// single block (full/complete and empty/incomplete).
+func WithBinaryFill() Option {
+ return func(m *Model) {
+ m.FillSteps = []FillStep{
+ {' ', 0.0},
+ {'█', 1.0},
+ }
+ }
+}
+
// WithoutPercentage hides the numeric percentage.
func WithoutPercentage() Option {
return func(m *Model) {
@@ -165,8 +177,6 @@ type Model struct {
// "Filled" sections of the progress bar.
FullColor string
- EmptyColor string
-
// Settings for rendering the numeric percentage.
ShowPercentage bool
PercentFormat string // a fmt string for a float
@@ -200,7 +210,6 @@ func New(opts ...Option) Model {
Width: defaultWidth,
FillSteps: defaultFillSteps(),
FullColor: "#7571F9",
- EmptyColor: "#606060",
ShowPercentage: true,
PercentFormat: " %3.0f%%",
colorProfile: termenv.ColorProfile(),
@@ -332,17 +341,13 @@ func (m Model) barView(b *strings.Builder, percent float64, textWidth int) {
b.WriteString(
termenv.String(string(step.rune)).
Foreground(m.color(color)).
- Background(m.color(m.EmptyColor)).
String(),
)
} else {
// Empty cell
emptyStep := m.FillSteps[0]
b.WriteString(
- termenv.String(string(emptyStep.rune)).
- Foreground(m.color(m.EmptyColor)).
- Background(m.color(m.EmptyColor)).
- String(),
+ termenv.String(string(emptyStep.rune)).String(),
)
}
}