Skip to content

Commit

Permalink
Add navigation with numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemxm committed Jul 27, 2024
1 parent 54a7211 commit 043176b
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/keybindings/Keybindings_de.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<pre>
<kbd>+</kbd>: next screen mode (normal/half/fullscreen)
<kbd>_</kbd>: prev screen mode
<kbd>1</kbd>: focus projects panel
<kbd>2</kbd>: focus services panel
<kbd>3</kbd>: focus containers panel
<kbd>4</kbd>: focus images panel
<kbd>5</kbd>: focus volumes panel
<kbd>6</kbd>: focus networks panel
</pre>
6 changes: 6 additions & 0 deletions docs/keybindings/Keybindings_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<pre>
<kbd>+</kbd>: next screen mode (normal/half/fullscreen)
<kbd>_</kbd>: prev screen mode
<kbd>1</kbd>: focus projects panel
<kbd>2</kbd>: focus services panel
<kbd>3</kbd>: focus containers panel
<kbd>4</kbd>: focus images panel
<kbd>5</kbd>: focus volumes panel
<kbd>6</kbd>: focus networks panel
</pre>
6 changes: 6 additions & 0 deletions docs/keybindings/Keybindings_es.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<pre>
<kbd>+</kbd>: next screen mode (normal/half/fullscreen)
<kbd>_</kbd>: prev screen mode
<kbd>1</kbd>: focus projects panel
<kbd>2</kbd>: focus services panel
<kbd>3</kbd>: focus containers panel
<kbd>4</kbd>: focus images panel
<kbd>5</kbd>: focus volumes panel
<kbd>6</kbd>: focus networks panel
</pre>
6 changes: 6 additions & 0 deletions docs/keybindings/Keybindings_fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<pre>
<kbd>+</kbd>: next screen mode (normal/half/fullscreen)
<kbd>_</kbd>: prev screen mode
<kbd>1</kbd>: focus projects panel
<kbd>2</kbd>: focus services panel
<kbd>3</kbd>: focus containers panel
<kbd>4</kbd>: focus images panel
<kbd>5</kbd>: focus volumes panel
<kbd>6</kbd>: focus networks panel
</pre>
6 changes: 6 additions & 0 deletions docs/keybindings/Keybindings_nl.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<pre>
<kbd>+</kbd>: next screen mode (normal/half/fullscreen)
<kbd>_</kbd>: prev screen mode
<kbd>1</kbd>: focus projects panel
<kbd>2</kbd>: focus services panel
<kbd>3</kbd>: focus containers panel
<kbd>4</kbd>: focus images panel
<kbd>5</kbd>: focus volumes panel
<kbd>6</kbd>: focus networks panel
</pre>
6 changes: 6 additions & 0 deletions docs/keybindings/Keybindings_pl.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<pre>
<kbd>+</kbd>: next screen mode (normal/half/fullscreen)
<kbd>_</kbd>: prev screen mode
<kbd>1</kbd>: focus projects panel
<kbd>2</kbd>: focus services panel
<kbd>3</kbd>: focus containers panel
<kbd>4</kbd>: focus images panel
<kbd>5</kbd>: focus volumes panel
<kbd>6</kbd>: focus networks panel
</pre>
6 changes: 6 additions & 0 deletions docs/keybindings/Keybindings_pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<pre>
<kbd>+</kbd>: modo de tela seguinte (normal/meia/tela cheia)
<kbd>_</kbd>: modo de tela anterior
<kbd>1</kbd>: focus projects panel
<kbd>2</kbd>: focus services panel
<kbd>3</kbd>: focus containers panel
<kbd>4</kbd>: focus images panel
<kbd>5</kbd>: focus volumes panel
<kbd>6</kbd>: focus networks panel
</pre>
6 changes: 6 additions & 0 deletions docs/keybindings/Keybindings_tr.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<pre>
<kbd>+</kbd>: next screen mode (normal/half/fullscreen)
<kbd>_</kbd>: prev screen mode
<kbd>1</kbd>: focus projects panel
<kbd>2</kbd>: focus services panel
<kbd>3</kbd>: focus containers panel
<kbd>4</kbd>: focus images panel
<kbd>5</kbd>: focus volumes panel
<kbd>6</kbd>: focus networks panel
</pre>
6 changes: 6 additions & 0 deletions docs/keybindings/Keybindings_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<pre>
<kbd>+</kbd>: 下一个屏幕模式(正常/半屏/全屏)
<kbd>_</kbd>: 上一个屏幕模式
<kbd>1</kbd>: focus projects panel
<kbd>2</kbd>: focus services panel
<kbd>3</kbd>: focus containers panel
<kbd>4</kbd>: focus images panel
<kbd>5</kbd>: focus volumes panel
<kbd>6</kbd>: focus networks panel
</pre>
9 changes: 9 additions & 0 deletions pkg/gui/keybindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,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.FocusNetwork},
}...)

for _, panel := range gui.allListPanels() {
setUpDownClickBindings(panel.GetView().Name(), panel.HandlePrevLine, panel.HandleNextLine, panel.HandleClick)
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/gui/view_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ type TranslationSet struct {
LcPrevScreenMode string
ClearMain string
FilterPrompt string

FocusProjects string
FocusServices string
FocusContainers string
FocusImages string
FocusVolumes string
FocusNetwork string
}

func englishSet() TranslationSet {
Expand Down Expand Up @@ -265,5 +272,12 @@ func englishSet() TranslationSet {
LcPrevScreenMode: "prev screen mode",
ClearMain: "clear main panel",
FilterPrompt: "filter",

FocusProjects: "focus projects panel",
FocusServices: "focus services panel",
FocusContainers: "focus containers panel",
FocusImages: "focus images panel",
FocusVolumes: "focus volumes panel",
FocusNetwork: "focus networks panel",
}
}

0 comments on commit 043176b

Please sign in to comment.