fix jump panel keybindings display

This commit is contained in:
kohath 2024-11-25 20:25:02 +08:00
parent b8bf22ead8
commit 4cf9544abf
2 changed files with 20 additions and 9 deletions

View file

@ -525,7 +525,9 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
// Mapping number keys to jump between side panels // Mapping number keys to jump between side panels
for _, panel := range gui.allSidePanels() { for _, panel := range gui.allSidePanels() {
for idx := 1; idx <= len(gui.allSidePanels()); idx++ { for idx := 1; idx <= len(gui.allSidePanels()); idx++ {
bindings = append(bindings, &Binding{ViewName: panel.GetView().Name(), Key: rune('0' + idx), Modifier: gocui.ModNone, Handler: wrappedHandlerWithKey(gui.jumpToSideView, idx)}) bindings = append(bindings,
&Binding{ViewName: panel.GetView().Name(), Key: rune('0' + idx), Modifier: gocui.ModNone, Handler: wrappedHandlerWithKey(gui.jumpToSideView, idx)},
)
} }
} }

View file

@ -178,15 +178,24 @@ func (gui *Gui) createAllViews() error {
} }
func (gui *Gui) configureViewProperties() { func (gui *Gui) configureViewProperties() {
gui.Config.UserConfig.Gui.ShowPanelJumps = true
if gui.Config.UserConfig.Gui.ShowPanelJumps { if gui.Config.UserConfig.Gui.ShowPanelJumps {
gui.Views.Project.TitlePrefix = "[1]" // defualt use number key mapping
// TODO service panel appear condition? jumpLabels := []string{"[1]", "[2]", "[3]", "[4]", "[5]", "[6]"}
gui.Views.Services.TitlePrefix = "[2]" idx := 0
gui.Views.Containers.TitlePrefix = "[3]" gui.Views.Project.TitlePrefix = jumpLabels[idx]
gui.Views.Images.TitlePrefix = "[4]" idx++
gui.Views.Volumes.TitlePrefix = "[5]" if gui.DockerCommand.InDockerComposeProject {
gui.Views.Networks.TitlePrefix = "[6]" gui.Views.Services.TitlePrefix = jumpLabels[idx]
idx++
}
gui.Views.Containers.TitlePrefix = jumpLabels[idx]
idx++
gui.Views.Images.TitlePrefix = jumpLabels[idx]
idx++
gui.Views.Volumes.TitlePrefix = jumpLabels[idx]
idx++
gui.Views.Networks.TitlePrefix = jumpLabels[idx]
idx++
} else { } else {
gui.Views.Project.TitlePrefix = "" gui.Views.Project.TitlePrefix = ""
gui.Views.Services.TitlePrefix = "" gui.Views.Services.TitlePrefix = ""