mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
extract common code
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
parent
ea2fe23317
commit
68c020c103
1 changed files with 20 additions and 41 deletions
|
|
@ -195,50 +195,16 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
||||||
aboveContainersView := "project"
|
aboveContainersView := "project"
|
||||||
if showServicesPanel {
|
if showServicesPanel {
|
||||||
aboveContainersView = "services"
|
aboveContainersView = "services"
|
||||||
servicesView, err := g.SetViewBeneath("services", "project", vHeights["services"])
|
addView(g, "services", "project", gui.Tr.ServicesTitle, vHeights["services"])
|
||||||
if err != nil {
|
|
||||||
if err.Error() != "unknown view" {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
servicesView.Highlight = true
|
|
||||||
servicesView.Title = gui.Tr.ServicesTitle
|
|
||||||
servicesView.FgColor = gocui.ColorDefault
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
containersView, err := g.SetViewBeneath("containers", aboveContainersView, vHeights["containers"])
|
containerTitle := gui.Tr.StandaloneContainersTitle
|
||||||
if err != nil {
|
if gui.Config.UserConfig.Gui.ShowAllContainers || !showServicesPanel {
|
||||||
if err.Error() != "unknown view" {
|
containerTitle = gui.Tr.ContainersTitle
|
||||||
return err
|
|
||||||
}
|
|
||||||
containersView.Highlight = true
|
|
||||||
if gui.Config.UserConfig.Gui.ShowAllContainers || !showServicesPanel {
|
|
||||||
containersView.Title = gui.Tr.ContainersTitle
|
|
||||||
} else {
|
|
||||||
containersView.Title = gui.Tr.StandaloneContainersTitle
|
|
||||||
}
|
|
||||||
containersView.FgColor = gocui.ColorDefault
|
|
||||||
}
|
|
||||||
|
|
||||||
imagesView, err := g.SetViewBeneath("images", "containers", vHeights["images"])
|
|
||||||
if err != nil {
|
|
||||||
if err.Error() != "unknown view" {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
imagesView.Highlight = true
|
|
||||||
imagesView.Title = gui.Tr.ImagesTitle
|
|
||||||
imagesView.FgColor = gocui.ColorDefault
|
|
||||||
}
|
|
||||||
|
|
||||||
volumesView, err := g.SetViewBeneath("volumes", "images", vHeights["volumes"])
|
|
||||||
if err != nil {
|
|
||||||
if err.Error() != "unknown view" {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
volumesView.Highlight = true
|
|
||||||
volumesView.Title = gui.Tr.VolumesTitle
|
|
||||||
volumesView.FgColor = gocui.ColorDefault
|
|
||||||
}
|
}
|
||||||
|
addView(g, "containers", aboveContainersView, containerTitle, vHeights["containers"])
|
||||||
|
addView(g, "images", "containers", gui.Tr.ImagesTitle, vHeights["images"])
|
||||||
|
addView(g, "volumes", "images", gui.Tr.VolumesTitle, vHeights["volumes"])
|
||||||
|
|
||||||
if v, err := g.SetView("options", appStatusOptionsBoundary-1, height-2, optionsVersionBoundary-1, height, 0); err != nil {
|
if v, err := g.SetView("options", appStatusOptionsBoundary-1, height-2, optionsVersionBoundary-1, height, 0); err != nil {
|
||||||
if err.Error() != "unknown view" {
|
if err.Error() != "unknown view" {
|
||||||
|
|
@ -301,6 +267,19 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
||||||
return gui.resizeCurrentPopupPanel(g)
|
return gui.resizeCurrentPopupPanel(g)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addView(g *gocui.Gui, name, after, title string, height int) error {
|
||||||
|
imagesView, err := g.SetViewBeneath(name, after, height)
|
||||||
|
if err != nil {
|
||||||
|
if err.Error() != "unknown view" {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
imagesView.Highlight = true
|
||||||
|
imagesView.Title = title
|
||||||
|
imagesView.FgColor = gocui.ColorDefault
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type listViewState struct {
|
type listViewState struct {
|
||||||
selectedLine int
|
selectedLine int
|
||||||
lineCount int
|
lineCount int
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue