1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-05-13 22:17:05 +02:00

#480 Allow cycling side panels with number keys

This commit is contained in:
Giorgio Previtera 2019-07-14 14:39:31 +01:00 committed by Jesse Duffield
parent a045313e08
commit ac5cbc1d2c
6 changed files with 80 additions and 0 deletions

View File

@ -609,6 +609,7 @@ func (gui *Gui) renderGlobalOptions() error {
"← → ↑ ↓": gui.Tr.SLocalize("navigate"),
"esc/q": gui.Tr.SLocalize("close"),
"x": gui.Tr.SLocalize("menu"),
"1-5": gui.Tr.SLocalize("jump"),
})
}

View File

@ -523,6 +523,36 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.handleOpenOldCommitFile,
Description: gui.Tr.SLocalize("openFile"),
},
{
ViewName: "",
Key: '1',
Modifier: gocui.ModNone,
Handler: gui.goToStatus,
},
{
ViewName: "",
Key: '2',
Modifier: gocui.ModNone,
Handler: gui.goToFiles,
},
{
ViewName: "",
Key: '3',
Modifier: gocui.ModNone,
Handler: gui.goToBranches,
},
{
ViewName: "",
Key: '4',
Modifier: gocui.ModNone,
Handler: gui.goToCommits,
},
{
ViewName: "",
Key: '5',
Modifier: gocui.ModNone,
Handler: gui.goToStash,
},
}
for _, viewName := range []string{"status", "branches", "files", "commits", "commitFiles", "stash", "menu"} {

View File

@ -139,6 +139,46 @@ func (gui *Gui) returnFocus(g *gocui.Gui, v *gocui.View) error {
return gui.switchFocus(g, v, previousView)
}
func (gui *Gui) goToStatus(g *gocui.Gui, v *gocui.View) error {
view, err := g.View("status")
if err != nil {
gui.Log.Error(err)
}
return gui.switchFocus(g, nil, view)
}
func (gui *Gui) goToFiles(g *gocui.Gui, v *gocui.View) error {
view, err := g.View("files")
if err != nil {
gui.Log.Error(err)
}
return gui.switchFocus(g, nil, view)
}
func (gui *Gui) goToBranches(g *gocui.Gui, v *gocui.View) error {
view, err := g.View("branches")
if err != nil {
gui.Log.Error(err)
}
return gui.switchFocus(g, nil, view)
}
func (gui *Gui) goToCommits(g *gocui.Gui, v *gocui.View) error {
view, err := g.View("commits")
if err != nil {
gui.Log.Error(err)
}
return gui.switchFocus(g, nil, view)
}
func (gui *Gui) goToStash(g *gocui.Gui, v *gocui.View) error {
view, err := g.View("stash")
if err != nil {
gui.Log.Error(err)
}
return gui.switchFocus(g, nil, view)
}
// pass in oldView = nil if you don't want to be able to return to your old view
// TODO: move some of this logic into our onFocusLost and onFocus hooks
func (gui *Gui) switchFocus(g *gocui.Gui, oldView, newView *gocui.View) error {

View File

@ -751,6 +751,9 @@ func addDutch(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "notARepository",
Other: "Error: must be run inside a git repository",
}, &i18n.Message{
ID: "jump",
Other: "jump to panel",
},
)
}

View File

@ -774,6 +774,9 @@ func addEnglish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "notARepository",
Other: "Error: must be run inside a git repository",
}, &i18n.Message{
ID: "jump",
Other: "jump to panel",
},
)
}

View File

@ -734,6 +734,9 @@ func addPolish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "notARepository",
Other: "Error: must be run inside a git repository",
}, &i18n.Message{
ID: "jump",
Other: "jump to panel",
},
)
}