From 86cce8495521e4d54b753a9e7c16f462f2ddb864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=89AU?= Date: Wed, 5 Jun 2024 20:59:24 +0200 Subject: [PATCH] Add navigation via numbers A la lazygit, we can now navigate between panels using numbers (1,2,3,4,5,6,7) Add translation for number navigation reformat oops fix translation case & generate docs pluralize networks --- docs/keybindings/Keybindings_de.md | 6 ++++++ docs/keybindings/Keybindings_en.md | 6 ++++++ docs/keybindings/Keybindings_es.md | 6 ++++++ docs/keybindings/Keybindings_fr.md | 6 ++++++ docs/keybindings/Keybindings_nl.md | 6 ++++++ docs/keybindings/Keybindings_pl.md | 6 ++++++ docs/keybindings/Keybindings_pt.md | 6 ++++++ docs/keybindings/Keybindings_tr.md | 6 ++++++ docs/keybindings/Keybindings_zh.md | 6 ++++++ pkg/gui/keybindings.go | 9 +++++++++ pkg/gui/view_helpers.go | 7 +++++++ pkg/i18n/english.go | 14 ++++++++++++++ 12 files changed, 84 insertions(+) diff --git a/docs/keybindings/Keybindings_de.md b/docs/keybindings/Keybindings_de.md index f463e21b..2d306a2d 100644 --- a/docs/keybindings/Keybindings_de.md +++ b/docs/keybindings/Keybindings_de.md @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   +: next screen mode (normal/half/fullscreen)
   _: prev screen mode
+  1: focus projects panel
+  2: focus services panel
+  3: focus containers panel
+  4: focus images panel
+  5: focus volumes panel
+  6: focus networks panel
 
diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index a5a8ff3f..13470d1d 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   +: next screen mode (normal/half/fullscreen)
   _: prev screen mode
+  1: focus projects panel
+  2: focus services panel
+  3: focus containers panel
+  4: focus images panel
+  5: focus volumes panel
+  6: focus networks panel
 
diff --git a/docs/keybindings/Keybindings_es.md b/docs/keybindings/Keybindings_es.md index ff4eee14..145c7a22 100644 --- a/docs/keybindings/Keybindings_es.md +++ b/docs/keybindings/Keybindings_es.md @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   +: next screen mode (normal/half/fullscreen)
   _: prev screen mode
+  1: focus projects panel
+  2: focus services panel
+  3: focus containers panel
+  4: focus images panel
+  5: focus volumes panel
+  6: focus networks panel
 
diff --git a/docs/keybindings/Keybindings_fr.md b/docs/keybindings/Keybindings_fr.md index 64fb4197..260fe0bd 100644 --- a/docs/keybindings/Keybindings_fr.md +++ b/docs/keybindings/Keybindings_fr.md @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   +: next screen mode (normal/half/fullscreen)
   _: prev screen mode
+  1: focus projects panel
+  2: focus services panel
+  3: focus containers panel
+  4: focus images panel
+  5: focus volumes panel
+  6: focus networks panel
 
diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index 3de0c93e..dca57f64 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   +: next screen mode (normal/half/fullscreen)
   _: prev screen mode
+  1: focus projects panel
+  2: focus services panel
+  3: focus containers panel
+  4: focus images panel
+  5: focus volumes panel
+  6: focus networks panel
 
diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index 8d46b0ef..c290fdc2 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   +: next screen mode (normal/half/fullscreen)
   _: prev screen mode
+  1: focus projects panel
+  2: focus services panel
+  3: focus containers panel
+  4: focus images panel
+  5: focus volumes panel
+  6: focus networks panel
 
diff --git a/docs/keybindings/Keybindings_pt.md b/docs/keybindings/Keybindings_pt.md index 41604314..73544cc9 100644 --- a/docs/keybindings/Keybindings_pt.md +++ b/docs/keybindings/Keybindings_pt.md @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   +: modo de tela seguinte (normal/meia/tela cheia)
   _: modo de tela anterior
+  1: focus projects panel
+  2: focus services panel
+  3: focus containers panel
+  4: focus images panel
+  5: focus volumes panel
+  6: focus networks panel
 
diff --git a/docs/keybindings/Keybindings_tr.md b/docs/keybindings/Keybindings_tr.md index 018f68c2..787d7d15 100644 --- a/docs/keybindings/Keybindings_tr.md +++ b/docs/keybindings/Keybindings_tr.md @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   +: next screen mode (normal/half/fullscreen)
   _: prev screen mode
+  1: focus projects panel
+  2: focus services panel
+  3: focus containers panel
+  4: focus images panel
+  5: focus volumes panel
+  6: focus networks panel
 
diff --git a/docs/keybindings/Keybindings_zh.md b/docs/keybindings/Keybindings_zh.md index 8b1607dd..0e47a44e 100644 --- a/docs/keybindings/Keybindings_zh.md +++ b/docs/keybindings/Keybindings_zh.md @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   +: 下一个屏幕模式(正常/半屏/全屏)
   _: 上一个屏幕模式
+  1: focus projects panel
+  2: focus services panel
+  3: focus containers panel
+  4: focus images panel
+  5: focus volumes panel
+  6: focus networks panel
 
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 424f47c5..df706024 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -534,6 +534,15 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { }...) } + bindings = append(bindings, []*Binding{ + {Handler: gui.handleGoTo(gui.Panels.Projects.View), Key: '1', Description: gui.Tr.FocusProjects}, + {Handler: gui.handleGoTo(gui.Panels.Services.View), Key: '2', Description: gui.Tr.FocusServices}, + {Handler: gui.handleGoTo(gui.Panels.Containers.View), Key: '3', Description: gui.Tr.FocusContainers}, + {Handler: gui.handleGoTo(gui.Panels.Images.View), Key: '4', Description: gui.Tr.FocusImages}, + {Handler: gui.handleGoTo(gui.Panels.Volumes.View), Key: '5', Description: gui.Tr.FocusVolumes}, + {Handler: gui.handleGoTo(gui.Panels.Networks.View), Key: '6', Description: gui.Tr.FocusNetworks}, + }...) + for _, panel := range gui.allListPanels() { setUpDownClickBindings(panel.GetView().Name(), panel.HandlePrevLine, panel.HandleNextLine, panel.HandleClick) } diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 5e2b72fb..6acbb18c 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -12,6 +12,13 @@ import ( "github.com/spkg/bom" ) +func (gui *Gui) handleGoTo(view *gocui.View) func(g *gocui.Gui, v *gocui.View) error { + return func(g *gocui.Gui, v *gocui.View) error { + gui.resetMainView() + return gui.switchFocus(view) + } +} + func (gui *Gui) nextView(g *gocui.Gui, v *gocui.View) error { sideViewNames := gui.sideViewNames() var focusedViewName string diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 0d4f8222..d1ed0320 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -128,6 +128,13 @@ type TranslationSet struct { LcNextScreenMode string LcPrevScreenMode string FilterPrompt string + + FocusProjects string + FocusServices string + FocusContainers string + FocusImages string + FocusVolumes string + FocusNetworks string } func englishSet() TranslationSet { @@ -263,5 +270,12 @@ func englishSet() TranslationSet { LcNextScreenMode: "next screen mode (normal/half/fullscreen)", LcPrevScreenMode: "prev screen mode", FilterPrompt: "filter", + + FocusProjects: "focus projects panel", + FocusServices: "focus services panel", + FocusContainers: "focus containers panel", + FocusImages: "focus images panel", + FocusVolumes: "focus volumes panel", + FocusNetworks: "focus networks panel", } }