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:
parent
a045313e08
commit
ac5cbc1d2c
@ -609,6 +609,7 @@ func (gui *Gui) renderGlobalOptions() error {
|
|||||||
"← → ↑ ↓": gui.Tr.SLocalize("navigate"),
|
"← → ↑ ↓": gui.Tr.SLocalize("navigate"),
|
||||||
"esc/q": gui.Tr.SLocalize("close"),
|
"esc/q": gui.Tr.SLocalize("close"),
|
||||||
"x": gui.Tr.SLocalize("menu"),
|
"x": gui.Tr.SLocalize("menu"),
|
||||||
|
"1-5": gui.Tr.SLocalize("jump"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,6 +523,36 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
Handler: gui.handleOpenOldCommitFile,
|
Handler: gui.handleOpenOldCommitFile,
|
||||||
Description: gui.Tr.SLocalize("openFile"),
|
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"} {
|
for _, viewName := range []string{"status", "branches", "files", "commits", "commitFiles", "stash", "menu"} {
|
||||||
|
@ -139,6 +139,46 @@ func (gui *Gui) returnFocus(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return gui.switchFocus(g, v, previousView)
|
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
|
// 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
|
// TODO: move some of this logic into our onFocusLost and onFocus hooks
|
||||||
func (gui *Gui) switchFocus(g *gocui.Gui, oldView, newView *gocui.View) error {
|
func (gui *Gui) switchFocus(g *gocui.Gui, oldView, newView *gocui.View) error {
|
||||||
|
@ -751,6 +751,9 @@ func addDutch(i18nObject *i18n.Bundle) error {
|
|||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "notARepository",
|
ID: "notARepository",
|
||||||
Other: "Error: must be run inside a git repository",
|
Other: "Error: must be run inside a git repository",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "jump",
|
||||||
|
Other: "jump to panel",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -774,6 +774,9 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
|||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "notARepository",
|
ID: "notARepository",
|
||||||
Other: "Error: must be run inside a git repository",
|
Other: "Error: must be run inside a git repository",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "jump",
|
||||||
|
Other: "jump to panel",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -734,6 +734,9 @@ func addPolish(i18nObject *i18n.Bundle) error {
|
|||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "notARepository",
|
ID: "notARepository",
|
||||||
Other: "Error: must be run inside a git repository",
|
Other: "Error: must be run inside a git repository",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "jump",
|
||||||
|
Other: "jump to panel",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user