1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-06 03:53:59 +02:00

factor out code for new popup panels

This commit is contained in:
Jesse Duffield 2018-08-15 21:49:38 +10:00
parent 7c33c02930
commit 8d99b400fd

View File

@ -57,7 +57,7 @@ func (gui *Gui) getConfirmationPanelDimensions(g *gocui.Gui, prompt string) (int
} }
func (gui *Gui) createPromptPanel(g *gocui.Gui, currentView *gocui.View, title string, handleConfirm func(*gocui.Gui, *gocui.View) error) error { func (gui *Gui) createPromptPanel(g *gocui.Gui, currentView *gocui.View, title string, handleConfirm func(*gocui.Gui, *gocui.View) error) error {
g.SetViewOnBottom("commitMessage") gui.onNewPopupPanel()
// only need to fit one line // only need to fit one line
x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, "") x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, "")
if confirmationView, err := g.SetView("confirmation", x0, y0, x1, y1, 0); err != nil { if confirmationView, err := g.SetView("confirmation", x0, y0, x1, y1, 0); err != nil {
@ -73,8 +73,12 @@ func (gui *Gui) createPromptPanel(g *gocui.Gui, currentView *gocui.View, title s
return nil return nil
} }
func (gui *Gui) onNewPopupPanel() {
gui.g.SetViewOnBottom("commitMessage")
}
func (gui *Gui) createConfirmationPanel(g *gocui.Gui, currentView *gocui.View, title, prompt string, handleConfirm, handleClose func(*gocui.Gui, *gocui.View) error) error { func (gui *Gui) createConfirmationPanel(g *gocui.Gui, currentView *gocui.View, title, prompt string, handleConfirm, handleClose func(*gocui.Gui, *gocui.View) error) error {
g.SetViewOnBottom("commitMessage") gui.onNewPopupPanel()
g.Update(func(g *gocui.Gui) error { g.Update(func(g *gocui.Gui) error {
// delete the existing confirmation panel if it exists // delete the existing confirmation panel if it exists
if view, _ := g.View("confirmation"); view != nil { if view, _ := g.View("confirmation"); view != nil {