summaryrefslogtreecommitdiffstats
path: root/pkg/gui/view_helpers.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-02-11 21:02:53 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-02-11 21:02:53 +1100
commit3d343e9b574a2c99ebf5b30dc9a4dac2886f6d73 (patch)
treeef6b2f8c08a29349bcc56a16260dfefdb3ee872d /pkg/gui/view_helpers.go
parenta3656154906c1117f9c9bbe100aa585e43417897 (diff)
parent3a607061a2303d9f45d308de652fbebe7300b43c (diff)
Merge branch 'master' into feature/rebasing
Diffstat (limited to 'pkg/gui/view_helpers.go')
-rw-r--r--pkg/gui/view_helpers.go37
1 files changed, 25 insertions, 12 deletions
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go
index df32e8fb5..7d343c9a4 100644
--- a/pkg/gui/view_helpers.go
+++ b/pkg/gui/view_helpers.go
@@ -90,7 +90,7 @@ func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error {
case "status":
return gui.handleStatusSelect(g, v)
case "files":
- return gui.handleFileSelect(g, v)
+ return gui.handleFileSelect(g, v, false)
case "branches":
return gui.handleBranchSelect(g, v)
case "commits":
@@ -101,11 +101,15 @@ func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error {
return nil
case "commitMessage":
return gui.handleCommitFocused(g, v)
- case "merging":
+ case "credentials":
+ return gui.handleCredentialsViewFocused(g, v)
+ case "main":
// TODO: pull this out into a 'view focused' function
gui.refreshMergePanel(g)
v.Highlight = false
return nil
+ case "merging":
+ return nil
case "staging":
return nil
// return gui.handleStagingSelect(g, v)
@@ -238,19 +242,28 @@ func (gui *Gui) focusPoint(cx int, cy int, v *gocui.View) error {
return nil
}
+func (gui *Gui) cleanString(s string) string {
+ output := string(bom.Clean([]byte(s)))
+ return utils.NormalizeLinefeeds(output)
+}
+
+func (gui *Gui) setViewContent(g *gocui.Gui, v *gocui.View, s string) error {
+ v.Clear()
+ fmt.Fprint(v, gui.cleanString(s))
+ return nil
+}
+
+// renderString resets the origin of a view and sets its content
func (gui *Gui) renderString(g *gocui.Gui, viewName, s string) error {
g.Update(func(*gocui.Gui) error {
v, err := g.View(viewName)
- // just in case the view disappeared as this function was called, we'll
- // silently return if it's not found
if err != nil {
- return nil
+ return nil // return gracefully if view has been deleted
}
- v.Clear()
- output := string(bom.Clean([]byte(s)))
- output = utils.NormalizeLinefeeds(output)
- fmt.Fprint(v, output)
- return nil
+ if err := v.SetOrigin(0, 0); err != nil {
+ return err
+ }
+ return gui.setViewContent(gui.g, v, s)
})
return nil
}
@@ -321,7 +334,7 @@ func (gui *Gui) currentViewName(g *gocui.Gui) string {
func (gui *Gui) resizeCurrentPopupPanel(g *gocui.Gui) error {
v := g.CurrentView()
- if v.Name() == "commitMessage" || v.Name() == "confirmation" {
+ if v.Name() == "commitMessage" || v.Name() == "credentials" || v.Name() == "confirmation" {
return gui.resizePopupPanel(g, v)
}
return nil
@@ -331,7 +344,7 @@ 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)
+ x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, v.Wrap, content)
vx0, vy0, vx1, vy1 := v.Dimensions()
if vx0 == x0 && vy0 == y0 && vx1 == x1 && vy1 == y1 {
return nil