mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-23 22:24:51 +02: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:
@@ -217,6 +217,30 @@ type DisabledReason struct {
|
||||
ShowErrorInPanel bool
|
||||
}
|
||||
|
||||
type MenuWidget int
|
||||
|
||||
const (
|
||||
MenuWidgetNone MenuWidget = iota
|
||||
MenuWidgetRadioButtonSelected
|
||||
MenuWidgetRadioButtonUnselected
|
||||
MenuWidgetCheckboxSelected
|
||||
MenuWidgetCheckboxUnselected
|
||||
)
|
||||
|
||||
func MakeMenuRadioButton(value bool) MenuWidget {
|
||||
if value {
|
||||
return MenuWidgetRadioButtonSelected
|
||||
}
|
||||
return MenuWidgetRadioButtonUnselected
|
||||
}
|
||||
|
||||
func MakeMenuCheckBox(value bool) MenuWidget {
|
||||
if value {
|
||||
return MenuWidgetCheckboxSelected
|
||||
}
|
||||
return MenuWidgetCheckboxUnselected
|
||||
}
|
||||
|
||||
type MenuItem struct {
|
||||
Label string
|
||||
|
||||
@@ -232,6 +256,12 @@ type MenuItem struct {
|
||||
// item, as opposed to having to navigate to it
|
||||
Key Key
|
||||
|
||||
// A widget to show in front of the menu item. Supported widget types are
|
||||
// checkboxes and radio buttons,
|
||||
// This only handles the rendering of the widget; the behavior needs to be
|
||||
// provided by the client.
|
||||
Widget MenuWidget
|
||||
|
||||
// The tooltip will be displayed upon highlighting the menu item
|
||||
Tooltip string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user