mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-04 23:37:41 +02:00
Add sections (local, global) to the keybindings menu
This commit is contained in:
parent
6d4df57393
commit
37381b610d
@ -18,9 +18,13 @@ func (self *OptionsMenuAction) Call() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
bindings := self.getBindings(ctx)
|
local, global, navigation := self.getBindings(ctx)
|
||||||
|
|
||||||
menuItems := lo.Map(bindings, func(binding *types.Binding, _ int) *types.MenuItem {
|
menuItems := []*types.MenuItem{}
|
||||||
|
|
||||||
|
appendBindings := func(bindings []*types.Binding, section *types.MenuSection) {
|
||||||
|
menuItems = append(menuItems,
|
||||||
|
lo.Map(bindings, func(binding *types.Binding, _ int) *types.MenuItem {
|
||||||
return &types.MenuItem{
|
return &types.MenuItem{
|
||||||
OpensMenu: binding.OpensMenu,
|
OpensMenu: binding.OpensMenu,
|
||||||
Label: binding.Description,
|
Label: binding.Description,
|
||||||
@ -33,8 +37,14 @@ func (self *OptionsMenuAction) Call() error {
|
|||||||
},
|
},
|
||||||
Key: binding.Key,
|
Key: binding.Key,
|
||||||
Tooltip: binding.Tooltip,
|
Tooltip: binding.Tooltip,
|
||||||
|
Section: section,
|
||||||
}
|
}
|
||||||
})
|
})...)
|
||||||
|
}
|
||||||
|
|
||||||
|
appendBindings(local, &types.MenuSection{Title: self.c.Tr.KeybindingsMenuSectionLocal, Column: 1})
|
||||||
|
appendBindings(global, &types.MenuSection{Title: self.c.Tr.KeybindingsMenuSectionGlobal, Column: 1})
|
||||||
|
appendBindings(navigation, &types.MenuSection{Title: self.c.Tr.KeybindingsMenuSectionNavigation, Column: 1})
|
||||||
|
|
||||||
return self.c.Menu(types.CreateMenuOptions{
|
return self.c.Menu(types.CreateMenuOptions{
|
||||||
Title: self.c.Tr.Keybindings,
|
Title: self.c.Tr.Keybindings,
|
||||||
@ -44,7 +54,8 @@ func (self *OptionsMenuAction) Call() error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *OptionsMenuAction) getBindings(context types.Context) []*types.Binding {
|
// Returns three slices of bindings: local, global, and navigation
|
||||||
|
func (self *OptionsMenuAction) getBindings(context types.Context) ([]*types.Binding, []*types.Binding, []*types.Binding) {
|
||||||
var bindingsGlobal, bindingsPanel, bindingsNavigation []*types.Binding
|
var bindingsGlobal, bindingsPanel, bindingsNavigation []*types.Binding
|
||||||
|
|
||||||
bindings, _ := self.c.GetInitialKeybindingsWithCustomCommands()
|
bindings, _ := self.c.GetInitialKeybindingsWithCustomCommands()
|
||||||
@ -61,14 +72,7 @@ func (self *OptionsMenuAction) getBindings(context types.Context) []*types.Bindi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resultBindings := []*types.Binding{}
|
return uniqueBindings(bindingsPanel), uniqueBindings(bindingsGlobal), uniqueBindings(bindingsNavigation)
|
||||||
resultBindings = append(resultBindings, uniqueBindings(bindingsPanel)...)
|
|
||||||
// adding a separator between the panel-specific bindings and the other bindings
|
|
||||||
resultBindings = append(resultBindings, &types.Binding{})
|
|
||||||
resultBindings = append(resultBindings, uniqueBindings(bindingsGlobal)...)
|
|
||||||
resultBindings = append(resultBindings, uniqueBindings(bindingsNavigation)...)
|
|
||||||
|
|
||||||
return resultBindings
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We shouldn't really need to do this. We should define alternative keys for the same
|
// We shouldn't really need to do this. We should define alternative keys for the same
|
||||||
|
@ -388,6 +388,9 @@ type TranslationSet struct {
|
|||||||
Panel string
|
Panel string
|
||||||
Keybindings string
|
Keybindings string
|
||||||
KeybindingsLegend string
|
KeybindingsLegend string
|
||||||
|
KeybindingsMenuSectionLocal string
|
||||||
|
KeybindingsMenuSectionGlobal string
|
||||||
|
KeybindingsMenuSectionNavigation string
|
||||||
RenameBranch string
|
RenameBranch string
|
||||||
SetUnsetUpstream string
|
SetUnsetUpstream string
|
||||||
NewGitFlowBranchPrompt string
|
NewGitFlowBranchPrompt string
|
||||||
@ -986,6 +989,9 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
ConflictsResolved: "All merge conflicts resolved. Continue?",
|
ConflictsResolved: "All merge conflicts resolved. Continue?",
|
||||||
Continue: "Continue",
|
Continue: "Continue",
|
||||||
Keybindings: "Keybindings",
|
Keybindings: "Keybindings",
|
||||||
|
KeybindingsMenuSectionLocal: "Local",
|
||||||
|
KeybindingsMenuSectionGlobal: "Global",
|
||||||
|
KeybindingsMenuSectionNavigation: "Navigation",
|
||||||
RebasingTitle: "Rebase '{{.checkedOutBranch}}' onto '{{.ref}}'",
|
RebasingTitle: "Rebase '{{.checkedOutBranch}}' onto '{{.ref}}'",
|
||||||
RebasingFromBaseCommitTitle: "Rebase '{{.checkedOutBranch}}' from marked base onto '{{.ref}}'",
|
RebasingFromBaseCommitTitle: "Rebase '{{.checkedOutBranch}}' from marked base onto '{{.ref}}'",
|
||||||
SimpleRebase: "Simple rebase",
|
SimpleRebase: "Simple rebase",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user