mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-15 11:56:37 +02:00
move some methods
This commit is contained in:
parent
2da300f2fb
commit
ea4587a3b8
@ -1,7 +1,6 @@
|
|||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/generics/slices"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
)
|
)
|
||||||
@ -22,16 +21,6 @@ func OnFocusWrapper(f func() error) func(opts types.OnFocusOpts) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) popupViewNames() []string {
|
|
||||||
popups := slices.Filter(gui.State.Contexts.Flatten(), func(c types.Context) bool {
|
|
||||||
return c.GetKind() == types.PERSISTENT_POPUP || c.GetKind() == types.TEMPORARY_POPUP
|
|
||||||
})
|
|
||||||
|
|
||||||
return slices.Map(popups, func(c types.Context) string {
|
|
||||||
return c.GetViewName()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) defaultSideContext() types.Context {
|
func (gui *Gui) defaultSideContext() types.Context {
|
||||||
if gui.State.Modes.Filtering.Active() {
|
if gui.State.Modes.Filtering.Active() {
|
||||||
return gui.State.Contexts.LocalCommits
|
return gui.State.Contexts.LocalCommits
|
||||||
@ -39,9 +28,3 @@ func (gui *Gui) defaultSideContext() types.Context {
|
|||||||
return gui.State.Contexts.Files
|
return gui.State.Contexts.Files
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) TransientContexts() []types.Context {
|
|
||||||
return slices.Filter(gui.State.Contexts.Flatten(), func(context types.Context) bool {
|
|
||||||
return context.IsTransient()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/jesseduffield/generics/slices"
|
"github.com/jesseduffield/generics/slices"
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -95,7 +96,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
|||||||
|
|
||||||
gui.Views.Tooltip.Visible = gui.Views.Menu.Visible && gui.Views.Tooltip.Buffer() != ""
|
gui.Views.Tooltip.Visible = gui.Views.Menu.Visible && gui.Views.Tooltip.Buffer() != ""
|
||||||
|
|
||||||
for _, context := range gui.TransientContexts() {
|
for _, context := range gui.transientContexts() {
|
||||||
view, err := gui.g.View(context.GetViewName())
|
view, err := gui.g.View(context.GetViewName())
|
||||||
if err != nil && !gocui.IsUnknownView(err) {
|
if err != nil && !gocui.IsUnknownView(err) {
|
||||||
return err
|
return err
|
||||||
@ -188,6 +189,16 @@ func (gui *Gui) onInitialViewsCreationForRepo() error {
|
|||||||
return gui.loadNewRepo()
|
return gui.loadNewRepo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) popupViewNames() []string {
|
||||||
|
popups := slices.Filter(gui.State.Contexts.Flatten(), func(c types.Context) bool {
|
||||||
|
return c.GetKind() == types.PERSISTENT_POPUP || c.GetKind() == types.TEMPORARY_POPUP
|
||||||
|
})
|
||||||
|
|
||||||
|
return slices.Map(popups, func(c types.Context) string {
|
||||||
|
return c.GetViewName()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) onInitialViewsCreation() error {
|
func (gui *Gui) onInitialViewsCreation() error {
|
||||||
// now we order the views (in order of bottom first)
|
// now we order the views (in order of bottom first)
|
||||||
for _, view := range gui.orderedViews() {
|
for _, view := range gui.orderedViews() {
|
||||||
@ -266,3 +277,9 @@ func (gui *Gui) onViewFocusLost(oldView *gocui.View) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) transientContexts() []types.Context {
|
||||||
|
return slices.Filter(gui.State.Contexts.Flatten(), func(context types.Context) bool {
|
||||||
|
return context.IsTransient()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user