diff --git a/docs/Config.md b/docs/Config.md index 0102596f..645d5919 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -13,6 +13,8 @@ gui: - white optionsTextColor: - blue + returnImmediately: false + wrapMainPanel: false reporting: undetermined commandTemplates: dockerCompose: docker-compose diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index a2c1dbed..971ac0e7 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -96,12 +96,15 @@ type GuiConfig struct { // of clutter ShowAllContainers bool `yaml:"showAllContainers,omitempty"` - // PromptToReturn determines whether you get the 'press enter to return to + // ReturnImmediately determines whether you get the 'press enter to return to // lazydocker' message after a subprocess has completed. You would set this to // true if you often want to see the output of subprocesses before returning // to lazydocker. I would default this to false but then people who want it // set to true won't even know the config option exists. - PromptToReturn bool `yaml:"promptToReturn,omitempty"` + ReturnImmediately bool `yaml:"returnImmediately,omitempty"` + + // WrapMainPanel determines whether we use word wrap on the main panel + WrapMainPanel bool `yaml:"wrapMainPanel,omitempty"` } // CommandTemplatesConfig determines what commands actually get called when we @@ -296,6 +299,8 @@ func GetDefaultConfig() UserConfig { OptionsTextColor: []string{"blue"}, }, ShowAllContainers: false, + ReturnImmediately: false, + WrapMainPanel: false, }, Reporting: "undetermined", ConfirmOnQuit: false, diff --git a/pkg/gui/containers_panel.go b/pkg/gui/containers_panel.go index 3f101979..4b5a6135 100644 --- a/pkg/gui/containers_panel.go +++ b/pkg/gui/containers_panel.go @@ -92,7 +92,7 @@ func (gui *Gui) handleContainerSelect(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) renderContainerConfig(container *commands.Container) error { mainView := gui.getMainView() mainView.Autoscroll = false - mainView.Wrap = false + mainView.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel padding := 10 output := "" @@ -142,7 +142,7 @@ func (gui *Gui) renderContainerConfig(container *commands.Container) error { func (gui *Gui) renderContainerStats(container *commands.Container) error { mainView := gui.getMainView() mainView.Autoscroll = false - mainView.Wrap = false + mainView.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel return gui.T.NewTickerTask(time.Second, func(stop chan struct{}) { gui.clearMainView() }, func(stop, notifyStopped chan struct{}) { width, _ := mainView.Size() @@ -159,7 +159,7 @@ func (gui *Gui) renderContainerStats(container *commands.Container) error { func (gui *Gui) renderContainerTop(container *commands.Container) error { mainView := gui.getMainView() mainView.Autoscroll = false - mainView.Wrap = false + mainView.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel return gui.T.NewTickerTask(time.Second, func(stop chan struct{}) { gui.clearMainView() }, func(stop, notifyStopped chan struct{}) { contents, err := container.RenderTop() @@ -174,7 +174,7 @@ func (gui *Gui) renderContainerTop(container *commands.Container) error { func (gui *Gui) renderContainerLogs(container *commands.Container) error { mainView := gui.getMainView() mainView.Autoscroll = true - mainView.Wrap = false + mainView.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel return gui.T.NewTickerTask(time.Millisecond*200, nil, func(stop, notifyStopped chan struct{}) { gui.clearMainView() diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 5b3ec30d..c567a952 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -87,6 +87,7 @@ type statusState struct { type menuPanelState struct { SelectedLine int + OnPress func(*gocui.Gui, *gocui.View) error } type mainPanelState struct { diff --git a/pkg/gui/images_panel.go b/pkg/gui/images_panel.go index 91ba7f8a..62b7604d 100644 --- a/pkg/gui/images_panel.go +++ b/pkg/gui/images_panel.go @@ -92,7 +92,7 @@ func (gui *Gui) renderImageConfig(mainView *gocui.View, image *commands.Image) e output += "\n\n" + history mainView.Autoscroll = false - mainView.Wrap = false + mainView.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel gui.renderString(gui.g, "main", output) }) diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go index de6d0e2c..78a498b5 100644 --- a/pkg/gui/layout.go +++ b/pkg/gui/layout.go @@ -169,7 +169,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { if err.Error() != "unknown view" { return err } - v.Wrap = false + v.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel v.FgColor = gocui.ColorWhite // when you run a docker container with the -it flags (interactive mode) it adds carriage returns for some reason. This is not docker's fault, it's an os-level default. diff --git a/pkg/gui/menu_panel.go b/pkg/gui/menu_panel.go index 083f5e01..0602bdab 100644 --- a/pkg/gui/menu_panel.go +++ b/pkg/gui/menu_panel.go @@ -25,7 +25,11 @@ func (gui *Gui) handleMenuClick(g *gocui.Gui, v *gocui.View) error { handleSelect := gui.handleMenuSelect selectedLine := &gui.State.Panels.Menu.SelectedLine - return gui.handleClick(v, itemCount, selectedLine, handleSelect) + if err := gui.handleClick(v, itemCount, selectedLine, handleSelect); err != nil { + return err + } + + return gui.State.Panels.Menu.OnPress(g, v) } func (gui *Gui) handleMenuPrevLine(g *gocui.Gui, v *gocui.View) error { @@ -89,6 +93,8 @@ func (gui *Gui) createMenu(title string, items interface{}, itemCount int, handl return gui.returnFocus(gui.g, menuView) } + gui.State.Panels.Menu.OnPress = wrappedHandlePress + for _, key := range []gocui.Key{gocui.KeySpace, gocui.KeyEnter, 'y'} { _ = gui.g.DeleteKeybinding("menu", key, gocui.ModNone) diff --git a/pkg/gui/services_panel.go b/pkg/gui/services_panel.go index 8bdee811..0c1e7a43 100644 --- a/pkg/gui/services_panel.go +++ b/pkg/gui/services_panel.go @@ -102,7 +102,7 @@ func (gui *Gui) renderServiceStats(service *commands.Service) error { func (gui *Gui) renderServiceTop(service *commands.Service) error { mainView := gui.getMainView() mainView.Autoscroll = false - mainView.Wrap = false + mainView.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel return gui.T.NewTickerTask(time.Second, func(stop chan struct{}) { gui.clearMainView() }, func(stop, notifyStopped chan struct{}) { contents, err := service.RenderTop() diff --git a/pkg/gui/status_panel.go b/pkg/gui/status_panel.go index 9017af80..3e09aae0 100644 --- a/pkg/gui/status_panel.go +++ b/pkg/gui/status_panel.go @@ -91,7 +91,7 @@ func (gui *Gui) renderCredits() error { return gui.T.NewTask(func(stop chan struct{}) { mainView := gui.getMainView() mainView.Autoscroll = false - mainView.Wrap = false + mainView.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel var configBuf bytes.Buffer yaml.NewEncoder(&configBuf, yaml.IncludeOmitted).Encode(gui.Config.UserConfig) @@ -116,7 +116,7 @@ func (gui *Gui) renderAllLogs() error { return gui.T.NewTask(func(stop chan struct{}) { mainView := gui.getMainView() mainView.Autoscroll = true - mainView.Wrap = false + mainView.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel gui.clearMainView() @@ -148,7 +148,7 @@ func (gui *Gui) renderDockerComposeConfig() error { return gui.T.NewTask(func(stop chan struct{}) { mainView := gui.getMainView() mainView.Autoscroll = false - mainView.Wrap = false + mainView.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel config := gui.DockerCommand.DockerComposeConfig() gui.renderString(gui.g, "main", config) diff --git a/pkg/gui/subprocess.go b/pkg/gui/subprocess.go index 11965bc8..7d2c72d0 100644 --- a/pkg/gui/subprocess.go +++ b/pkg/gui/subprocess.go @@ -72,8 +72,8 @@ func (gui *Gui) runCommand() error { signal.Stop(c) - if gui.Config.UserConfig.Gui.PromptToReturn { - fmt.Fprintf(os.Stdout, "\n%s", utils.ColoredString(gui.Tr.PressEnterToReturn, color.FgGreen)) + if !gui.Config.UserConfig.Gui.ReturnImmediately { + fmt.Fprintf(os.Stdout, "\n\n%s", utils.ColoredString(gui.Tr.PressEnterToReturn, color.FgGreen)) // wait for enter press if _, err := fmt.Scanln(); err != nil { diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 08a72f6d..e3c51312 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -74,7 +74,7 @@ func (gui *Gui) previousView(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) resetMainView() { gui.State.Panels.Main.ObjectKey = "" - gui.getMainView().Wrap = false + gui.getMainView().Wrap = gui.Config.UserConfig.Gui.WrapMainPanel } func (gui *Gui) newLineFocused(v *gocui.View) error { diff --git a/pkg/gui/volumes_panel.go b/pkg/gui/volumes_panel.go index dceab127..2fb4291e 100644 --- a/pkg/gui/volumes_panel.go +++ b/pkg/gui/volumes_panel.go @@ -74,7 +74,7 @@ func (gui *Gui) handleVolumeSelect(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) renderVolumeConfig(mainView *gocui.View, volume *commands.Volume) error { return gui.T.NewTask(func(stop chan struct{}) { mainView.Autoscroll = false - mainView.Wrap = false + mainView.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel padding := 15 output := "" diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 69dc6a56..130f3674 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -167,6 +167,6 @@ func englishSet() TranslationSet { ConfirmPruneVolumes: "Are you sure you want to prune all unused volumes?", StopService: "Are you sure you want to stop this service's containers? (enter/esc)", StopContainer: "Are you sure you want to stop this container?", - PressEnterToReturn: "Press enter to return to lazydocker (this prompt can be disabled in your config)", + PressEnterToReturn: "Press enter to return to lazydocker (this prompt can be disabled in your config by setting `gui.returnImmediately: true`)", } }