1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/gui/controllers/helpers/view_helper.go

32 lines
612 B
Go
Raw Normal View History

package helpers
import (
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
type ViewHelper struct {
2023-03-23 03:53:18 +02:00
c *HelperCommon
}
func NewViewHelper(c *HelperCommon, contexts *context.ContextTree) *ViewHelper {
return &ViewHelper{
2023-03-23 03:53:18 +02:00
c: c,
}
}
func (self *ViewHelper) ContextForView(viewName string) (types.Context, bool) {
view, err := self.c.GocuiGui().View(viewName)
if err != nil {
return nil, false
}
2023-03-23 03:53:18 +02:00
for _, context := range self.c.Contexts().Flatten() {
if context.GetViewName() == view.Name() {
return context, true
}
}
return nil, false
}