update keybindings

This commit is contained in:
Jesse Duffield
2020-10-02 07:32:48 +10:00
parent 30b3478611
commit 7be474bd83
8 changed files with 229 additions and 252 deletions

View File

@@ -21,6 +21,7 @@ type Binding struct {
Modifier gocui.Modifier
Description string
Alternative string
Tag string // e.g. 'navigation'. Used for grouping things in the cheatsheet
}
// GetDisplayStrings returns the display string of a file
@@ -633,18 +634,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.wrappedHandler(gui.handleSwitchToSubCommits),
Description: gui.Tr.SLocalize("viewCommits"),
},
{
ViewName: "branches",
Key: gui.getKey("universal.nextTab"),
Handler: gui.handleNextTab,
Description: gui.Tr.SLocalize("nextTab"),
},
{
ViewName: "branches",
Key: gui.getKey("universal.prevTab"),
Handler: gui.handlePrevTab,
Description: gui.Tr.SLocalize("prevTab"),
},
{
ViewName: "branches",
Contexts: []string{REMOTE_BRANCHES_CONTEXT_KEY},
@@ -673,18 +662,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.handleFetchRemote,
Description: gui.Tr.SLocalize("fetchRemote"),
},
{
ViewName: "commits",
Key: gui.getKey("universal.nextTab"),
Handler: gui.handleNextTab,
Description: gui.Tr.SLocalize("nextTab"),
},
{
ViewName: "commits",
Key: gui.getKey("universal.prevTab"),
Handler: gui.handlePrevTab,
Description: gui.Tr.SLocalize("prevTab"),
},
{
ViewName: "commits",
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
@@ -1560,18 +1537,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Modifier: gocui.ModNone,
Handler: gui.wrappedHandler(gui.onMenuPress),
},
{
ViewName: "files",
Key: gui.getKey("universal.nextTab"),
Handler: gui.handleNextTab,
Description: gui.Tr.SLocalize("nextTab"),
},
{
ViewName: "files",
Key: gui.getKey("universal.prevTab"),
Handler: gui.handlePrevTab,
Description: gui.Tr.SLocalize("prevTab"),
},
{
ViewName: "files",
Contexts: []string{SUBMODULES_CONTEXT_KEY},
@@ -1644,6 +1609,25 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
bindings = append(bindings, &Binding{ViewName: "", Key: rune(i+1) + '0', Modifier: gocui.ModNone, Handler: gui.goToSideWindow(window)})
}
for viewName := range gui.viewTabContextMap() {
bindings = append(bindings, []*Binding{
{
ViewName: viewName,
Key: gui.getKey("universal.nextTab"),
Handler: gui.handleNextTab,
Description: gui.Tr.SLocalize("nextTab"),
Tag: "navigation",
},
{
ViewName: viewName,
Key: gui.getKey("universal.prevTab"),
Handler: gui.handlePrevTab,
Description: gui.Tr.SLocalize("prevTab"),
Tag: "navigation",
},
}...)
}
bindings = append(bindings, gui.getListContextKeyBindings()...)
return bindings

View File

