1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-05 15:15:49 +02:00

refactor menu context

This commit is contained in:
Jesse Duffield 2022-03-26 15:34:15 +11:00
parent 98e7ec0905
commit f0a4dcfdc3
7 changed files with 10 additions and 15 deletions

View File

@ -35,6 +35,10 @@ func (self *MenuController) GetKeybindings(opts types.KeybindingsOpts) []*types.
Key: opts.GetKey(opts.Config.Universal.ConfirmAlt1),
Handler: self.press,
},
{
Key: opts.GetKey(opts.Config.Universal.Return),
Handler: self.close,
},
}
return bindings
@ -58,6 +62,10 @@ func (self *MenuController) press() error {
return nil
}
func (self *MenuController) close() error {
return self.c.PopContext()
}
func (self *MenuController) Context() types.Context {
return self.context()
}

View File

@ -412,12 +412,6 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
Handler: self.handleCopySelectedSideContextItemToClipboard,
Description: self.c.Tr.LcCopyCommitShaToClipboard,
},
{
ViewName: "menu",
Key: opts.GetKey(opts.Config.Universal.Return),
Handler: self.handleMenuClose,
Description: self.c.Tr.LcCloseMenu,
},
{
ViewName: "information",
Key: gocui.MouseLeft,

View File

@ -18,10 +18,6 @@ func (gui *Gui) getMenuOptions() map[string]string {
}
}
func (gui *Gui) handleMenuClose() error {
return gui.c.PopContext()
}
// note: items option is mutated by this function
func (gui *Gui) createMenu(opts types.CreateMenuOptions) error {
if !opts.HideCancel {

View File

@ -70,7 +70,8 @@ func (gui *Gui) handleCreateOptionsMenu() error {
if binding.Key == nil {
return nil
}
if err := gui.handleMenuClose(); err != nil {
if err := gui.c.PopContext(); err != nil {
return err
}
return binding.Handler()

View File

@ -347,7 +347,6 @@ func chineseTranslationSet() TranslationSet {
NewBranchNamePrompt: "输入分支的新名称",
RenameBranchWarning: "该分支正在跟踪远程仓库。此操作将仅会重命名本地分支名称,而不会重命名远程分支的名称。确定继续?",
LcOpenMenu: "打开菜单",
LcCloseMenu: "关闭菜单",
LcResetCherryPick: "重置已拣选(复制)的提交",
LcNextTab: "下一个标签",
LcPrevTab: "上一个标签",

View File

@ -302,7 +302,6 @@ func dutchTranslationSet() TranslationSet {
NewBranchNamePrompt: "Noem een nieuwe branch naam",
RenameBranchWarning: "Deze branch volgt een remote. Deze actie zal alleen de locale branch name wijzigen niet de naam van de remote branch. Verder gaan?",
LcOpenMenu: "open menu",
LcCloseMenu: "sluit menu",
LcResetCherryPick: "reset cherry-picked (gekopieerde) commits selectie",
LcNextTab: "volgende tabblad",
LcPrevTab: "vorige tabblad",

View File

@ -332,7 +332,6 @@ type TranslationSet struct {
NewGitFlowBranchPrompt string
RenameBranchWarning string
LcOpenMenu string
LcCloseMenu string
LcResetCherryPick string
LcNextTab string
LcPrevTab string
@ -923,7 +922,6 @@ func EnglishTranslationSet() TranslationSet {
NewBranchNamePrompt: "Enter new branch name for branch",
RenameBranchWarning: "This branch is tracking a remote. This action will only rename the local branch name, not the name of the remote branch. Continue?",
LcOpenMenu: "open menu",
LcCloseMenu: "close menu",
LcResetCherryPick: "reset cherry-picked (copied) commits selection",
LcNextTab: "next tab",
LcPrevTab: "previous tab",