diff options
Diffstat (limited to 'pkg/gui/context/base_context.go')
-rw-r--r-- | pkg/gui/context/base_context.go | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/pkg/gui/context/base_context.go b/pkg/gui/context/base_context.go index e95b298a4..f6007fe5f 100644 --- a/pkg/gui/context/base_context.go +++ b/pkg/gui/context/base_context.go @@ -3,35 +3,48 @@ package context import "github.com/jesseduffield/lazygit/pkg/gui/types" type BaseContext struct { - Kind types.ContextKind - Key types.ContextKey + kind types.ContextKind + key types.ContextKey ViewName string - WindowName string - OnGetOptionsMap func() map[string]string + windowName string + onGetOptionsMap func() map[string]string *ParentContextMgr } +type NewBaseContextOpts struct { + Kind types.ContextKind + Key types.ContextKey + ViewName string + WindowName string + + OnGetOptionsMap func() map[string]string +} + +func NewBaseContext(opts NewBaseContextOpts) *BaseContext { + return &BaseContext{ + kind: opts.Kind, + key: opts.Key, + ViewName: opts.ViewName, + windowName: opts.WindowName, + onGetOptionsMap: opts.OnGetOptionsMap, + ParentContextMgr: &ParentContextMgr{}, + } +} + func (self *BaseContext) GetOptionsMap() map[string]string { - if self.OnGetOptionsMap != nil { - return self.OnGetOptionsMap() + if self.onGetOptionsMap != nil { + return self.onGetOptionsMap() } return nil } func (self *BaseContext) SetWindowName(windowName string) { - self.WindowName = windowName + self.windowName = windowName } func (self *BaseContext) GetWindowName() string { - windowName := self.WindowName - - if windowName != "" { - return windowName - } - - // TODO: actually set this for everything so we don't default to the view name - return self.ViewName + return self.windowName } func (self *BaseContext) GetViewName() string { @@ -39,29 +52,9 @@ func (self *BaseContext) GetViewName() string { } func (self *BaseContext) GetKind() types.ContextKind { - return self.Kind + return self.kind } func (self *BaseContext) GetKey() types.ContextKey { - return self.Key -} - -type NewBaseContextOpts struct { - Kind types.ContextKind - Key types.ContextKey - ViewName string - WindowName string - - OnGetOptionsMap func() map[string]string -} - -func NewBaseContext(opts NewBaseContextOpts) *BaseContext { - return &BaseContext{ - Kind: opts.Kind, - Key: opts.Key, - ViewName: opts.ViewName, - WindowName: opts.WindowName, - OnGetOptionsMap: opts.OnGetOptionsMap, - ParentContextMgr: &ParentContextMgr{}, - } + return self.key } |