mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
appease linter
see if this works
This commit is contained in:
parent
e8ebec193f
commit
cd791e576f
8 changed files with 32 additions and 30 deletions
|
|
@ -101,6 +101,8 @@ func (gui *Gui) onNewPopupPanel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// it is very important that within this function we never include the original prompt in any error messages, because it may contain e.g. a user password
|
// it is very important that within this function we never include the original prompt in any error messages, because it may contain e.g. a user password
|
||||||
|
// unparam complains that handleClose is alwans nil but one day it won't be nil.
|
||||||
|
// nolint:unparam
|
||||||
func (gui *Gui) createConfirmationPanel(g *gocui.Gui, currentView *gocui.View, title, prompt string, handleConfirm, handleClose func(*gocui.Gui, *gocui.View) error) error {
|
func (gui *Gui) createConfirmationPanel(g *gocui.Gui, currentView *gocui.View, title, prompt string, handleConfirm, handleClose func(*gocui.Gui, *gocui.View) error) error {
|
||||||
return gui.createPopupPanel(g, currentView, title, prompt, false, handleConfirm, handleClose)
|
return gui.createPopupPanel(g, currentView, title, prompt, false, handleConfirm, handleClose)
|
||||||
}
|
}
|
||||||
|
|
@ -146,19 +148,10 @@ func (gui *Gui) setKeyBindings(g *gocui.Gui, handleConfirm, handleClose func(*go
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// createSpecificErrorPanel allows you to create an error popup, specifying the
|
func (gui *Gui) createErrorPanel(g *gocui.Gui, message string) error {
|
||||||
// view to be focused when the user closes the popup, and a boolean specifying
|
|
||||||
// whether we will log the error. If the message may include a user password,
|
|
||||||
// this function is to be used over the more generic createErrorPanel, with
|
|
||||||
// willLog set to false
|
|
||||||
func (gui *Gui) createSpecificErrorPanel(message string, nextView *gocui.View, willLog bool) error {
|
|
||||||
colorFunction := color.New(color.FgRed).SprintFunc()
|
colorFunction := color.New(color.FgRed).SprintFunc()
|
||||||
coloredMessage := colorFunction(strings.TrimSpace(message))
|
coloredMessage := colorFunction(strings.TrimSpace(message))
|
||||||
return gui.createConfirmationPanel(gui.g, nextView, gui.Tr.ErrorTitle, coloredMessage, nil, nil)
|
return gui.createConfirmationPanel(gui.g, g.CurrentView(), gui.Tr.ErrorTitle, coloredMessage, nil, nil)
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) createErrorPanel(g *gocui.Gui, message string) error {
|
|
||||||
return gui.createSpecificErrorPanel(message, g.CurrentView(), true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) renderConfirmationOptions() error {
|
func (gui *Gui) renderConfirmationOptions() error {
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ func (gui *Gui) handleContainerSelect(g *gocui.Gui, v *gocui.View) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.focusPoint(0, gui.State.Panels.Containers.SelectedLine, len(gui.DockerCommand.DisplayContainers), v)
|
gui.focusY(gui.State.Panels.Containers.SelectedLine, len(gui.DockerCommand.DisplayContainers), v)
|
||||||
|
|
||||||
key := "containers-" + container.ID + "-" + gui.getContainerContexts()[gui.State.Panels.Containers.ContextIndex]
|
key := "containers-" + container.ID + "-" + gui.getContainerContexts()[gui.State.Panels.Containers.ContextIndex]
|
||||||
if !gui.shouldRefresh(key) {
|
if !gui.shouldRefresh(key) {
|
||||||
|
|
@ -199,7 +199,7 @@ func (gui *Gui) renderContainerStats(container *commands.Container) error {
|
||||||
_ = gui.createErrorPanel(gui.g, err.Error())
|
_ = gui.createErrorPanel(gui.g, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = gui.reRenderString(gui.g, "main", contents)
|
gui.reRenderStringMain(contents)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -211,10 +211,10 @@ func (gui *Gui) renderContainerTop(container *commands.Container) error {
|
||||||
return gui.T.NewTickerTask(time.Second, func(stop chan struct{}) { gui.clearMainView() }, func(stop, notifyStopped chan struct{}) {
|
return gui.T.NewTickerTask(time.Second, func(stop chan struct{}) { gui.clearMainView() }, func(stop, notifyStopped chan struct{}) {
|
||||||
contents, err := container.RenderTop()
|
contents, err := container.RenderTop()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = gui.reRenderString(gui.g, "main", err.Error())
|
gui.reRenderStringMain(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = gui.reRenderString(gui.g, "main", contents)
|
gui.reRenderStringMain(contents)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -244,7 +244,7 @@ func (gui *Gui) refreshContainersAndServices() error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
gui.State.Panels.Services.SelectedLine = i
|
gui.State.Panels.Services.SelectedLine = i
|
||||||
gui.focusPoint(0, i, len(gui.DockerCommand.Services), gui.getServicesView())
|
gui.focusY(i, len(gui.DockerCommand.Services), gui.getServicesView())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ func (gui *Gui) handleImageSelect(g *gocui.Gui, v *gocui.View) error {
|
||||||
return gui.renderString(g, "main", gui.Tr.NoImages)
|
return gui.renderString(g, "main", gui.Tr.NoImages)
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.focusPoint(0, gui.State.Panels.Images.SelectedLine, len(gui.DockerCommand.Images), v)
|
gui.focusY(gui.State.Panels.Images.SelectedLine, len(gui.DockerCommand.Images), v)
|
||||||
|
|
||||||
key := "images-" + Image.ID + "-" + gui.getImageContexts()[gui.State.Panels.Images.ContextIndex]
|
key := "images-" + Image.ID + "-" + gui.getImageContexts()[gui.State.Panels.Images.ContextIndex]
|
||||||
if !gui.shouldRefresh(key) {
|
if !gui.shouldRefresh(key) {
|
||||||
|
|
|
||||||
|
|
@ -300,6 +300,6 @@ func (gui *Gui) focusPointInView(view *gocui.View) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if state, ok := listViews[view.Name()]; ok {
|
if state, ok := listViews[view.Name()]; ok {
|
||||||
gui.focusPoint(0, state.selectedLine, state.lineCount, view)
|
gui.focusY(state.selectedLine, state.lineCount, view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
// list panel functions
|
// list panel functions
|
||||||
|
|
||||||
func (gui *Gui) handleMenuSelect(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleMenuSelect(g *gocui.Gui, v *gocui.View) error {
|
||||||
gui.focusPoint(0, gui.State.Panels.Menu.SelectedLine, gui.State.MenuItemCount, v)
|
gui.focusY(gui.State.Panels.Menu.SelectedLine, gui.State.MenuItemCount, v)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ func (gui *Gui) handleServiceSelect(g *gocui.Gui, v *gocui.View) error {
|
||||||
containerID = service.Container.ID
|
containerID = service.Container.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.focusPoint(0, gui.State.Panels.Services.SelectedLine, len(gui.DockerCommand.Services), v)
|
gui.focusY(gui.State.Panels.Services.SelectedLine, len(gui.DockerCommand.Services), v)
|
||||||
|
|
||||||
key := "services-" + service.ID + "-" + containerID + "-" + gui.getServiceContexts()[gui.State.Panels.Services.ContextIndex]
|
key := "services-" + service.ID + "-" + containerID + "-" + gui.getServiceContexts()[gui.State.Panels.Services.ContextIndex]
|
||||||
if !gui.shouldRefresh(key) {
|
if !gui.shouldRefresh(key) {
|
||||||
|
|
@ -118,10 +118,10 @@ func (gui *Gui) renderServiceTop(service *commands.Service) error {
|
||||||
return gui.T.NewTickerTask(time.Second, func(stop chan struct{}) { gui.clearMainView() }, func(stop, notifyStopped chan struct{}) {
|
return gui.T.NewTickerTask(time.Second, func(stop chan struct{}) { gui.clearMainView() }, func(stop, notifyStopped chan struct{}) {
|
||||||
contents, err := service.RenderTop()
|
contents, err := service.RenderTop()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = gui.reRenderString(gui.g, "main", err.Error())
|
gui.reRenderStringMain(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = gui.reRenderString(gui.g, "main", contents)
|
gui.reRenderStringMain(contents)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ func (gui *Gui) switchFocus(g *gocui.Gui, oldView, newView *gocui.View, returnin
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the cursor down past the last item, move it to the last line
|
// if the cursor down past the last item, move it to the last line
|
||||||
|
// nolint:unparam
|
||||||
func (gui *Gui) focusPoint(selectedX int, selectedY int, lineCount int, v *gocui.View) {
|
func (gui *Gui) focusPoint(selectedX int, selectedY int, lineCount int, v *gocui.View) {
|
||||||
if selectedY < 0 || selectedY > lineCount {
|
if selectedY < 0 || selectedY > lineCount {
|
||||||
return
|
return
|
||||||
|
|
@ -192,12 +193,16 @@ func (gui *Gui) focusPoint(selectedX int, selectedY int, lineCount int, v *gocui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) focusY(selectedY int, lineCount int, v *gocui.View) {
|
||||||
|
gui.focusPoint(0, selectedY, lineCount, v)
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) cleanString(s string) string {
|
func (gui *Gui) cleanString(s string) string {
|
||||||
output := string(bom.Clean([]byte(s)))
|
output := string(bom.Clean([]byte(s)))
|
||||||
return utils.NormalizeLinefeeds(output)
|
return utils.NormalizeLinefeeds(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) setViewContent(g *gocui.Gui, v *gocui.View, s string) error {
|
func (gui *Gui) setViewContent(v *gocui.View, s string) error {
|
||||||
v.Clear()
|
v.Clear()
|
||||||
fmt.Fprint(v, gui.cleanString(s))
|
fmt.Fprint(v, gui.cleanString(s))
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -216,21 +221,25 @@ func (gui *Gui) renderString(g *gocui.Gui, viewName, s string) error {
|
||||||
if err := v.SetCursor(0, 0); err != nil {
|
if err := v.SetCursor(0, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return gui.setViewContent(gui.g, v, s)
|
return gui.setViewContent(v, s)
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reRenderString sets the main view's content, without changing its origin
|
||||||
|
func (gui *Gui) reRenderStringMain(s string) {
|
||||||
|
gui.reRenderString("main", s)
|
||||||
|
}
|
||||||
|
|
||||||
// reRenderString sets the view's content, without changing its origin
|
// reRenderString sets the view's content, without changing its origin
|
||||||
func (gui *Gui) reRenderString(g *gocui.Gui, viewName, s string) error {
|
func (gui *Gui) reRenderString(viewName, s string) {
|
||||||
g.Update(func(*gocui.Gui) error {
|
gui.g.Update(func(*gocui.Gui) error {
|
||||||
v, err := g.View(viewName)
|
v, err := gui.g.View(viewName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil // return gracefully if view has been deleted
|
return nil // return gracefully if view has been deleted
|
||||||
}
|
}
|
||||||
return gui.setViewContent(gui.g, v, s)
|
return gui.setViewContent(v, s)
|
||||||
})
|
})
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) optionsMapToString(optionsMap map[string]string) string {
|
func (gui *Gui) optionsMapToString(optionsMap map[string]string) string {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ func (gui *Gui) handleVolumeSelect(g *gocui.Gui, v *gocui.View) error {
|
||||||
return gui.renderString(g, "main", gui.Tr.NoVolumes)
|
return gui.renderString(g, "main", gui.Tr.NoVolumes)
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.focusPoint(0, gui.State.Panels.Volumes.SelectedLine, len(gui.DockerCommand.Volumes), v)
|
gui.focusY(gui.State.Panels.Volumes.SelectedLine, len(gui.DockerCommand.Volumes), v)
|
||||||
|
|
||||||
key := "volumes-" + volume.Name + "-" + gui.getVolumeContexts()[gui.State.Panels.Volumes.ContextIndex]
|
key := "volumes-" + volume.Name + "-" + gui.getVolumeContexts()[gui.State.Panels.Volumes.ContextIndex]
|
||||||
if !gui.shouldRefresh(key) {
|
if !gui.shouldRefresh(key) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue