@@ -139,21 +139,23 @@ type Gui struct {
139139 ReplayedEvents replayedEvents
140140 playRecording bool
141141
142- tabClickBindings []* tabClickBinding
143- viewMouseBindings []* ViewMouseBinding
144- lastClick * clickInfo
145- gEvents chan GocuiEvent
146- userEvents chan userEvent
147- views []* View
148- currentView * View
149- managers []Manager
150- keybindings []* keybinding
151- focusHandler func (bool ) error
152- openHyperlink func (string , string ) error
153- maxX , maxY int
154- outputMode OutputMode
155- stop chan struct {}
156- blacklist []Key
142+ tabClickBindings []* tabClickBinding
143+ viewMouseBindings []* ViewMouseBinding
144+ lastClick * clickInfo
145+ gEvents chan GocuiEvent
146+ userEvents chan userEvent
147+ views []* View
148+ currentView * View
149+ managers []Manager
150+ keybindings []* keybinding
151+ focusHandler func (bool ) error
152+ openHyperlink func (string , string ) error
153+ onSelectSearchResultFunc func (* View , int )
154+ renderSearchStatusFunc func (* View , int , int )
155+ maxX , maxY int
156+ outputMode OutputMode
157+ stop chan struct {}
158+ blacklist []Key
157159
158160 // BgColor and FgColor allow to configure the background and foreground
159161 // colors of the GUI.
@@ -355,11 +357,26 @@ func (g *Gui) SetView(name string, x0, y0, x1, y1 int, overlaps byte) (*View, er
355357 v .Overlaps = overlaps
356358 g .views = append (g .views , v )
357359
360+ v .setOnSelectResult (g .onSelectSearchItem )
361+ v .setRenderSearchStatus (g .renderSearchStatus )
362+
358363 g .Mutexes .ViewsMutex .Unlock ()
359364
360365 return v , errors .Wrap (ErrUnknownView , 0 )
361366}
362367
368+ func (g * Gui ) onSelectSearchItem (v * View , selectedLineIdx int ) {
369+ if g .onSelectSearchResultFunc != nil {
370+ g .onSelectSearchResultFunc (v , selectedLineIdx )
371+ }
372+ }
373+
374+ func (g * Gui ) renderSearchStatus (v * View , selected int , total int ) {
375+ if g .renderSearchStatusFunc != nil {
376+ g .renderSearchStatusFunc (v , selected , total )
377+ }
378+ }
379+
363380// SetViewBeneath sets a view stacked beneath another view
364381func (g * Gui ) SetViewBeneath (name string , aboveViewName string , height int ) (* View , error ) {
365382 aboveView , err := g .View (aboveViewName )
@@ -643,6 +660,14 @@ func (g *Gui) SetOpenHyperlinkFunc(openHyperlinkFunc func(string, string) error)
643660 g .openHyperlink = openHyperlinkFunc
644661}
645662
663+ func (g * Gui ) SetOnSelectSearchResultFunc (onSelectSearchResultFunc func (* View , int )) {
664+ g .onSelectSearchResultFunc = onSelectSearchResultFunc
665+ }
666+
667+ func (g * Gui ) SetRenderSearchStatusFunc (renderSearchStatusFunc func (* View , int , int )) {
668+ g .renderSearchStatusFunc = renderSearchStatusFunc
669+ }
670+
646671// getKey takes an empty interface with a key and returns the corresponding
647672// typed Key or rune.
648673func getKey (key any ) (Key , rune , error ) {
0 commit comments