Skip to content

Commit

Permalink
help -> menu
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidd6 committed Sep 5, 2018
1 parent e21f739 commit 557009e
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion pkg/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
})
}

Expand Down
16 changes: 8 additions & 8 deletions pkg/gui/keybindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (gui *Gui) GetKeybindings() []Binding {
ViewName: "",
Key: '?',
Modifier: gocui.ModNone,
Handler: gui.handleHelp,
Handler: gui.handleMenu,
}, {
ViewName: "status",
Key: 'e',
Expand Down Expand Up @@ -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},
Expand Down
28 changes: 14 additions & 14 deletions pkg/gui/help_panel.go → pkg/gui/menu_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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"),
Expand All @@ -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
}
Expand Down Expand Up @@ -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 := ""
Expand All @@ -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
}
4 changes: 2 additions & 2 deletions pkg/gui/view_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
4 changes: 2 additions & 2 deletions pkg/i18n/dutch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pkg/i18n/polish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_cheatsheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down

0 comments on commit 557009e

Please sign in to comment.