diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-10-24 12:02:39 -0400 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2024-10-24 12:02:39 -0400 |
commit | d6c5530b35743d1a2f153f942f508ca0768870af (patch) | |
tree | 1374ab8394ed9ad7a2720f5c158426a54b89b7b5 /internal/slider/slider.go | |
parent | 7277fa994838474ced8dc61a5f5002cb269685e8 (diff) |
Diffstat (limited to 'internal/slider/slider.go')
-rw-r--r-- | internal/slider/slider.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/internal/slider/slider.go b/internal/slider/slider.go index 0c0a89e..e882a29 100644 --- a/internal/slider/slider.go +++ b/internal/slider/slider.go @@ -51,8 +51,13 @@ func (s Slider) Dec(val int) (tea.Model, tea.Cmd) { return s.Set(s.val - val) } -func (s Slider) View() string { - return s.bar.View() + fmt.Sprintf(" (%d)", s.val) +func (s Slider) Val() int { + return s.val +} + +func New(name string, v int, maxV int, opt ...progress.Option) *Slider { + opt = append(opt, progress.WithoutPercentage()) + return &Slider{name: name, max: maxV, val: v, options: opt} } func (s Slider) Animate(msg tea.Msg) (tea.Model, tea.Cmd) { @@ -66,9 +71,8 @@ func (s Slider) Init() tea.Cmd { return s.bar.Init() } -func New(name string, v int, maxV int, opt ...progress.Option) *Slider { - opt = append(opt, progress.WithoutPercentage()) - return &Slider{name: name, max: maxV, val: v, options: opt} +func (s Slider) View() string { + return s.bar.View() + fmt.Sprintf(" (%d)", s.val) } func (s Slider) Update(msg tea.Msg) (tea.Model, tea.Cmd) { @@ -103,3 +107,11 @@ func (s Slider) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } // }}} +// Implement the list.Item interface {{{ + +func (s Slider) FilterValue() string { + // Sliders shouldn't be filtered + return "" +} + +// }}} |