diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index ed7675796..f385b529b 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -1,50 +1,21 @@ -# Lazygit menu +# Lazygit Keybindings -## Global +## Global Keybindings
+ pgup: scroll up main panel (fn+up) + pgdown: scroll down main panel (fn+down) m: view merge/rebase options ctrl+p: view custom patch options P: push p: pull - R: refres + R: refresh +: next screen mode (normal/half/fullscreen) - _: prev screen mode + _: prev screen mode :: execute custom command-## Status - -
- e: edit config file - o: open config file - u: check for update - enter: switch to a recent repo -- -## Files - -
- c: commit changes - w: commit changes without pre-commit hook - A: amend last commit - C: commit changes using git editor - space: toggle staged - d: view 'discard changes' options - e: edit file - o: open file - i: add to .gitignore - r: refresh files - s: stash canges - S: view stash options - a: stage/unstage all - D: view reset options - enter: stage individual hunks/lines - f: fetch - X: execute custom command -- -## Branches +## Branches Panel (Branches Tab)
space: checkout @@ -53,14 +24,56 @@ F: force checkout n: new branch d: delete branch - r: rebase branch + r: rebase checked-out branch onto this branch M: merge into currently checked out branch i: show git-flow options f: fast-forward this branch from its upstream g: view reset options-## Commits +## Branches Panel (Remote Branches (in Remotes tab)) + +
+ esc: return to remotes list + g: view reset options + space: checkout + M: merge into currently checked out branch + d: delete branch + r: rebase checked-out branch onto this branch + u: set as upstream of checked-out branch ++ +## Branches Panel (Remotes Tab) + +
+ f: fetch remote + n: add new remote + d: remove remote + e: edit remote ++ +## Branches Panel (Tags Tab) + +
+ space: checkout + d: delete tag + P: push tag + n: create tag + g: view reset options ++ +## Commit Files Panel + +
+ esc: go back + c: checkout file + d: discard this commit's changes to this file + o: open file + space: toggle file included in patch + enter: enter file to add selected lines to the patch ++ +## Commits Panel (Commits Tab)
s: squash down @@ -81,60 +94,41 @@ C: copy commit range (cherry-pick) v: paste commits (cherry-pick) enter: view commit's files - space: select commit to diff with another commit + space: checkout commit i: select commit to diff with another commit T: tag commit-## Stash +## Commits Panel (Reflog Tab)
- space: apply - g: pop - d: drop + space: checkout commit + g: view reset options-## Commit files +## Files Panel
- esc: go back - c: checkout file - d: discard this commit's changes to this file - o: open file - space: toggle file included in patch - enter: enter file to add selected lines to the patch -- -## Main (Normal) - -
- PgDn: scroll down (fn+up) - PgUp: scroll up (fn+down) -- -## Main (Staging) - -
- esc: return to files panel - space: stage selection - d: reset selection - tab: switch to other panel - ▲: select previous line - ▼: select next line - ◄: select previous hunk - ►: select next hunk - space: stage line + c: commit changes + w: commit changes without pre-commit hook + A: amend last commit + C: commit changes using git editor + space: toggle staged + d: view 'discard changes' options e: edit file o: open file - v: toggle drag select - V: toggle drag select - a: toggle select hunk - c: commit chages - W: commit changes without pre-commit hook - C: commit changes using git editor + i: add to .gitignore + r: refresh files + s: stash changes + S: view stash options + a: stage/unstage all + D: view reset options + enter: stage individual hunks/lines + f: fetch + g: view upstream reset options-## Main (Merging) +## Main Panel (Merging)
esc: return to files panel @@ -146,3 +140,63 @@ ▼: select bottom hunk z: undo+ +## Main Panel (Normal) + +
+  ̄: scroll down (fn+up) + ¦: scroll up (fn+down) ++ +## Main Panel (Patch Building) + +
+ esc: exit line-by-line mode + ▲: select previous line + ▼: select next line + ◄: select previous hunk + ►: select next hunk + space: stage selection + d: reset selection + v: toggle drag select + V: toggle drag select + a: toggle select hunk ++ +## Main Panel (Staging) + +
+ esc: return to files panel + space: stage selection + d: reset selection + tab: switch to other panel + ▲: select previous line + ▼: select next line + ◄: select previous hunk + ►: select next hunk + e: edit file + o: open file + v: toggle drag select + V: toggle drag select + a: toggle select hunk + c: commit changes + w: commit changes without pre-commit hook + C: commit changes using git editor ++ +## Stash Panel + +
+ space: apply + g: pop + d: drop ++ +## Status Panel + +
+ e: edit config file + o: open config file + u: check for update + enter: switch to a recent repo +diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index fb0972ea6..0201252b1 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -1,46 +1,21 @@ -# Lazygit menu +# Lazygit Keybindings ## Global
+ pgup: scroll up main panel (fn+up) + pgdown: scroll down main panel (fn+down) m: bekijk merge/rebase opties + ctrl+p: view custom patch options P: push p: pull R: verversen + +: next screen mode (normal/half/fullscreen) + _: prev screen mode + :: voor aangepast commando uit-## Status - -
- e: verander config file - o: open config file - u: check voor updates - s: wissel naar een recente repo -- -## Bestanden - -
- c: Commit veranderingen - w: commit veranderingen zonder pre-commit hook - A: wijzig laatste commit - C: commit veranderingen met de git editor - space: toggle staged - d: bekijk 'veranderingen ongedaan maken' opties - e: verander bestand - o: open bestand - i: voeg toe aan .gitignore - r: refresh bestanden - S: stash-bestanden - a: toggle staged alle - t: bewerkingen toevoegen - D: bekijk reset opties - enter: stage individuele hunks/lijnen - f: fetch - X: voor aangepast commando uit -- -## Branches +## Branches Panel (Branches Tab)
space: uitchecken @@ -51,10 +26,54 @@ d: verwijder branch r: rebase branch M: merge in met huidige checked out branch + i: show git-flow options f: fast-forward this branch from its upstream + g: bekijk reset opties-## Commits +## Branches Panel (Remote Branches (in Remotes tab)) + +
+ esc: return to remotes list + g: bekijk reset opties + space: uitchecken + M: merge in met huidige checked out branch + d: verwijder branch + r: rebase branch + u: set as upstream of checked-out branch ++ +## Branches Panel (Remotes Tab) + +
+ f: fetch remote + n: add new remote + d: remove remote + e: edit remote ++ +## Branches Panel (Tags Tab) + +
+ space: uitchecken + d: delete tag + P: push tag + n: create tag + g: bekijk reset opties ++ +## Commit bestanden Panel + +
+ esc: ga terug + c: bestand uitchecken + d: uitsluit deze commit zijn veranderingen aan dit bestand + o: open bestand + space: toggle file included in patch + enter: enter file to add selected lines to the patch ++ +## Commits Panel (Commits Tab)
s: squash beneden @@ -75,39 +94,41 @@ C: kopiëer commit reeks (cherry-pick) v: plak commits (cherry-pick) enter: bekijk gecommite bestanden - space: select commit to diff with another commit + space: checkout commit + i: select commit to diff with another commit + T: tag commit-## Stash +## Commits Panel (Reflog Tab)
- space: toepassen - g: pop - d: drop + space: checkout commit + g: bekijk reset opties-## Commit bestanden +## Bestanden Panel
- esc: ga terug - c: bestand uitchecken - d: uitsluit deze commit zijn veranderingen aan dit bestand + c: Commit veranderingen + w: commit veranderingen zonder pre-commit hook + A: wijzig laatste commit + C: commit veranderingen met de git editor + space: toggle staged + d: bekijk 'veranderingen ongedaan maken' opties + e: verander bestand o: open bestand + i: voeg toe aan .gitignore + r: refresh bestanden + s: stash-bestanden + S: view stash options + a: toggle staged alle + D: bekijk reset opties + enter: stage individuele hunks/lijnen + f: fetch + g: view upstream reset options-## Hoofd (Stage Lines/Hunks) - -
- esc: ga terug naar het bestanden paneel - ▲: selecteer de vorige lijn - ▼: selecteer de volgende lijn - ◄: selecteer de vorige hunk - ►: selecteer de volgende hunk - space: stage lijn - a: stage hunk -- -## Hoofd (Merging) +## Hoofd Panel (Merging)
esc: ga terug naar het bestanden paneel @@ -120,9 +141,62 @@ z: ongedaan maken-## Hoofd (Normaal) +## Hoofd Panel (Normaal)
- PgDn: scroll omlaag (fn+up) - PgUp: scroll omhoog (fn+down) +  ̄: scroll omlaag (fn+up) + ¦: scroll omhoog (fn+down) ++ +## Hoofd Panel (Patch Building) + +
+ esc: exit line-by-line mode + ▲: selecteer de vorige lijn + ▼: selecteer de volgende lijn + ◄: selecteer de vorige hunk + ►: selecteer de volgende hunk + space: stage selection + d: reset selection + v: toggle drag select + V: toggle drag select + a: toggle select hunk ++ +## Hoofd Panel (Stage Lines/Hunks) + +
+ esc: ga terug naar het bestanden paneel + space: stage selection + d: reset selection + tab: switch to other panel + ▲: selecteer de vorige lijn + ▼: selecteer de volgende lijn + ◄: selecteer de vorige hunk + ►: selecteer de volgende hunk + e: verander bestand + o: open bestand + v: toggle drag select + V: toggle drag select + a: toggle select hunk + c: Commit veranderingen + w: commit veranderingen zonder pre-commit hook + C: commit veranderingen met de git editor ++ +## Stash Panel + +
+ space: toepassen + g: pop + d: drop ++ +## Status Panel + +
+ e: verander config file + o: open config file + u: check voor updates + enter: wissel naar een recente repodiff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index 039d15089..539a24d45 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -1,46 +1,21 @@ -# Lazygit menu +# Lazygit Keybindings ## Globalne
+ pgup: scroll up main panel (fn+up) + pgdown: scroll down main panel (fn+down) m: view merge/rebase options + ctrl+p: view custom patch options P: push p: pull R: odśwież + +: next screen mode (normal/half/fullscreen) + _: prev screen mode + :: execute custom command-## Status - -
- e: edytuj plik konfiguracyjny - o: otwórz plik konfiguracyjny - u: sprawdź aktualizacje - s: switch to a recent repo -- -## Pliki - -
- c: commituj zmiany - w: commit changes without pre-commit hook - A: zmień ostatnie zatwierdzenie - C: commituj zmiany używając edytora z gita - space: przełącz zatwierdzenie - d: view 'discard changes' options - e: edytuj plik - o: otwórz plik - i: dodaj do .gitignore - r: odśwież pliki - S: przechowaj pliki - a: przełącz wszystkie zatwierdzenia - t: dodaj łatkę - D: view reset options - enter: zatwierdź pojedyncze linie - f: fetch - X: execute custom command -- -## Gałęzie +## Gałęzie Panel (Branches Tab)
space: przełącz @@ -51,10 +26,54 @@ d: usuń gałąź r: rebase branch M: scal do obecnej gałęzi + i: show git-flow options f: fast-forward this branch from its upstream + g: view reset options-## Commity +## Gałęzie Panel (Remote Branches (in Remotes tab)) + +
+ esc: return to remotes list + g: view reset options + space: przełącz + M: scal do obecnej gałęzi + d: usuń gałąź + r: rebase branch + u: set as upstream of checked-out branch ++ +## Gałęzie Panel (Remotes Tab) + +
+ f: fetch remote + n: add new remote + d: remove remote + e: edit remote ++ +## Gałęzie Panel (Tags Tab) + +
+ space: przełącz + d: delete tag + P: push tag + n: create tag + g: view reset options ++ +## Commit files Panel + +
+ esc: go back + c: checkout file + d: discard this commit's changes to this file + o: otwórz plik + space: toggle file included in patch + enter: enter file to add selected lines to the patch ++ +## Commity Panel (Commits Tab)
s: ściśnij w dół @@ -75,46 +94,41 @@ C: copy commit range (cherry-pick) v: paste commits (cherry-pick) enter: view commit's files - space: select commit to diff with another commit + space: checkout commit + i: select commit to diff with another commit + T: tag commit-## Schowek +## Commity Panel (Reflog Tab)
- space: zastosuj - g: wyciągnij - d: porzuć + space: checkout commit + g: view reset options-## Commit files +## Pliki Panel
- esc: go back - c: checkout file - d: discard this commit's changes to this file + c: commituj zmiany + w: commit changes without pre-commit hook + A: zmień ostatnie zatwierdzenie + C: commituj zmiany używając edytora z gita + space: przełącz zatwierdzenie + d: view 'discard changes' options + e: edytuj plik o: otwórz plik + i: dodaj do .gitignore + r: odśwież pliki + s: przechowaj pliki + S: view stash options + a: przełącz wszystkie zatwierdzenia + D: view reset options + enter: zatwierdź pojedyncze linie + f: fetch + g: view upstream reset options-## Main (Normal) - -
- PgDn: scroll down (fn+up) - PgUp: scroll up (fn+down) -- -## Main (Zatwierdzanie) - -
- esc: wróć do panelu plików - ▲: select previous line - ▼: select next line - ◄: select previous hunk - ►: select next hunk - space: zatwierdź linię - a: zatwierdź kawałek -- -## Main (Merging) +## Main Panel (Merging)
esc: wróć do panelu plików @@ -126,3 +140,63 @@ ▼: select bottom hunk z: undo+ +## Main Panel (Normal) + +
+  ̄: scroll down (fn+up) + ¦: scroll up (fn+down) ++ +## Main Panel (Patch Building) + +
+ esc: exit line-by-line mode + ▲: select previous line + ▼: select next line + ◄: select previous hunk + ►: select next hunk + space: stage selection + d: reset selection + v: toggle drag select + V: toggle drag select + a: toggle select hunk ++ +## Main Panel (Zatwierdzanie) + +
+ esc: wróć do panelu plików + space: stage selection + d: reset selection + tab: switch to other panel + ▲: select previous line + ▼: select next line + ◄: select previous hunk + ►: select next hunk + e: edytuj plik + o: otwórz plik + v: toggle drag select + V: toggle drag select + a: toggle select hunk + c: commituj zmiany + w: commit changes without pre-commit hook + C: commituj zmiany używając edytora z gita ++ +## Schowek Panel + +
+ space: zastosuj + g: wyciągnij + d: porzuć ++ +## Status Panel + +
+ e: edytuj plik konfiguracyjny + o: otwórz plik konfiguracyjny + u: sprawdź aktualizacje + enter: switch to a recent repo +diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index d3a360874..62715d3b1 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -225,6 +225,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Modifier: gocui.ModNone, Handler: gui.scrollUpMain, Alternative: "fn+up", + Description: gui.Tr.SLocalize("scrollUpMainPanel"), }, { ViewName: "", @@ -232,6 +233,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Modifier: gocui.ModNone, Handler: gui.scrollDownMain, Alternative: "fn+down", + Description: gui.Tr.SLocalize("scrollDownMainPanel"), }, { ViewName: "", diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 2c6fed0af..55c08e920 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -564,6 +564,54 @@ func addEnglish(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "RebaseOptionsTitle", Other: "Rebase Options", + }, &i18n.Message{ + ID: "CommitMessageTitle", + Other: "Commit Message", + }, &i18n.Message{ + ID: "Local-BranchesTitle", + Other: "Branches Tab", + }, &i18n.Message{ + ID: "SearchTitle", + Other: "Search", + }, &i18n.Message{ + ID: "TagsTitle", + Other: "Tags Tab", + }, &i18n.Message{ + ID: "Branch-CommitsTitle", + Other: "Commits Tab", + }, &i18n.Message{ + ID: "MenuTitle", + Other: "Menu", + }, &i18n.Message{ + ID: "RemotesTitle", + Other: "Remotes Tab", + }, &i18n.Message{ + ID: "CredentialsTitle", + Other: "Credentials", + }, &i18n.Message{ + ID: "Remote-BranchesTitle", + Other: "Remote Branches (in Remotes tab)", + }, &i18n.Message{ + ID: "Patch-BuildingTitle", + Other: "Patch Building", + }, &i18n.Message{ + ID: "InformationTitle", + Other: "Information", + }, &i18n.Message{ + ID: "SecondaryTitle", + Other: "Secondary", + }, &i18n.Message{ + ID: "Reflog-CommitsTitle", + Other: "Reflog Tab", + }, &i18n.Message{ + ID: "Title", + Other: "Title", + }, &i18n.Message{ + ID: "GlobalTitle", + Other: "Global Keybindings", + }, &i18n.Message{ + ID: "MerginTitle", + Other: "Mergin", }, &i18n.Message{ ID: "ConflictsResolved", Other: "all merge conflicts resolved. Continue?", @@ -651,6 +699,12 @@ func addEnglish(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "ScrollUp", Other: "scroll up", + }, &i18n.Message{ + ID: "scrollUpMainPanel", + Other: "scroll up main panel", + }, &i18n.Message{ + ID: "scrollDownMainPanel", + Other: "scroll down main panel", }, &i18n.Message{ ID: "AmendCommitTitle", Other: "Amend Commit", @@ -692,7 +746,7 @@ func addEnglish(i18nObject *i18n.Bundle) error { Other: "view commit's files", }, &i18n.Message{ ID: "CommitFilesTitle", - Other: "Commit files", + Other: "Commit Files", }, &i18n.Message{ ID: "goBack", Other: "go back", @@ -951,6 +1005,12 @@ func addEnglish(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "prevScreenMode", Other: "prev screen mode", + }, &i18n.Message{ + ID: "Panel", + Other: "Panel", + }, &i18n.Message{ + ID: "Keybindings", + Other: "Keybindings", }, ) } diff --git a/scripts/generate_cheatsheet.go b/scripts/generate_cheatsheet.go index 56059d3bc..c5afdf5e9 100644 --- a/scripts/generate_cheatsheet.go +++ b/scripts/generate_cheatsheet.go @@ -12,6 +12,7 @@ import ( "fmt" "log" "os" + "sort" "strings" "github.com/jesseduffield/lazygit/pkg/app" @@ -60,33 +61,87 @@ func formatTitle(title string) string { func formatBinding(binding *gui.Binding) string { if binding.Alternative != "" { - return fmt.Sprintf(" %s: %s (%s)\n", binding.GetKey(), binding.Description, binding.Alternative) + return fmt.Sprintf(" %s: %s (%s)\n", gui.GetKeyDisplay(binding.Key), binding.Description, binding.Alternative) } - return fmt.Sprintf(" %s: %s\n", binding.GetKey(), binding.Description) + return fmt.Sprintf(" %s: %s\n", gui.GetKeyDisplay(binding.Key), binding.Description) } func getBindingSections(mApp *app.App) []*bindingSection { bindingSections := []*bindingSection{} - // TODO: add context-based keybindings - for _, binding := range mApp.Gui.GetInitialKeybindings() { - if binding.Description == "" { - continue + bindings := mApp.Gui.GetInitialKeybindings() + + type contextAndViewType struct { + context string + viewName string + } + + contextAndViewBindingMap := map[contextAndViewType][]*gui.Binding{} + + for _, binding := range bindings { + contexts := []string{} + if len(binding.Contexts) == 0 { + contexts = append(contexts, "") + } else { + for _, context := range binding.Contexts { + contexts = append(contexts, context) + } } - viewName := binding.ViewName + for _, context := range contexts { + key := contextAndViewType{context: context, viewName: binding.ViewName} + existing := contextAndViewBindingMap[key] + if existing == nil { + contextAndViewBindingMap[key] = []*gui.Binding{binding} + } else { + contextAndViewBindingMap[key] = append(contextAndViewBindingMap[key], binding) + } + } + } + + type groupedBindingsType struct { + contextAndView contextAndViewType + bindings []*gui.Binding + } + + groupedBindings := make([]groupedBindingsType, len(contextAndViewBindingMap)) + + for contextAndView, contextBindings := range contextAndViewBindingMap { + groupedBindings = append(groupedBindings, groupedBindingsType{contextAndView: contextAndView, bindings: contextBindings}) + } + + sort.Slice(groupedBindings, func(i, j int) bool { + first := groupedBindings[i].contextAndView + second := groupedBindings[j].contextAndView + if first.viewName == "" { + return true + } + if second.viewName == "" { + return false + } + return first.viewName < second.viewName || (first.viewName == second.viewName && first.context < second.context) + }) + + for _, group := range groupedBindings { + contextAndView := group.contextAndView + contextBindings := group.bindings + mApp.Log.Warn("viewname: " + contextAndView.viewName + ", context: " + contextAndView.context) + viewName := contextAndView.viewName if viewName == "" { viewName = "global" } - title := localisedTitle(mApp, viewName) - - bindingSections = addBinding(title, bindingSections, binding) - } - - for contextName, contextBindings := range mApp.Gui.GetContextMap() { - translatedView := localisedTitle(mApp, contextBindings[0].ViewName) - translatedContextName := localisedTitle(mApp, contextName) - title := fmt.Sprintf("%s (%s)", translatedView, translatedContextName) + translatedView := localisedTitle(mApp, viewName) + var title string + if contextAndView.context == "" { + addendum := " " + mApp.Tr.SLocalize("Panel") + if viewName == "global" { + addendum = "" + } + title = fmt.Sprintf("%s%s", translatedView, addendum) + } else { + translatedContextName := localisedTitle(mApp, contextAndView.context) + title = fmt.Sprintf("%s %s (%s)", translatedView, mApp.Tr.SLocalize("Panel"), translatedContextName) + } for _, binding := range contextBindings { bindingSections = addBinding(title, bindingSections, binding) @@ -117,7 +172,7 @@ func addBinding(title string, bindingSections []*bindingSection, binding *gui.Bi } func formatSections(mApp *app.App, bindingSections []*bindingSection) string { - content := fmt.Sprintf("# Lazygit %s\n", mApp.Tr.SLocalize("menu")) + content := fmt.Sprintf("# Lazygit %s\n", mApp.Tr.SLocalize("Keybindings")) for _, section := range bindingSections { content += formatTitle(section.title)