diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2018-12-08 16:54:54 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2018-12-11 22:02:12 +1100 |
commit | 9489a9447396b30bca86ea3df201cacfdffdb1a9 (patch) | |
tree | ae251c28096f2bde6b1647603852782c58329d4c /pkg/gui/view_helpers.go | |
parent | e0ff46fe53503d74fc63c90fc5ddc4d9468b60d5 (diff) |
Make merge panel its own panel
Diffstat (limited to 'pkg/gui/view_helpers.go')
-rw-r--r-- | pkg/gui/view_helpers.go | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 1508daa1b..df32e8fb5 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -16,7 +16,7 @@ func (gui *Gui) refreshSidePanels(g *gocui.Gui) error { if err := gui.refreshBranches(g); err != nil { return err } - if err := gui.refreshFiles(g); err != nil { + if err := gui.refreshFiles(); err != nil { return err } if err := gui.refreshCommits(g); err != nil { @@ -101,7 +101,7 @@ func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error { return nil case "commitMessage": return gui.handleCommitFocused(g, v) - case "main": + case "merging": // TODO: pull this out into a 'view focused' function gui.refreshMergePanel(g) v.Highlight = false @@ -126,6 +126,20 @@ func (gui *Gui) returnFocus(g *gocui.Gui, v *gocui.View) error { return gui.switchFocus(g, v, previousView) } +// in lieu of a proper window system, we've got three panels that overlap, +// the main panel, the staging panel, and the merging panel. We will call this +// function whenever we might need to hide one of these panels +// this function introduces some unwanted technical debt but is necessary for this rebasing feature +func (gui *Gui) showCorrectMainPanel() error { + // if the files view is not focused or the current file is not in a merging state we hide the merging panel + if gui.g.CurrentView().Name() != "merging" && gui.g.CurrentView().Name() != "confirmation" { + if _, err := gui.g.SetViewOnBottom("merging"); err != nil { + return err + } + } + return nil +} + // pass in oldView = nil if you don't want to be able to return to your old view func (gui *Gui) switchFocus(g *gocui.Gui, oldView, newView *gocui.View) error { // we assume we'll never want to return focus to a confirmation panel i.e. @@ -169,6 +183,10 @@ func (gui *Gui) switchFocus(g *gocui.Gui, oldView, newView *gocui.View) error { return err } + if err := gui.showCorrectMainPanel(); err != nil { + return err + } + return gui.newLineFocused(g, newView) } @@ -229,9 +247,6 @@ func (gui *Gui) renderString(g *gocui.Gui, viewName, s string) error { return nil } v.Clear() - if err := v.SetOrigin(0, 0); err != nil { - return err - } output := string(bom.Clean([]byte(s))) output = utils.NormalizeLinefeeds(output) fmt.Fprint(v, output) @@ -255,38 +270,43 @@ func (gui *Gui) renderOptionsMap(optionsMap map[string]string) error { // TODO: refactor properly // i'm so sorry but had to add this getBranchesView -func (gui *Gui) getFilesView(g *gocui.Gui) *gocui.View { - v, _ := g.View("files") +func (gui *Gui) getFilesView() *gocui.View { + v, _ := gui.g.View("files") + return v +} + +func (gui *Gui) getCommitsView() *gocui.View { + v, _ := gui.g.View("commits") return v } -func (gui *Gui) getCommitsView(g *gocui.Gui) *gocui.View { - v, _ := g.View("commits") +func (gui *Gui) getCommitMessageView() *gocui.View { + v, _ := gui.g.View("commitMessage") return v } -func (gui *Gui) getCommitMessageView(g *gocui.Gui) *gocui.View { - v, _ := g.View("commitMessage") +func (gui *Gui) getBranchesView() *gocui.View { + v, _ := gui.g.View("branches") return v } -func (gui *Gui) getBranchesView(g *gocui.Gui) *gocui.View { - v, _ := g.View("branches") +func (gui *Gui) getStagingView() *gocui.View { + v, _ := gui.g.View("staging") return v } -func (gui *Gui) getStagingView(g *gocui.Gui) *gocui.View { - v, _ := g.View("staging") +func (gui *Gui) getMainView() *gocui.View { + v, _ := gui.g.View("main") return v } -func (gui *Gui) getMainView(g *gocui.Gui) *gocui.View { - v, _ := g.View("main") +func (gui *Gui) getStashView() *gocui.View { + v, _ := gui.g.View("stash") return v } -func (gui *Gui) getStashView(g *gocui.Gui) *gocui.View { - v, _ := g.View("stash") +func (gui *Gui) getMergingView() *gocui.View { + v, _ := gui.g.View("merging") return v } |