diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-06-13 11:01:26 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-08-06 13:49:11 +1000 |
commit | 524bf83a4a681408c3fb57818f6968cab632e0ae (patch) | |
tree | 8858b4ee8d4670dcdd1637fe5fedf00ff080c154 /pkg/gui/controllers.go | |
parent | 6dfef08efc5c7f262194c0af35fd777428f33a1a (diff) |
refactor to only have one context per view
Diffstat (limited to 'pkg/gui/controllers.go')
-rw-r--r-- | pkg/gui/controllers.go | 103 |
1 files changed, 89 insertions, 14 deletions
diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go index dcb3377cf..1f18cd266 100644 --- a/pkg/gui/controllers.go +++ b/pkg/gui/controllers.go @@ -27,7 +27,7 @@ func (gui *Gui) resetControllers() { gui.helpers = &helpers.Helpers{ Refs: refsHelper, Host: helpers.NewHostHelper(helperCommon, gui.git), - PatchBuilding: helpers.NewPatchBuildingHelper(helperCommon, gui.git), + PatchBuilding: helpers.NewPatchBuildingHelper(helperCommon, gui.git, gui.State.Contexts), Bisect: helpers.NewBisectHelper(helperCommon, gui.git), Suggestions: suggestionsHelper, Files: helpers.NewFilesHelper(helperCommon, gui.git, osCommand), @@ -120,11 +120,18 @@ func (gui *Gui) resetControllers() { ) undoController := controllers.NewUndoController(common) globalController := controllers.NewGlobalController(common) + contextLinesController := controllers.NewContextLinesController(common) + verticalScrollControllerFactory := controllers.NewVerticalScrollControllerFactory(common) + branchesController := controllers.NewBranchesController(common) gitFlowController := controllers.NewGitFlowController(common) filesRemoveController := controllers.NewFilesRemoveController(common) stashController := controllers.NewStashController(common) commitFilesController := controllers.NewCommitFilesController(common) + patchExplorerControllerFactory := controllers.NewPatchExplorerControllerFactory(common) + stagingController := controllers.NewStagingController(common, gui.State.Contexts.Staging, gui.State.Contexts.StagingSecondary, false) + stagingSecondaryController := controllers.NewStagingController(common, gui.State.Contexts.StagingSecondary, gui.State.Contexts.Staging, true) + patchBuildingController := controllers.NewPatchBuildingController(common) setSubCommits := func(commits []*models.Commit) { gui.State.Model.SubCommits = commits } @@ -157,19 +164,87 @@ func (gui *Gui) resetControllers() { controllers.AttachControllers(context, controllers.NewBasicCommitsController(common, context)) } - controllers.AttachControllers(gui.State.Contexts.Files, filesController, filesRemoveController) - controllers.AttachControllers(gui.State.Contexts.Tags, tagsController) - controllers.AttachControllers(gui.State.Contexts.Submodules, submodulesController) - controllers.AttachControllers(gui.State.Contexts.LocalCommits, localCommitsController, bisectController) - controllers.AttachControllers(gui.State.Contexts.Branches, branchesController, gitFlowController) - controllers.AttachControllers(gui.State.Contexts.LocalCommits, localCommitsController, bisectController) - controllers.AttachControllers(gui.State.Contexts.CommitFiles, commitFilesController) - controllers.AttachControllers(gui.State.Contexts.Remotes, remotesController) - controllers.AttachControllers(gui.State.Contexts.Stash, stashController) - controllers.AttachControllers(gui.State.Contexts.Menu, menuController) - controllers.AttachControllers(gui.State.Contexts.CommitMessage, commitMessageController) - controllers.AttachControllers(gui.State.Contexts.RemoteBranches, remoteBranchesController) - controllers.AttachControllers(gui.State.Contexts.Global, syncController, undoController, globalController) + // TODO: add scroll controllers for main panels (need to bring some more functionality across for that e.g. reading more from the currently displayed git command) + controllers.AttachControllers(gui.State.Contexts.Staging, + stagingController, + patchExplorerControllerFactory.Create(gui.State.Contexts.Staging), + verticalScrollControllerFactory.Create(gui.State.Contexts.Staging), + ) + + controllers.AttachControllers(gui.State.Contexts.StagingSecondary, + stagingSecondaryController, + patchExplorerControllerFactory.Create(gui.State.Contexts.StagingSecondary), + verticalScrollControllerFactory.Create(gui.State.Contexts.StagingSecondary), + ) + + controllers.AttachControllers(gui.State.Contexts.CustomPatchBuilder, + patchBuildingController, + patchExplorerControllerFactory.Create(gui.State.Contexts.CustomPatchBuilder), + verticalScrollControllerFactory.Create(gui.State.Contexts.CustomPatchBuilder), + ) + + controllers.AttachControllers(gui.State.Contexts.CustomPatchBuilderSecondary, + verticalScrollControllerFactory.Create(gui.State.Contexts.CustomPatchBuilder), + ) + + controllers.AttachControllers(gui.State.Contexts.Files, + filesController, + filesRemoveController, + ) + + controllers.AttachControllers(gui.State.Contexts.Tags, + tagsController, + ) + + controllers.AttachControllers(gui.State.Contexts.Submodules, + submodulesController, + ) + + controllers.AttachControllers(gui.State.Contexts.LocalCommits, + localCommitsController, + bisectController, + ) + + controllers.AttachControllers(gui.State.Contexts.Branches, + branchesController, + gitFlowController, + ) + + controllers.AttachControllers(gui.State.Contexts.LocalCommits, + localCommitsController, + bisectController, + ) + + controllers.AttachControllers(gui.State.Contexts.CommitFiles, + commitFilesController, + ) + + controllers.AttachControllers(gui.State.Contexts.Remotes, + remotesController, + ) + + controllers.AttachControllers(gui.State.Contexts.Stash, + stashController, + ) + + controllers.AttachControllers(gui.State.Contexts.Menu, + menuController, + ) + + controllers.AttachControllers(gui.State.Contexts.CommitMessage, + commitMessageController, + ) + + controllers.AttachControllers(gui.State.Contexts.RemoteBranches, + remoteBranchesController, + ) + + controllers.AttachControllers(gui.State.Contexts.Global, + syncController, + undoController, + globalController, + contextLinesController, + ) // this must come last so that we've got our click handlers defined against the context listControllerFactory := controllers.NewListControllerFactory(gui.c) |