mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
refactor to only have one context per view
This commit is contained in:
parent
6dfef08efc
commit
524bf83a4a
372 changed files with 28866 additions and 6902 deletions
|
@ -1,6 +1,8 @@
|
|||
package gui
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
|
@ -39,7 +41,17 @@ func (self *guiCommon) RunSubprocess(cmdObj oscommands.ICmdObj) (bool, error) {
|
|||
}
|
||||
|
||||
func (self *guiCommon) PushContext(context types.Context, opts ...types.OnFocusOpts) error {
|
||||
return self.gui.pushContext(context, opts...)
|
||||
singleOpts := types.OnFocusOpts{}
|
||||
if len(opts) > 0 {
|
||||
// using triple dot but you should only ever pass one of these opt structs
|
||||
if len(opts) > 1 {
|
||||
return errors.New("cannot pass multiple opts to pushContext")
|
||||
}
|
||||
|
||||
singleOpts = opts[0]
|
||||
}
|
||||
|
||||
return self.gui.pushContext(context, singleOpts)
|
||||
}
|
||||
|
||||
func (self *guiCommon) PopContext() error {
|
||||
|
@ -50,6 +62,14 @@ func (self *guiCommon) CurrentContext() types.Context {
|
|||
return self.gui.currentContext()
|
||||
}
|
||||
|
||||
func (self *guiCommon) CurrentStaticContext() types.Context {
|
||||
return self.gui.currentStaticContext()
|
||||
}
|
||||
|
||||
func (self *guiCommon) IsCurrentContext(c types.Context) bool {
|
||||
return self.CurrentContext().GetKey() == c.GetKey()
|
||||
}
|
||||
|
||||
func (self *guiCommon) GetAppState() *config.AppState {
|
||||
return self.gui.Config.GetAppState()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue