diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-30 09:53:28 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-17 19:13:40 +1100 |
commit | 51547e38227b2443de955f4d17d46429039cf9f1 (patch) | |
tree | c1d8eccaa7736713b01cb00b574e9ed65c60bc8d /pkg/gui/context | |
parent | e363606fb6eeff130e38466f5a63a3a8c0e6ec0d (diff) |
move all refresh code into the one file
Diffstat (limited to 'pkg/gui/context')
-rw-r--r-- | pkg/gui/context/base_context.go | 67 | ||||
-rw-r--r-- | pkg/gui/context/view_trait.go | 2 |
2 files changed, 31 insertions, 38 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 } diff --git a/pkg/gui/context/view_trait.go b/pkg/gui/context/view_trait.go index 4c02a4990..1409ed561 100644 --- a/pkg/gui/context/view_trait.go +++ b/pkg/gui/context/view_trait.go @@ -36,7 +36,7 @@ func (self *ViewTrait) SetFooter(value string) { } func (self *ViewTrait) SetOriginX(value int) { - self.getView().SetOriginX(value) + _ = self.getView().SetOriginX(value) } // tells us the bounds of line indexes shown in the view currently |