1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-14 11:23:09 +02:00
lazygit/pkg/gui/context/base_context.go

61 lines
1.3 KiB
Go
Raw Normal View History

2022-01-29 10:09:20 +02:00
package context
import "github.com/jesseduffield/lazygit/pkg/gui/types"
type BaseContext struct {
kind types.ContextKind
key types.ContextKey
2022-01-29 10:09:20 +02:00
ViewName string
windowName string
onGetOptionsMap func() map[string]string
2022-01-29 10:09:20 +02:00
*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{},
}
}
2022-01-29 10:09:20 +02:00
func (self *BaseContext) GetOptionsMap() map[string]string {
if self.onGetOptionsMap != nil {
return self.onGetOptionsMap()
2022-01-29 10:09:20 +02:00
}
return nil
}
func (self *BaseContext) SetWindowName(windowName string) {
self.windowName = windowName
2022-01-29 10:09:20 +02:00
}
func (self *BaseContext) GetWindowName() string {
return self.windowName
2022-01-29 10:09:20 +02:00
}
func (self *BaseContext) GetViewName() string {
return self.ViewName
}
func (self *BaseContext) GetKind() types.ContextKind {
return self.kind
2022-01-29 10:09:20 +02:00
}
func (self *BaseContext) GetKey() types.ContextKey {
return self.key
2022-01-29 10:09:20 +02:00
}