Skip to content

Commit

Permalink
Add mark for current cursor position
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkondr committed Feb 4, 2025
1 parent 4b9c653 commit 8faac1d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pkg/cli/tui/multi_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ var (
Background(lipgloss.AdaptiveColor{Light: "#E2EFFC", Dark: "#2F435B"})

// Selected checkbox symbol.
selectedCheckBox = "{X}"
selectedCheckBox = "[X]"

// Unselected checkbox symbol.
unselectedCheckbox = "{ }"
unselectedCheckbox = "[ ]"

// cursor current position symbol.
cursorSymbol = ">"

// ----------
// Key bindings.
Expand Down Expand Up @@ -205,18 +208,17 @@ func (m MultiSelect) View() string {
func drawLine(hover, checked bool, label string) string {
// Template contains: <option selected/unselected mark> <option label>
// Examples:
// {X} MySQL
// { } PostgreSQL
const tmpl = " %s %s"
// [X] MySQL
// [ ] PostgreSQL
const tmpl = " %s %s %s"
mark := selectedCheckBox
if !checked {
mark = unselectedCheckbox
}

s := fmt.Sprintf(tmpl, mark, label)
if hover {
return fmt.Sprintf("%s\n", hoverOptionStyle.Render(s))
return fmt.Sprintf("%s\n", hoverOptionStyle.Render(fmt.Sprintf(tmpl, cursorSymbol, mark, label)))
} else {
return fmt.Sprintf("%s\n", optionStyle.Render(s))
return fmt.Sprintf("%s\n", optionStyle.Render(fmt.Sprintf(tmpl, " ", mark, label)))
}
}

0 comments on commit 8faac1d

Please sign in to comment.