summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-09-05 19:07:46 +1000
committerJesse Duffield <jessedduffield@gmail.com>2018-09-05 19:10:46 +1000
commit422b263df425aceb68f446d41ce359370f188be1 (patch)
tree4a40bf8b8b2766ce3f77efbe94e0b57f62622e49 /pkg
parentc1bf1e52b0e2bbe25a99a1cc10826fd138b7c7f9 (diff)
fix popup panel resizing
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/commit_message_panel.go9
-rw-r--r--pkg/gui/confirmation_panel.go15
-rw-r--r--pkg/gui/gui.go12
-rw-r--r--pkg/gui/view_helpers.go22
4 files changed, 23 insertions, 35 deletions
diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go
index 26db703f0..36718680f 100644
--- a/pkg/gui/commit_message_panel.go
+++ b/pkg/gui/commit_message_panel.go
@@ -34,15 +34,6 @@ func (gui *Gui) handleCommitClose(g *gocui.Gui, v *gocui.View) error {
}
func (gui *Gui) handleNewlineCommitMessage(g *gocui.Gui, v *gocui.View) error {
- // resising ahead of time so that the top line doesn't get hidden to make
- // room for the cursor on the second line
- x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, v.Buffer())
- if _, err := g.SetView("commitMessage", x0, y0, x1, y1+1, 0); err != nil {
- if err != gocui.ErrUnknownView {
- return err
- }
- }
-
v.EditNewLine()
return nil
}
diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go
index 1702b1df6..0bb633f32 100644
--- a/pkg/gui/confirmation_panel.go
+++ b/pkg/gui/confirmation_panel.go
@@ -11,7 +11,6 @@ import (
"github.com/fatih/color"
"github.com/jesseduffield/gocui"
- "github.com/jesseduffield/lazygit/pkg/utils"
)
func (gui *Gui) wrappedConfirmationFunction(function func(*gocui.Gui, *gocui.View) error) func(*gocui.Gui, *gocui.View) error {
@@ -161,17 +160,3 @@ func (gui *Gui) createErrorPanel(g *gocui.Gui, message string) error {
coloredMessage := colorFunction(strings.TrimSpace(message))
return gui.createConfirmationPanel(g, currentView, gui.Tr.SLocalize("Error"), coloredMessage, nil, nil)
}
-
-func (gui *Gui) resizePopupPanel(g *gocui.Gui, v *gocui.View) error {
- // If the confirmation panel is already displayed, just resize the width,
- // otherwise continue
- content := utils.TrimTrailingNewline(v.Buffer())
- x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, content)
- vx0, vy0, vx1, vy1 := v.Dimensions()
- if vx0 == x0 && vy0 == y0 && vx1 == x1 && vy1 == y1 {
- return nil
- }
- gui.Log.Info(gui.Tr.SLocalize("resizingPopupPanel"))
- _, err := g.SetView(v.Name(), x0, y0, x1, y1, 0)
- return err
-}
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 2a68bce71..bb2ed752b 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -307,9 +307,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
}
}
- gui.resizePopupPanels(g)
-
- return nil
+ return gui.resizeCurrentPopupPanel(g)
}
func (gui *Gui) promptAnonymousReporting() error {
@@ -355,14 +353,6 @@ func (gui *Gui) goEvery(g *gocui.Gui, interval time.Duration, function func(*goc
}()
}
-func (gui *Gui) resizePopupPanels(g *gocui.Gui) error {
- v := g.CurrentView()
- if v.Name() == "commitMessage" || v.Name() == "confirmation" {
- return gui.resizePopupPanel(g, v)
- }
- return nil
-}
-
// Run setup the gui with keybindings and start the mainloop
func (gui *Gui) Run() error {
g, err := gocui.NewGui(gocui.OutputNormal, OverlappingEdges)
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go
index fd810220b..3a59945a5 100644
--- a/pkg/gui/view_helpers.go
+++ b/pkg/gui/view_helpers.go
@@ -268,3 +268,25 @@ func (gui *Gui) currentViewName(g *gocui.Gui) string {
currentView := g.CurrentView()
return currentView.Name()
}
+
+func (gui *Gui) resizeCurrentPopupPanel(g *gocui.Gui) error {
+ v := g.CurrentView()
+ if v.Name() == "commitMessage" || v.Name() == "confirmation" {
+ return gui.resizePopupPanel(g, v)
+ }
+ return nil
+}
+
+func (gui *Gui) resizePopupPanel(g *gocui.Gui, v *gocui.View) error {
+ // If the confirmation panel is already displayed, just resize the width,
+ // otherwise continue
+ content := v.Buffer()
+ x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, content)
+ vx0, vy0, vx1, vy1 := v.Dimensions()
+ if vx0 == x0 && vy0 == y0 && vx1 == x1 && vy1 == y1 {
+ return nil
+ }
+ gui.Log.Info(gui.Tr.SLocalize("resizingPopupPanel"))
+ _, err := g.SetView(v.Name(), x0, y0, x1, y1, 0)
+ return err
+}