summaryrefslogtreecommitdiff
path: root/internal/progress/progress.go
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2025-01-16 00:20:12 -0500
committerGitHub <noreply@github.com>2025-01-16 00:20:12 -0500
commit7d2afe1ca176d0eb76f65523ed7ebcbca702d0c1 (patch)
tree148d0f8da77686ff7d713d8a233b3545b7994e2a /internal/progress/progress.go
parentf438213c56fb072bbd3dc1aed0fd7e901181a7b9 (diff)
Central UI (#26)
* migrate to urfave/cli V3 * Remove slider background * Force the use of TrueColor everywhere * All ui info in one location * Fix BinaryFill Example * Make unfocused tabs more faint * Fix color input width * Ctrl-c overrides color input and quits termpicker * docs: remove redundant comment * fix: refactor picker View()
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(),
)
}
}