@@ -510,15 +510,15 @@ func (gui *Gui) getListContextKeyBindings() []*Binding {
for _, listContext := range gui.getListContexts() {
bindings = append(bindings, []*Binding{
{ViewName: listContext.ViewName, Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.prevItem-alt"), Modifier: gocui.ModNone, Handler: listContext.handlePrevLine},
{ViewName: listContext.ViewName, Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.prevItem"), Modifier: gocui.ModNone, Handler: listContext.handlePrevLine},
{ViewName: listContext.ViewName, Contexts: []string{listContext.ContextKey}, Key: gocui.MouseWheelUp, Modifier: gocui.ModNone, Handler: listContext.handlePrevLine},
{ViewName: listContext.ViewName, Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.nextItem-alt"), Modifier: gocui.ModNone, Handler: listContext.handleNextLine},
{ViewName: listContext.ViewName, Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.nextItem"), Modifier: gocui.ModNone, Handler: listContext.handleNextLine},
{ViewName: listContext.ViewName, Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.prevPage"), Modifier: gocui.ModNone, Handler: listContext.handlePrevPage, Description: gui.Tr.SLocalize("prevPage")},
{ViewName: listContext.ViewName, Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.nextPage"), Modifier: gocui.ModNone, Handler: listContext.handleNextPage, Description: gui.Tr.SLocalize("nextPage")},
{ViewName: listContext.ViewName, Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.gotoTop"), Modifier: gocui.ModNone, Handler: listContext.handleGotoTop, Description: gui.Tr.SLocalize("gotoTop")},
{ViewName: listContext.ViewName, Contexts: []string{listContext.ContextKey}, Key: gocui.MouseWheelDown, Modifier: gocui.ModNone, Handler: listContext.handleNextLine},
{ViewName: listContext.ViewName, Tag: "navigation", Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.prevItem-alt"), Modifier: gocui.ModNone, Handler: listContext.handlePrevLine},
{ViewName: listContext.ViewName, Tag: "navigation", Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.prevItem"), Modifier: gocui.ModNone, Handler: listContext.handlePrevLine},
{ViewName: listContext.ViewName, Tag: "navigation", Contexts: []string{listContext.ContextKey}, Key: gocui.MouseWheelUp, Modifier: gocui.ModNone, Handler: listContext.handlePrevLine},
{ViewName: listContext.ViewName, Tag: "navigation", Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.nextItem-alt"), Modifier: gocui.ModNone, Handler: listContext.handleNextLine},
{ViewName: listContext.ViewName, Tag: "navigation", Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.nextItem"), Modifier: gocui.ModNone, Handler: listContext.handleNextLine},
{ViewName: listContext.ViewName, Tag: "navigation", Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.prevPage"), Modifier: gocui.ModNone, Handler: listContext.handlePrevPage, Description: gui.Tr.SLocalize("prevPage")},
{ViewName: listContext.ViewName, Tag: "navigation", Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.nextPage"), Modifier: gocui.ModNone, Handler: listContext.handleNextPage, Description: gui.Tr.SLocalize("nextPage")},
{ViewName: listContext.ViewName, Tag: "navigation", Contexts: []string{listContext.ContextKey}, Key: gui.getKey("universal.gotoTop"), Modifier: gocui.ModNone, Handler: listContext.handleGotoTop, Description: gui.Tr.SLocalize("gotoTop")},
{ViewName: listContext.ViewName, Tag: "navigation", Contexts: []string{listContext.ContextKey}, Key: gocui.MouseWheelDown, Modifier: gocui.ModNone, Handler: listContext.handleNextLine},
{ViewName: listContext.ViewName, Contexts: []string{listContext.ContextKey}, Key: gocui.MouseLeft, Modifier: gocui.ModNone, Handler: listContext.handleClick},
}...)
@@ -537,6 +537,7 @@ func (gui *Gui) getListContextKeyBindings() []*Binding {
Key: gui.getKey("universal.startSearch"),
Handler: openSearchHandler,
Description: gui.Tr.SLocalize("startSearch"),
Tag: "navigation",
},
{
ViewName: listContext.ViewName,
@@ -544,6 +545,7 @@ func (gui *Gui) getListContextKeyBindings() []*Binding {
Key: gui.getKey("universal.gotoBottom"),
Handler: gotoBottomHandler,
Description: gui.Tr.SLocalize("gotoBottom"),
Tag: "navigation",
},
}...)
}

View File

@@ -572,7 +572,7 @@ func addDutch(i18nObject *i18n.Bundle) error {
ID: "CommitMessageTitle",
Other: "Commit Bericht",
}, &i18n.Message{
ID: "Local-BranchesTitle",
ID: "LocalBranchesTitle",
Other: "Branches Tab",
}, &i18n.Message{
ID: "SearchTitle",
@@ -581,7 +581,7 @@ func addDutch(i18nObject *i18n.Bundle) error {
ID: "TagsTitle",
Other: "Tags Tab",
}, &i18n.Message{
ID: "Branch-CommitsTitle",
ID: "BranchCommitsTitle",
Other: "Commits Tab",
}, &i18n.Message{
ID: "MenuTitle",
@@ -593,10 +593,10 @@ func addDutch(i18nObject *i18n.Bundle) error {
ID: "CredentialsTitle",
Other: "Credentials",
}, &i18n.Message{
ID: "Remote-BranchesTitle",
ID: "RemoteBranchesTitle",
Other: "Remote Branches (in Remotes tab)",
}, &i18n.Message{
ID: "Patch-BuildingTitle",
ID: "PatchBuildingTitle",
Other: "Patch Bouwen",
}, &i18n.Message{
ID: "InformationTitle",
@@ -605,7 +605,7 @@ func addDutch(i18nObject *i18n.Bundle) error {
ID: "SecondaryTitle",
Other: "Secondary",
}, &i18n.Message{
ID: "Reflog-CommitsTitle",
ID: "ReflogCommitsTitle",
Other: "Reflog Tab",
}, &i18n.Message{
ID: "Title",

View File

@@ -580,7 +580,7 @@ func addEnglish(i18nObject *i18n.Bundle) error {
ID: "CommitMessageTitle",
Other: "Commit Message",
}, &i18n.Message{
ID: "Local-BranchesTitle",
ID: "LocalBranchesTitle",
Other: "Branches Tab",
}, &i18n.Message{
ID: "SearchTitle",
@@ -589,7 +589,7 @@ func addEnglish(i18nObject *i18n.Bundle) error {
ID: "TagsTitle",
Other: "Tags Tab",
}, &i18n.Message{
ID: "Branch-CommitsTitle",
ID: "BranchCommitsTitle",
Other: "Commits Tab",
}, &i18n.Message{
ID: "MenuTitle",
@@ -601,10 +601,10 @@ func addEnglish(i18nObject *i18n.Bundle) error {
ID: "CredentialsTitle",
Other: "Credentials",
}, &i18n.Message{
ID: "Remote-BranchesTitle",
ID: "RemoteBranchesTitle",
Other: "Remote Branches (in Remotes tab)",
}, &i18n.Message{
ID: "Patch-BuildingTitle",
ID: "PatchBuildingTitle",
Other: "Patch Building",
}, &i18n.Message{
ID: "InformationTitle",
@@ -613,7 +613,7 @@ func addEnglish(i18nObject *i18n.Bundle) error {
ID: "SecondaryTitle",
Other: "Secondary",
}, &i18n.Message{
ID: "Reflog-CommitsTitle",
ID: "ReflogCommitsTitle",
Other: "Reflog Tab",
}, &i18n.Message{
ID: "Title",
@@ -1272,6 +1272,15 @@ func addEnglish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "runningCommand",
Other: "running command",
}, &i18n.Message{
ID: "SubCommitsTitle",
Other: "Sub-commits",
}, &i18n.Message{
ID: "SubmodulesTitle",
Other: "Submodules",
}, &i18n.Message{
ID: "NavigationTitle",
Other: "List Panel Navigation",
},
)
}