mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +02:00
Begin refactoring gui
This begins a big refactor of moving more code out of the Gui struct into contexts, controllers, and helpers. We also move some code into structs in the gui package purely for the sake of better encapsulation
This commit is contained in:
parent
826128a8e0
commit
8edad826ca
101 changed files with 3331 additions and 2877 deletions
|
@ -1,6 +1,7 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
)
|
||||
|
||||
|
@ -17,20 +18,20 @@ type CanSwitchToDiffFiles interface {
|
|||
type SwitchToDiffFilesController struct {
|
||||
baseController
|
||||
*controllerCommon
|
||||
context CanSwitchToDiffFiles
|
||||
viewFiles func(SwitchToCommitFilesContextOpts) error
|
||||
context CanSwitchToDiffFiles
|
||||
diffFilesContext *context.CommitFilesContext
|
||||
}
|
||||
|
||||
func NewSwitchToDiffFilesController(
|
||||
controllerCommon *controllerCommon,
|
||||
viewFiles func(SwitchToCommitFilesContextOpts) error,
|
||||
context CanSwitchToDiffFiles,
|
||||
diffFilesContext *context.CommitFilesContext,
|
||||
) *SwitchToDiffFilesController {
|
||||
return &SwitchToDiffFilesController{
|
||||
baseController: baseController{},
|
||||
controllerCommon: controllerCommon,
|
||||
context: context,
|
||||
viewFiles: viewFiles,
|
||||
diffFilesContext: diffFilesContext,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,3 +73,22 @@ func (self *SwitchToDiffFilesController) enter(ref types.Ref) error {
|
|||
func (self *SwitchToDiffFilesController) Context() types.Context {
|
||||
return self.context
|
||||
}
|
||||
|
||||
func (self *SwitchToDiffFilesController) viewFiles(opts SwitchToCommitFilesContextOpts) error {
|
||||
diffFilesContext := self.diffFilesContext
|
||||
|
||||
diffFilesContext.SetSelectedLineIdx(0)
|
||||
diffFilesContext.SetRef(opts.Ref)
|
||||
diffFilesContext.SetTitleRef(opts.Ref.Description())
|
||||
diffFilesContext.SetCanRebase(opts.CanRebase)
|
||||
diffFilesContext.SetParentContext(opts.Context)
|
||||
diffFilesContext.SetWindowName(opts.Context.GetWindowName())
|
||||
|
||||
if err := self.c.Refresh(types.RefreshOptions{
|
||||
Scope: []types.RefreshableView{types.COMMIT_FILES},
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.PushContext(diffFilesContext)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue