mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Support showing checkboxes or radio buttons in menus
For checkboxes it probably doesn't really make sense to use them yet, because we'd have to find a way how you can toggle them without closing the dialog; but we already provide rendering for them to lay the ground. But radio buttons can be used already, because for those it is ok to close the dialog when choosing a different option (as long as there is only one grounp of radio buttons in the panel, that is).
This commit is contained in:
@ -107,7 +107,21 @@ func (self *MenuViewModel) GetDisplayStrings(_ int, _ int) [][]string {
|
||||
keyLabel = style.FgCyan.Sprint(keybindings.LabelFromKey(item.Key))
|
||||
}
|
||||
|
||||
displayStrings = utils.Prepend(displayStrings, keyLabel)
|
||||
checkMark := ""
|
||||
switch item.Widget {
|
||||
case types.MenuWidgetNone:
|
||||
// do nothing
|
||||
case types.MenuWidgetRadioButtonSelected:
|
||||
checkMark = "(•)"
|
||||
case types.MenuWidgetRadioButtonUnselected:
|
||||
checkMark = "( )"
|
||||
case types.MenuWidgetCheckboxSelected:
|
||||
checkMark = "[✓]"
|
||||
case types.MenuWidgetCheckboxUnselected:
|
||||
checkMark = "[ ]"
|
||||
}
|
||||
|
||||
displayStrings = utils.Prepend(displayStrings, keyLabel, checkMark)
|
||||
return displayStrings
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user