diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-03-23 22:05:25 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-04-30 13:19:53 +1000 |
commit | f8c9ce33c2cdbefac27e6af409a10aa539d4037a (patch) | |
tree | e9f8dbb848baf6ca5681864ce7d19a0dd490f3e0 /pkg/gui/context.go | |
parent | 71753770ad6da851b6584b6868fd03a0dba6e5c8 (diff) |
move more actions into controller
Diffstat (limited to 'pkg/gui/context.go')
-rw-r--r-- | pkg/gui/context.go | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/pkg/gui/context.go b/pkg/gui/context.go index 3550e9eef..4c403973f 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -18,13 +18,20 @@ type ContextMgr struct { ContextStack []types.Context sync.RWMutex gui *Gui + + allContexts *context.ContextTree } -func NewContextMgr(initialContext types.Context, gui *Gui) *ContextMgr { +func NewContextMgr( + initialContext types.Context, + gui *Gui, + allContexts *context.ContextTree, +) *ContextMgr { return &ContextMgr{ ContextStack: []types.Context{initialContext}, RWMutex: sync.RWMutex{}, gui: gui, + allContexts: allContexts, } } @@ -286,3 +293,28 @@ func (self *ContextMgr) ForEach(f func(types.Context)) { func (self *ContextMgr) IsCurrent(c types.Context) bool { return self.Current().GetKey() == c.GetKey() } + +// all list contexts +func (self *ContextMgr) AllList() []types.IListContext { + var listContexts []types.IListContext + + for _, context := range self.allContexts.Flatten() { + if listContext, ok := context.(types.IListContext); ok { + listContexts = append(listContexts, listContext) + } + } + + return listContexts +} + +func (self *ContextMgr) AllPatchExplorer() []types.IPatchExplorerContext { + var listContexts []types.IPatchExplorerContext + + for _, context := range self.allContexts.Flatten() { + if listContext, ok := context.(types.IPatchExplorerContext); ok { + listContexts = append(listContexts, listContext) + } + } + + return listContexts +} |