mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-07 22:02:56 +03:00
help -> menu
This commit is contained in:
@@ -356,7 +356,7 @@ func (gui *Gui) renderGlobalOptions(g *gocui.Gui) error {
|
|||||||
"PgUp/PgDn": gui.Tr.SLocalize("scroll"),
|
"PgUp/PgDn": gui.Tr.SLocalize("scroll"),
|
||||||
"← → ↑ ↓": gui.Tr.SLocalize("navigate"),
|
"← → ↑ ↓": gui.Tr.SLocalize("navigate"),
|
||||||
"esc/q": gui.Tr.SLocalize("close"),
|
"esc/q": gui.Tr.SLocalize("close"),
|
||||||
"?": gui.Tr.SLocalize("help"),
|
"?": gui.Tr.SLocalize("menu"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,7 +70,7 @@ func (gui *Gui) GetKeybindings() []Binding {
|
|||||||
ViewName: "",
|
ViewName: "",
|
||||||
Key: '?',
|
Key: '?',
|
||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.handleHelp,
|
Handler: gui.handleMenu,
|
||||||
}, {
|
}, {
|
||||||
ViewName: "status",
|
ViewName: "status",
|
||||||
Key: 'e',
|
Key: 'e',
|
||||||
@@ -342,26 +342,26 @@ func (gui *Gui) GetKeybindings() []Binding {
|
|||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.handleNewlineCommitMessage,
|
Handler: gui.handleNewlineCommitMessage,
|
||||||
}, {
|
}, {
|
||||||
ViewName: "help",
|
ViewName: "menu",
|
||||||
Key: gocui.KeyEsc,
|
Key: gocui.KeyEsc,
|
||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.handleHelpClose,
|
Handler: gui.handleMenuClose,
|
||||||
}, {
|
}, {
|
||||||
ViewName: "help",
|
ViewName: "menu",
|
||||||
Key: 'q',
|
Key: 'q',
|
||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.handleHelpClose,
|
Handler: gui.handleMenuClose,
|
||||||
}, {
|
}, {
|
||||||
ViewName: "help",
|
ViewName: "menu",
|
||||||
Key: gocui.KeySpace,
|
Key: gocui.KeySpace,
|
||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.handleHelpPress,
|
Handler: gui.handleMenuPress,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Would make these keybindings global but that interferes with editing
|
// Would make these keybindings global but that interferes with editing
|
||||||
// input in the confirmation panel
|
// 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{
|
bindings = append(bindings, []Binding{
|
||||||
{ViewName: viewName, Key: gocui.KeyTab, Modifier: gocui.ModNone, Handler: gui.nextView},
|
{ViewName: viewName, Key: gocui.KeyTab, Modifier: gocui.ModNone, Handler: gui.nextView},
|
||||||
{ViewName: viewName, Key: gocui.KeyArrowLeft, Modifier: gocui.ModNone, Handler: gui.previousView},
|
{ViewName: viewName, Key: gocui.KeyArrowLeft, Modifier: gocui.ModNone, Handler: gui.previousView},
|
||||||
|
@@ -8,10 +8,10 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"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)
|
lineNumber := gui.getItemPosition(v)
|
||||||
if len(gui.State.Keys) > lineNumber {
|
if len(gui.State.Keys) > lineNumber {
|
||||||
err := gui.handleHelpClose(g, v)
|
err := gui.handleMenuClose(g, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -20,13 +20,13 @@ func (gui *Gui) handleHelpPress(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return nil
|
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
|
// doing nothing for now
|
||||||
// but it is needed for switch in newLineFocused
|
// but it is needed for switch in newLineFocused
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) renderHelpOptions(g *gocui.Gui) error {
|
func (gui *Gui) renderMenuOptions(g *gocui.Gui) error {
|
||||||
optionsMap := map[string]string{
|
optionsMap := map[string]string{
|
||||||
"esc/q": gui.Tr.SLocalize("close"),
|
"esc/q": gui.Tr.SLocalize("close"),
|
||||||
"↑ ↓": gui.Tr.SLocalize("navigate"),
|
"↑ ↓": gui.Tr.SLocalize("navigate"),
|
||||||
@@ -35,11 +35,11 @@ func (gui *Gui) renderHelpOptions(g *gocui.Gui) error {
|
|||||||
return gui.renderOptionsMap(g, optionsMap)
|
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,
|
// 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
|
// the focus isn't set back to any of panels and one is unable to even quit
|
||||||
//_, err := g.SetViewOnBottom(v.Name())
|
//_, err := g.SetViewOnBottom(v.Name())
|
||||||
err := g.DeleteView("help")
|
err := g.DeleteView("menu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ func (gui *Gui) getMaxKeyLength(bindings []Binding) int {
|
|||||||
return max
|
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
|
// clear keys slice, so we don't have ghost elements
|
||||||
gui.State.Keys = gui.State.Keys[:0]
|
gui.State.Keys = gui.State.Keys[:0]
|
||||||
content := ""
|
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
|
// y1-1 so there will not be an extra space at the end of panel
|
||||||
x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, content)
|
x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, content)
|
||||||
helpView, _ := g.SetView("help", x0, y0, x1, y1-1, 0)
|
menuView, _ := g.SetView("menu", x0, y0, x1, y1-1, 0)
|
||||||
helpView.Title = strings.Title(gui.Tr.SLocalize("help"))
|
menuView.Title = strings.Title(gui.Tr.SLocalize("menu"))
|
||||||
helpView.FgColor = gocui.ColorWhite
|
menuView.FgColor = gocui.ColorWhite
|
||||||
|
|
||||||
if err := gui.renderHelpOptions(g); err != nil {
|
if err := gui.renderMenuOptions(g); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprint(helpView, content)
|
fmt.Fprint(menuView, content)
|
||||||
|
|
||||||
g.Update(func(g *gocui.Gui) error {
|
g.Update(func(g *gocui.Gui) error {
|
||||||
_, err := g.SetViewOnTop("help")
|
_, err := g.SetViewOnTop("menu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return gui.switchFocus(g, v, helpView)
|
return gui.switchFocus(g, v, menuView)
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
@@ -82,8 +82,8 @@ func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error {
|
|||||||
mainView.SetOrigin(0, 0)
|
mainView.SetOrigin(0, 0)
|
||||||
|
|
||||||
switch v.Name() {
|
switch v.Name() {
|
||||||
case "help":
|
case "menu":
|
||||||
return gui.handleHelpSelect(g, v)
|
return gui.handleMenuSelect(g, v)
|
||||||
case "status":
|
case "status":
|
||||||
return gui.handleStatusSelect(g, v)
|
return gui.handleStatusSelect(g, v)
|
||||||
case "files":
|
case "files":
|
||||||
|
@@ -44,8 +44,8 @@ func addDutch(i18nObject *i18n.Bundle) error {
|
|||||||
ID: "navigate",
|
ID: "navigate",
|
||||||
Other: "navigeer",
|
Other: "navigeer",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "help",
|
ID: "menu",
|
||||||
Other: "help",
|
Other: "menu",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "execute",
|
ID: "execute",
|
||||||
Other: "execute",
|
Other: "execute",
|
||||||
|
@@ -52,8 +52,8 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
|||||||
ID: "navigate",
|
ID: "navigate",
|
||||||
Other: "navigate",
|
Other: "navigate",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "help",
|
ID: "menu",
|
||||||
Other: "help",
|
Other: "menu",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "execute",
|
ID: "execute",
|
||||||
Other: "execute",
|
Other: "execute",
|
||||||
|
@@ -42,7 +42,7 @@ func addPolish(i18nObject *i18n.Bundle) error {
|
|||||||
ID: "navigate",
|
ID: "navigate",
|
||||||
Other: "nawiguj",
|
Other: "nawiguj",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "help",
|
ID: "menu",
|
||||||
Other: "pomoc",
|
Other: "pomoc",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "execute",
|
ID: "execute",
|
||||||
|
@@ -24,7 +24,7 @@ func main() {
|
|||||||
current := ""
|
current := ""
|
||||||
content := ""
|
content := ""
|
||||||
|
|
||||||
file.WriteString("# Lazygit " + a.Tr.SLocalize("help"))
|
file.WriteString("# Lazygit " + a.Tr.SLocalize("menu"))
|
||||||
|
|
||||||
for _, binding := range bindings {
|
for _, binding := range bindings {
|
||||||
if key := a.Gui.GetKey(binding); key != "" && binding.Description != "" {
|
if key := a.Gui.GetKey(binding); key != "" && binding.Description != "" {
|
||||||
|
Reference in New Issue
Block a user