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
for _, panel := range gui.allSidePanels() {
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() {
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]"
// defualt use number key mapping
jumpLabels := []string{"[1]", "[2]", "[3]", "[4]", "[5]", "[6]"}
idx := 0
gui.Views.Project.TitlePrefix = jumpLabels[idx]
idx++
if gui.DockerCommand.InDockerComposeProject {
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 {
gui.Views.Project.TitlePrefix = ""
gui.Views.Services.TitlePrefix = ""