Give the choice input the ability to have name/value choices delimited by a tab
@@ -143,6 +143,14 @@ func (m Model) View() string {
return strings.Join(lines, "")
}
+func (m Model) Value() string {
+ value := m.Model.Value()
+ if pos := strings.IndexRune(value, '\t'); pos >= 0 {
+ value = value[0:pos]
+ }
+ return value
+}
+
func viewChoice(value string, selected, highlighted, focused bool) string {
var choice strings.Builder
var checkboxStyle, choiceStyle termenv.Style
@@ -155,6 +163,9 @@ func viewChoice(value string, selected, highlighted, focused bool) string {
checkboxStyle = checkboxStyle.Bold()
choiceStyle = choiceStyle.Bold()
}
+ if pos := strings.IndexRune(value, '\t'); pos >= 0 {
+ value = value[pos+1:]
+ }
choice.WriteString("\n")
choice.WriteString(checkboxStyle.Styled("["))
