From a62f213063f1f8d33b2c6da799be847616784247 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 15 Aug 2026 18:19:57 +0200 Subject: [PATCH] Remove the plumbing for clicking the focused main view With both implementations gone, nothing is left that lets a side panel handle a click in the focused main view, so the mechanism for attaching one to a context can go as well. Co-authored-by: Claude Opus 5 (1M context) --- pkg/gui/context/base_context.go | 36 +++++++------------------- pkg/gui/controllers/attach.go | 1 - pkg/gui/controllers/base_controller.go | 4 --- pkg/gui/types/context.go | 7 ----- 4 files changed, 10 insertions(+), 38 deletions(-) diff --git a/pkg/gui/context/base_context.go b/pkg/gui/context/base_context.go index b5fbf76ce..b36600674 100644 --- a/pkg/gui/context/base_context.go +++ b/pkg/gui/context/base_context.go @@ -13,15 +13,14 @@ type BaseContext struct { windowName string onGetOptionsMap func() map[string]string - keybindingsFns []types.KeybindingsFn - mouseKeybindingsFns []types.MouseKeybindingsFn - onDoubleClickFn func() error - onClickFn func(opts gocui.ViewMouseBindingOpts) error - onClickFocusedMainViewFn onClickFocusedMainViewFn - onRenderToMainFn func() - onFocusFns []onFocusFn - onFocusLostFns []onFocusLostFn - onQuitFns []func() + keybindingsFns []types.KeybindingsFn + mouseKeybindingsFns []types.MouseKeybindingsFn + onDoubleClickFn func() error + onClickFn func(opts gocui.ViewMouseBindingOpts) error + onRenderToMainFn func() + onFocusFns []onFocusFn + onFocusLostFns []onFocusLostFn + onQuitFns []func() focusable bool transient bool @@ -34,9 +33,8 @@ type BaseContext struct { } type ( - onFocusFn = func(types.OnFocusOpts) - onFocusLostFn = func(types.OnFocusLostOpts) - onClickFocusedMainViewFn = func(mainViewName string, clickedLineIdx int) error + onFocusFn = func(types.OnFocusOpts) + onFocusLostFn = func(types.OnFocusLostOpts) ) var _ types.IBaseContext = &BaseContext{} @@ -153,7 +151,6 @@ func (self *BaseContext) ClearAllAttachedControllerFunctions() { self.onQuitFns = nil self.onDoubleClickFn = nil self.onClickFn = nil - self.onClickFocusedMainViewFn = nil self.onRenderToMainFn = nil } @@ -175,15 +172,6 @@ func (self *BaseContext) AddOnClickFn(fn func(opts gocui.ViewMouseBindingOpts) e } } -func (self *BaseContext) AddOnClickFocusedMainViewFn(fn onClickFocusedMainViewFn) { - if fn != nil { - if self.onClickFocusedMainViewFn != nil { - panic("only one controller is allowed to set an onClickFocusedMainViewFn") - } - self.onClickFocusedMainViewFn = fn - } -} - func (self *BaseContext) GetOnDoubleClick() func() error { return self.onDoubleClickFn } @@ -192,10 +180,6 @@ func (self *BaseContext) GetOnClick() func(opts gocui.ViewMouseBindingOpts) erro return self.onClickFn } -func (self *BaseContext) GetOnClickFocusedMainView() onClickFocusedMainViewFn { - return self.onClickFocusedMainViewFn -} - func (self *BaseContext) AddOnRenderToMainFn(fn func()) { if fn != nil { if self.onRenderToMainFn != nil { diff --git a/pkg/gui/controllers/attach.go b/pkg/gui/controllers/attach.go index c9ef5d4b0..ae5ac5c09 100644 --- a/pkg/gui/controllers/attach.go +++ b/pkg/gui/controllers/attach.go @@ -8,7 +8,6 @@ func AttachControllers(context types.Context, controllers ...types.IController) context.AddMouseKeybindingsFn(controller.GetMouseKeybindings) context.AddOnDoubleClickFn(controller.GetOnDoubleClick()) context.AddOnClickFn(controller.GetOnClick()) - context.AddOnClickFocusedMainViewFn(controller.GetOnClickFocusedMainView()) context.AddOnRenderToMainFn(controller.GetOnRenderToMain()) context.AddOnFocusFn(controller.GetOnFocus()) context.AddOnFocusLostFn(controller.GetOnFocusLost()) diff --git a/pkg/gui/controllers/base_controller.go b/pkg/gui/controllers/base_controller.go index f91f0b4cc..f0684461f 100644 --- a/pkg/gui/controllers/base_controller.go +++ b/pkg/gui/controllers/base_controller.go @@ -19,10 +19,6 @@ func (self *baseController) GetOnDoubleClick() func() error { return nil } -func (self *baseController) GetOnClickFocusedMainView() func(mainViewName string, clickedLineIdx int) error { - return nil -} - func (self *baseController) GetOnClick() func(opts gocui.ViewMouseBindingOpts) error { return nil } diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go index 3f75f41ea..788184f47 100644 --- a/pkg/gui/types/context.go +++ b/pkg/gui/types/context.go @@ -102,9 +102,6 @@ type IBaseContext interface { // that the generic ListController can be specialized by view-specific controllers. // We'll need to think of a better way to do this. AddOnDoubleClickFn(func() error) - // Likewise for the focused main view: we need this to communicate between a - // side panel controller and the focused main view controller. - AddOnClickFocusedMainViewFn(func(mainViewName string, clickedLineIdx int) error) // Adding on to the above, this is so that a list-specific handler can register // a hook for doing additional click handling AddOnClickFn(func(opts gocui.ViewMouseBindingOpts) error) @@ -308,10 +305,6 @@ type HasKeybindings interface { // HandleFocus has already been called (so the main view is up to date). Should return nil if it // decides not to do anything with the click. GetOnClick() func(opts gocui.ViewMouseBindingOpts) error - - // Implement this in a side-panel controller to get called when there's a click in the main view - // that belongs to your panel while the main view is already focused. - GetOnClickFocusedMainView() func(mainViewName string, clickedLineIdx int) error } type IController interface {