1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

limit size of menu panel

This commit is contained in:
Jesse Duffield
2020-03-26 21:39:59 +11:00
parent f2036b42e5
commit 83757f1065
3 changed files with 44 additions and 1 deletions

View File

@ -39,7 +39,8 @@ func (gui *Gui) closeConfirmationPrompt(g *gocui.Gui, returnFocusOnClose bool) e
panic(err) panic(err)
} }
} }
g.DeleteKeybindings("confirmation") g.DeleteKeybinding("confirmation", gocui.KeyEnter, gocui.ModNone)
g.DeleteKeybinding("confirmation", gocui.KeyEsc, gocui.ModNone)
return g.DeleteView("confirmation") return g.DeleteView("confirmation")
} }
@ -61,6 +62,9 @@ func (gui *Gui) getConfirmationPanelDimensions(g *gocui.Gui, wrap bool, prompt s
width, height := g.Size() width, height := g.Size()
panelWidth := 4 * width / 7 panelWidth := 4 * width / 7
panelHeight := gui.getMessageHeight(wrap, prompt, panelWidth) panelHeight := gui.getMessageHeight(wrap, prompt, panelWidth)
if panelHeight > height*3/4 {
panelHeight = height * 3 / 4
}
return width/2 - panelWidth/2, return width/2 - panelWidth/2,
height/2 - panelHeight/2 - panelHeight%2 - 1, height/2 - panelHeight/2 - panelHeight%2 - 1,
width/2 + panelWidth/2, width/2 + panelWidth/2,
@ -149,6 +153,7 @@ func (gui *Gui) setKeyBindings(g *gocui.Gui, handleConfirm, handleClose func(*go
"keyBindConfirm": "enter", "keyBindConfirm": "enter",
}, },
) )
gui.renderString(g, "options", actions) gui.renderString(g, "options", actions)
if err := g.SetKeybinding("confirmation", nil, gocui.KeyEnter, gocui.ModNone, gui.wrappedConfirmationFunction(handleConfirm, returnFocusOnClose)); err != nil { if err := g.SetKeybinding("confirmation", nil, gocui.KeyEnter, gocui.ModNone, gui.wrappedConfirmationFunction(handleConfirm, returnFocusOnClose)); err != nil {
return err return err

View File

@ -343,6 +343,20 @@ func (gui *Gui) scrollDownSecondary(g *gocui.Gui, v *gocui.View) error {
return gui.scrollDownView("secondary") 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 { func (gui *Gui) handleRefresh(g *gocui.Gui, v *gocui.View) error {
return gui.refreshSidePanels(g) return gui.refreshSidePanels(g)
} }

View File

@ -1462,6 +1462,30 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Modifier: gocui.ModNone, Modifier: gocui.ModNone,
Handler: gui.handleSearchEscape, 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"} { for _, viewName := range []string{"status", "branches", "files", "commits", "commitFiles", "stash", "menu"} {