summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/picker/picker.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/internal/picker/picker.go b/internal/picker/picker.go
index 3094396..1c39aaa 100644
--- a/internal/picker/picker.go
+++ b/internal/picker/picker.go
@@ -2,6 +2,7 @@ package picker
import (
"fmt"
+ "strings"
"github.com/ChausseBenjamin/termpicker/internal/colors"
"github.com/ChausseBenjamin/termpicker/internal/slider"
@@ -108,25 +109,24 @@ func (m Model) Init() tea.Cmd {
return tea.Batch(cmds...)
}
-func (m Model) View() string {
- var s string
+func ViewSlider(active bool, s slider.Model) string {
+ if active {
+ return fmt.Sprintf("%s %s",
+ ui.Style().PickerCursor.Render(ui.PickerSelRune),
+ s.View(),
+ )
+ }
+ return fmt.Sprintf(" %s",
+ s.View(),
+ )
+}
- newline := ""
+func (m Model) View() string {
+ sliderList := make([]string, len(m.sliders))
for i, slider := range m.sliders {
- if i > 0 {
- newline = "\n"
- }
- if i == m.active {
- s += fmt.Sprintf("%v%s %s",
- newline,
- ui.Style().PickerCursor.Render(ui.PickerSelRune),
- slider.View(),
- )
- } else {
- s += fmt.Sprintf("%v %s", newline, slider.View())
- }
+ sliderList[i] = ViewSlider(i == m.active, slider)
}
- return s
+ return strings.Join(sliderList, "\n")
}
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {