mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-14 11:23:09 +02:00
32 lines
612 B
Go
32 lines
612 B
Go
package helpers
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
)
|
|
|
|
type ViewHelper struct {
|
|
c *HelperCommon
|
|
}
|
|
|
|
func NewViewHelper(c *HelperCommon, contexts *context.ContextTree) *ViewHelper {
|
|
return &ViewHelper{
|
|
c: c,
|
|
}
|
|
}
|
|
|
|
func (self *ViewHelper) ContextForView(viewName string) (types.Context, bool) {
|
|
view, err := self.c.GocuiGui().View(viewName)
|
|
if err != nil {
|
|
return nil, false
|
|
}
|
|
|
|
for _, context := range self.c.Contexts().Flatten() {
|
|
if context.GetViewName() == view.Name() {
|
|
return context, true
|
|
}
|
|
}
|
|
|
|
return nil, false
|
|
}
|