Skip to content

Commit b3ca944

Browse files
committed
Remove GetOnRenderToMain, GetOnFocus, and GetOnFocusLost from BaseContext
These are never called on the context, they only exist to satisfy the HasKeybindings interface. But that's wrong, HasKeybindings has nothing to do with focus handling or rendering the main view. Remove them from that interface and add them to IController instead.
1 parent 0245d66 commit b3ca944

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

pkg/gui/context/base_context.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,30 +166,18 @@ func (self *BaseContext) AddOnRenderToMainFn(fn func()) {
166166
}
167167
}
168168

169-
func (self *BaseContext) GetOnRenderToMain() func() {
170-
return self.onRenderToMainFn
171-
}
172-
173169
func (self *BaseContext) AddOnFocusFn(fn onFocusFn) {
174170
if fn != nil {
175171
self.onFocusFn = fn
176172
}
177173
}
178174

179-
func (self *BaseContext) GetOnFocus() onFocusFn {
180-
return self.onFocusFn
181-
}
182-
183175
func (self *BaseContext) AddOnFocusLostFn(fn onFocusLostFn) {
184176
if fn != nil {
185177
self.onFocusLostFn = fn
186178
}
187179
}
188180

189-
func (self *BaseContext) GetOnFocusLost() onFocusLostFn {
190-
return self.onFocusLostFn
191-
}
192-
193181
func (self *BaseContext) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding {
194182
bindings := []*gocui.ViewMouseBinding{}
195183
for i := range self.mouseKeybindingsFns {

pkg/gui/types/context.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,15 @@ type HasKeybindings interface {
245245
GetMouseKeybindings(opts KeybindingsOpts) []*gocui.ViewMouseBinding
246246
GetOnClick() func() error
247247
GetOnClickFocusedMainView() func(mainViewName string, clickedLineIdx int) error
248-
GetOnRenderToMain() func()
249-
GetOnFocus() func(OnFocusOpts)
250-
GetOnFocusLost() func(OnFocusLostOpts)
251248
}
252249

253250
type IController interface {
254251
HasKeybindings
255252
Context() Context
253+
254+
GetOnRenderToMain() func()
255+
GetOnFocus() func(OnFocusOpts)
256+
GetOnFocusLost() func(OnFocusLostOpts)
256257
}
257258

258259
type IList interface {

0 commit comments

Comments
 (0)