mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
move all refresh code into the one file
This commit is contained in:
@ -3,49 +3,15 @@ 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
|
||||
}
|
||||
|
||||
func (self *BaseContext) GetOptionsMap() map[string]string {
|
||||
if self.OnGetOptionsMap != nil {
|
||||
return self.OnGetOptionsMap()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *BaseContext) SetWindowName(windowName string) {
|
||||
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
|
||||
}
|
||||
|
||||
func (self *BaseContext) GetViewName() string {
|
||||
return self.ViewName
|
||||
}
|
||||
|
||||
func (self *BaseContext) GetKind() types.ContextKind {
|
||||
return self.Kind
|
||||
}
|
||||
|
||||
func (self *BaseContext) GetKey() types.ContextKey {
|
||||
return self.Key
|
||||
}
|
||||
|
||||
type NewBaseContextOpts struct {
|
||||
Kind types.ContextKind
|
||||
Key types.ContextKey
|
||||
@ -57,11 +23,38 @@ type NewBaseContextOpts struct {
|
||||
|
||||
func NewBaseContext(opts NewBaseContextOpts) *BaseContext {
|
||||
return &BaseContext{
|
||||
Kind: opts.Kind,
|
||||
Key: opts.Key,
|
||||
kind: opts.Kind,
|
||||
key: opts.Key,
|
||||
ViewName: opts.ViewName,
|
||||
WindowName: opts.WindowName,
|
||||
OnGetOptionsMap: opts.OnGetOptionsMap,
|
||||
windowName: opts.WindowName,
|
||||
onGetOptionsMap: opts.OnGetOptionsMap,
|
||||
ParentContextMgr: &ParentContextMgr{},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *BaseContext) GetOptionsMap() map[string]string {
|
||||
if self.onGetOptionsMap != nil {
|
||||
return self.onGetOptionsMap()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *BaseContext) SetWindowName(windowName string) {
|
||||
self.windowName = windowName
|
||||
}
|
||||
|
||||
func (self *BaseContext) GetWindowName() string {
|
||||
return self.windowName
|
||||
}
|
||||
|
||||
func (self *BaseContext) GetViewName() string {
|
||||
return self.ViewName
|
||||
}
|
||||
|
||||
func (self *BaseContext) GetKind() types.ContextKind {
|
||||
return self.kind
|
||||
}
|
||||
|
||||
func (self *BaseContext) GetKey() types.ContextKey {
|
||||
return self.key
|
||||
}
|
||||
|
Reference in New Issue
Block a user