diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-26 21:39:59 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-26 21:44:33 +1100 |
commit | 83757f10658415e48b22e2521885d42b712a5e37 (patch) | |
tree | 35665e4869d2f48c494a9d4ffce13717da34ef73 /pkg | |
parent | f2036b42e53e1fc647f431e08e078e5c96bc4352 (diff) |
limit size of menu panel
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/confirmation_panel.go | 7 | ||||
-rw-r--r-- | pkg/gui/gui.go | 14 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 24 |
3 files changed, 44 insertions, 1 deletions
diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go index 755d13f96..112f4769a 100644 --- a/pkg/gui/confirmation_panel.go +++ b/pkg/gui/confirmation_panel.go @@ -39,7 +39,8 @@ func (gui *Gui) closeConfirmationPrompt(g *gocui.Gui, returnFocusOnClose bool) e panic(err) } } - g.DeleteKeybindings("confirmation") + g.DeleteKeybinding("confirmation", gocui.KeyEnter, gocui.ModNone) + g.DeleteKeybinding("confirmation", gocui.KeyEsc, gocui.ModNone) return g.DeleteView("confirmation") } @@ -61,6 +62,9 @@ func (gui *Gui) getConfirmationPanelDimensions(g *gocui.Gui, wrap bool, prompt s width, height := g.Size() panelWidth := 4 * width / 7 panelHeight := gui.getMessageHeight(wrap, prompt, panelWidth) + if panelHeight > height*3/4 { + panelHeight = height * 3 / 4 + } return width/2 - panelWidth/2, height/2 - panelHeight/2 - panelHeight%2 - 1, width/2 + panelWidth/2, @@ -149,6 +153,7 @@ func (gui *Gui) setKeyBindings(g *gocui.Gui, handleConfirm, handleClose func(*go "keyBindConfirm": "enter", }, ) + gui.renderString(g, "options", actions) if err := g.SetKeybinding("confirmation", nil, gocui.KeyEnter, gocui.ModNone, gui.wrappedConfirmationFunction(handleConfirm, returnFocusOnClose)); err != nil { return err diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 1ae9199eb..62a673870 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -343,6 +343,20 @@ func (gui *Gui) scrollDownSecondary(g *gocui.Gui, v *gocui.View) error { return gui.scrollDownView("secondary") } +func (gui *Gui) scrollUpConfirmationPanel(g *gocui.Gui, v *gocui.View) error { + if v.Editable { + return nil + } + return gui.scrollUpView("confirmation") +} + +func (gui *Gui) scrollDownConfirmationPanel(g *gocui.Gui, v *gocui.View) error { + if v.Editable { + return nil + } + return gui.scrollDownView("confirmation") +} + func (gui *Gui) handleRefresh(g *gocui.Gui, v *gocui.View) error { return gui.refreshSidePanels(g) } diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index ab2273d94..31096a759 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -1462,6 +1462,30 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Modifier: gocui.ModNone, Handler: gui.handleSearchEscape, }, + { + ViewName: "confirmation", + Key: gui.getKey("universal.prevItem"), + Modifier: gocui.ModNone, + Handler: gui.scrollUpConfirmationPanel, + }, + { + ViewName: "confirmation", + Key: gui.getKey("universal.nextItem"), + Modifier: gocui.ModNone, + Handler: gui.scrollDownConfirmationPanel, + }, + { + ViewName: "confirmation", + Key: gui.getKey("universal.prevItem-alt"), + Modifier: gocui.ModNone, + Handler: gui.scrollUpConfirmationPanel, + }, + { + ViewName: "confirmation", + Key: gui.getKey("universal.nextItem-alt"), + Modifier: gocui.ModNone, + Handler: gui.scrollDownConfirmationPanel, + }, } for _, viewName := range []string{"status", "branches", "files", "commits", "commitFiles", "stash", "menu"} { |