summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-02-14 23:29:41 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-02-15 08:47:36 +1100
commiteb9134685a0ffd89771fb0d68b3c3ca33f06445f (patch)
treeb94a0ef96fbbc728125a2eef80210716f41fed9b /pkg/gui
parentd929b847867c696be5b9ea48ef52778157f00038 (diff)
refactor rebase menu panel
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/rebase_options_panel.go32
1 files changed, 10 insertions, 22 deletions
diff --git a/pkg/gui/rebase_options_panel.go b/pkg/gui/rebase_options_panel.go
index bf29d19c3..7ba3f45ab 100644
--- a/pkg/gui/rebase_options_panel.go
+++ b/pkg/gui/rebase_options_panel.go
@@ -7,33 +7,21 @@ import (
"github.com/jesseduffield/gocui"
)
-type option struct {
- value string
-}
-
-// GetDisplayStrings is a function.
-func (r *option) GetDisplayStrings(isFocused bool) []string {
- return []string{r.value}
-}
-
func (gui *Gui) handleCreateRebaseOptionsMenu(g *gocui.Gui, v *gocui.View) error {
- options := []*option{
- {value: "continue"},
- {value: "abort"},
- }
+ options := []string{"continue", "abort"}
if gui.State.WorkingTreeState == "rebasing" {
- options = append(options, &option{value: "skip"})
+ options = append(options, "skip")
}
- options = append(options, &option{value: "cancel"})
-
- handleMenuPress := func(index int) error {
- command := options[index].value
- if command == "cancel" {
- return nil
+ menuItems := make([]*menuItem, len(options))
+ for i, option := range options {
+ menuItems[i] = &menuItem{
+ displayString: option,
+ onPress: func() error {
+ return gui.genericMergeCommand(option)
+ },
}
- return gui.genericMergeCommand(command)
}
var title string
@@ -43,7 +31,7 @@ func (gui *Gui) handleCreateRebaseOptionsMenu(g *gocui.Gui, v *gocui.View) error
title = gui.Tr.SLocalize("RebaseOptionsTitle")
}
- return gui.createMenu(title, options, len(options), handleMenuPress)
+ return gui.createMenuNew(title, menuItems, createMenuOptions{showCancel: true})
}
func (gui *Gui) genericMergeCommand(command string) error {