Press enter in focused main view when user config is on

This commit is contained in:
Stefan Haller 2025-04-01 23:03:55 +02:00
parent e76f1d6c1f
commit d8d8634e5e
2 changed files with 23 additions and 0 deletions

View file

@ -30,6 +30,13 @@ func NewMainViewController(
} }
func (self *MainViewController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding { func (self *MainViewController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding {
var goIntoDescription string
// We only want to show the "enter" menu item if the user config is true;
// leaving the description empty causes it to be hidden
if self.c.UserConfig().Gui.ShowSelectionInFocusedMainView {
goIntoDescription = self.c.Tr.EnterStaging
}
return []*types.Binding{ return []*types.Binding{
{ {
Key: opts.GetKey(opts.Config.Universal.TogglePanel), Key: opts.GetKey(opts.Config.Universal.TogglePanel),
@ -43,6 +50,11 @@ func (self *MainViewController) GetKeybindings(opts types.KeybindingsOpts) []*ty
Handler: self.escape, Handler: self.escape,
Description: self.c.Tr.ExitFocusedMainView, Description: self.c.Tr.ExitFocusedMainView,
}, },
{
Key: opts.GetKey(opts.Config.Universal.GoInto),
Handler: self.enter,
Description: goIntoDescription,
},
{ {
// overriding this because we want to read all of the task's output before we start searching // overriding this because we want to read all of the task's output before we start searching
Key: opts.GetKey(opts.Config.Universal.StartSearch), Key: opts.GetKey(opts.Config.Universal.StartSearch),
@ -93,6 +105,15 @@ func (self *MainViewController) escape() error {
return nil return nil
} }
func (self *MainViewController) enter() error {
parentCtx := self.context.GetParentContext()
if parentCtx.GetOnClickFocusedMainView() != nil {
return parentCtx.GetOnClickFocusedMainView()(
self.context.GetViewName(), self.context.GetView().SelectedLineIdx())
}
return nil
}
func (self *MainViewController) onClick(opts gocui.ViewMouseBindingOpts) error { func (self *MainViewController) onClick(opts gocui.ViewMouseBindingOpts) error {
if self.context.GetView().Highlight && opts.Y != opts.PreviousY { if self.context.GetView().Highlight && opts.Y != opts.PreviousY {
return nil return nil

View file

@ -519,6 +519,7 @@ type TranslationSet struct {
EmptyPatchError string EmptyPatchError string
EnterCommitFile string EnterCommitFile string
EnterCommitFileTooltip string EnterCommitFileTooltip string
EnterStaging string
ExitCustomPatchBuilder string ExitCustomPatchBuilder string
ExitFocusedMainView string ExitFocusedMainView string
EnterUpstream string EnterUpstream string
@ -1607,6 +1608,7 @@ func EnglishTranslationSet() *TranslationSet {
EmptyPatchError: "Patch is still empty. Add some files or lines to your patch first.", EmptyPatchError: "Patch is still empty. Add some files or lines to your patch first.",
EnterCommitFile: "Enter file / Toggle directory collapsed", EnterCommitFile: "Enter file / Toggle directory collapsed",
EnterCommitFileTooltip: "If a file is selected, enter the file so that you can add/remove individual lines to the custom patch. If a directory is selected, toggle the directory.", EnterCommitFileTooltip: "If a file is selected, enter the file so that you can add/remove individual lines to the custom patch. If a directory is selected, toggle the directory.",
EnterStaging: "Enter staging/patch building",
ExitCustomPatchBuilder: `Exit custom patch builder`, ExitCustomPatchBuilder: `Exit custom patch builder`,
ExitFocusedMainView: "Exit back to side panel", ExitFocusedMainView: "Exit back to side panel",
EnterUpstream: `Enter upstream as '<remote> <branchname>'`, EnterUpstream: `Enter upstream as '<remote> <branchname>'`,