more stuff

This commit is contained in:
Jesse Duffield 2019-06-30 11:40:55 +10:00
parent 4416a5fa86
commit ea8258d66e
13 changed files with 32 additions and 18 deletions

View file

@ -13,6 +13,8 @@ gui:
- white
optionsTextColor:
- blue
returnImmediately: false
wrapMainPanel: false
reporting: undetermined
commandTemplates:
dockerCompose: docker-compose

View file

@ -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,

View file

@ -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()

View file

@ -87,6 +87,7 @@ type statusState struct {
type menuPanelState struct {
SelectedLine int
OnPress func(*gocui.Gui, *gocui.View) error
}
type mainPanelState struct {

View file

@ -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)
})

View file

@ -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.

View file

@ -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)

View file

@ -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()

View file

@ -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)

View file

@ -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 {

View file

@ -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 {

View file

@ -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 := ""

View file

@ -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`)",
}
}