From b8bf22ead802837fbb3601dc8d4f149aee116c38 Mon Sep 17 00:00:00 2001 From: qihanghu Date: Mon, 25 Nov 2024 16:20:40 +0800 Subject: [PATCH] Show jump panel keybindings in panel titles --- pkg/config/app_config.go | 3 +++ pkg/gui/views.go | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 9c0ad474..5db49e82 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -127,6 +127,9 @@ type GuiConfig struct { // info and the status of the app). ShowBottomLine bool `yaml:"showBottomLine"` + // If true, show jump-to-window keybindings in window titles. + ShowPanelJumps bool `yaml:"showPanelJumps"` + // When true, increases vertical space used by focused side panel, // creating an accordion effect ExpandFocusedSidePanel bool `yaml:"expandFocusedSidePanel"` diff --git a/pkg/gui/views.go b/pkg/gui/views.go index 60cf7201..bfe4fdaf 100644 --- a/pkg/gui/views.go +++ b/pkg/gui/views.go @@ -112,6 +112,8 @@ func (gui *Gui) createAllViews() error { (*mapping.viewPtr).FgColor = gocui.ColorDefault } + gui.configureViewProperties() + selectedLineBgColor := GetGocuiStyle(gui.Config.UserConfig.Gui.Theme.SelectedLineBgColor) gui.Views.Main.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel @@ -175,6 +177,26 @@ func (gui *Gui) createAllViews() error { return nil } +func (gui *Gui) configureViewProperties() { + gui.Config.UserConfig.Gui.ShowPanelJumps = true + if gui.Config.UserConfig.Gui.ShowPanelJumps { + gui.Views.Project.TitlePrefix = "[1]" + // TODO service panel appear condition? + gui.Views.Services.TitlePrefix = "[2]" + gui.Views.Containers.TitlePrefix = "[3]" + gui.Views.Images.TitlePrefix = "[4]" + gui.Views.Volumes.TitlePrefix = "[5]" + gui.Views.Networks.TitlePrefix = "[6]" + } else { + gui.Views.Project.TitlePrefix = "" + gui.Views.Services.TitlePrefix = "" + gui.Views.Containers.TitlePrefix = "" + gui.Views.Images.TitlePrefix = "" + gui.Views.Volumes.TitlePrefix = "" + gui.Views.Networks.TitlePrefix = "" + } +} + func (gui *Gui) setInitialViewContent() error { if err := gui.renderString(gui.g, "information", gui.getInformationContent()); err != nil { return err