1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-04 03:48:07 +02:00

help -> menu

This commit is contained in:
Dawid Dziurla 2018-09-05 11:12:11 +02:00
parent e21f739f4f
commit 557009e660
No known key found for this signature in database
GPG Key ID: 7B6D8368172E9B0B
8 changed files with 31 additions and 31 deletions

View File

@ -356,7 +356,7 @@ func (gui *Gui) renderGlobalOptions(g *gocui.Gui) error {
"PgUp/PgDn": gui.Tr.SLocalize("scroll"),
"← → ↑ ↓": gui.Tr.SLocalize("navigate"),
"esc/q": gui.Tr.SLocalize("close"),
"?": gui.Tr.SLocalize("help"),
"?": gui.Tr.SLocalize("menu"),
})
}

View File

@ -70,7 +70,7 @@ func (gui *Gui) GetKeybindings() []Binding {
ViewName: "",
Key: '?',
Modifier: gocui.ModNone,
Handler: gui.handleHelp,
Handler: gui.handleMenu,
}, {
ViewName: "status",
Key: 'e',
@ -342,26 +342,26 @@ func (gui *Gui) GetKeybindings() []Binding {
Modifier: gocui.ModNone,
Handler: gui.handleNewlineCommitMessage,
}, {
ViewName: "help",
ViewName: "menu",
Key: gocui.KeyEsc,
Modifier: gocui.ModNone,
Handler: gui.handleHelpClose,
Handler: gui.handleMenuClose,
}, {
ViewName: "help",
ViewName: "menu",
Key: 'q',
Modifier: gocui.ModNone,
Handler: gui.handleHelpClose,
Handler: gui.handleMenuClose,
}, {
ViewName: "help",
ViewName: "menu",
Key: gocui.KeySpace,
Modifier: gocui.ModNone,
Handler: gui.handleHelpPress,
Handler: gui.handleMenuPress,
},
}
// Would make these keybindings global but that interferes with editing
// input in the confirmation panel
for _, viewName := range []string{"status", "files", "branches", "commits", "stash", "help"} {
for _, viewName := range []string{"status", "files", "branches", "commits", "stash", "menu"} {
bindings = append(bindings, []Binding{
{ViewName: viewName, Key: gocui.KeyTab, Modifier: gocui.ModNone, Handler: gui.nextView},
{ViewName: viewName, Key: gocui.KeyArrowLeft, Modifier: gocui.ModNone, Handler: gui.previousView},

View File

@ -8,10 +8,10 @@ import (
"github.com/jesseduffield/lazygit/pkg/utils"
)
func (gui *Gui) handleHelpPress(g *gocui.Gui, v *gocui.View) error {
func (gui *Gui) handleMenuPress(g *gocui.Gui, v *gocui.View) error {
lineNumber := gui.getItemPosition(v)
if len(gui.State.Keys) > lineNumber {
err := gui.handleHelpClose(g, v)
err := gui.handleMenuClose(g, v)
if err != nil {
return err
}
@ -20,13 +20,13 @@ func (gui *Gui) handleHelpPress(g *gocui.Gui, v *gocui.View) error {
return nil
}
func (gui *Gui) handleHelpSelect(g *gocui.Gui, v *gocui.View) error {
func (gui *Gui) handleMenuSelect(g *gocui.Gui, v *gocui.View) error {
// doing nothing for now
// but it is needed for switch in newLineFocused
return nil
}
func (gui *Gui) renderHelpOptions(g *gocui.Gui) error {
func (gui *Gui) renderMenuOptions(g *gocui.Gui) error {
optionsMap := map[string]string{
"esc/q": gui.Tr.SLocalize("close"),
"↑ ↓": gui.Tr.SLocalize("navigate"),
@ -35,11 +35,11 @@ func (gui *Gui) renderHelpOptions(g *gocui.Gui) error {
return gui.renderOptionsMap(g, optionsMap)
}
func (gui *Gui) handleHelpClose(g *gocui.Gui, v *gocui.View) error {
func (gui *Gui) handleMenuClose(g *gocui.Gui, v *gocui.View) error {
// better to delete because for example after closing update confirmation panel,
// the focus isn't set back to any of panels and one is unable to even quit
//_, err := g.SetViewOnBottom(v.Name())
err := g.DeleteView("help")
err := g.DeleteView("menu")
if err != nil {
return err
}
@ -70,7 +70,7 @@ func (gui *Gui) getMaxKeyLength(bindings []Binding) int {
return max
}
func (gui *Gui) handleHelp(g *gocui.Gui, v *gocui.View) error {
func (gui *Gui) handleMenu(g *gocui.Gui, v *gocui.View) error {
// clear keys slice, so we don't have ghost elements
gui.State.Keys = gui.State.Keys[:0]
content := ""
@ -86,22 +86,22 @@ func (gui *Gui) handleHelp(g *gocui.Gui, v *gocui.View) error {
// y1-1 so there will not be an extra space at the end of panel
x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, content)
helpView, _ := g.SetView("help", x0, y0, x1, y1-1, 0)
helpView.Title = strings.Title(gui.Tr.SLocalize("help"))
helpView.FgColor = gocui.ColorWhite
menuView, _ := g.SetView("menu", x0, y0, x1, y1-1, 0)
menuView.Title = strings.Title(gui.Tr.SLocalize("menu"))
menuView.FgColor = gocui.ColorWhite
if err := gui.renderHelpOptions(g); err != nil {
if err := gui.renderMenuOptions(g); err != nil {
return err
}
fmt.Fprint(helpView, content)
fmt.Fprint(menuView, content)
g.Update(func(g *gocui.Gui) error {
_, err := g.SetViewOnTop("help")
_, err := g.SetViewOnTop("menu")
if err != nil {
return err
}
return gui.switchFocus(g, v, helpView)
return gui.switchFocus(g, v, menuView)
})
return nil
}

View File

@ -82,8 +82,8 @@ func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error {
mainView.SetOrigin(0, 0)
switch v.Name() {
case "help":
return gui.handleHelpSelect(g, v)
case "menu":
return gui.handleMenuSelect(g, v)
case "status":
return gui.handleStatusSelect(g, v)
case "files":

View File

@ -44,8 +44,8 @@ func addDutch(i18nObject *i18n.Bundle) error {
ID: "navigate",
Other: "navigeer",
}, &i18n.Message{
ID: "help",
Other: "help",
ID: "menu",
Other: "menu",
}, &i18n.Message{
ID: "execute",
Other: "execute",

View File

@ -52,8 +52,8 @@ func addEnglish(i18nObject *i18n.Bundle) error {
ID: "navigate",
Other: "navigate",
}, &i18n.Message{
ID: "help",
Other: "help",
ID: "menu",
Other: "menu",
}, &i18n.Message{
ID: "execute",
Other: "execute",

View File

@ -42,7 +42,7 @@ func addPolish(i18nObject *i18n.Bundle) error {
ID: "navigate",
Other: "nawiguj",
}, &i18n.Message{
ID: "help",
ID: "menu",
Other: "pomoc",
}, &i18n.Message{
ID: "execute",

View File

@ -24,7 +24,7 @@ func main() {
current := ""
content := ""
file.WriteString("# Lazygit " + a.Tr.SLocalize("help"))
file.WriteString("# Lazygit " + a.Tr.SLocalize("menu"))
for _, binding := range bindings {
if key := a.Gui.GetKey(binding); key != "" && binding.Description != "" {