@@ -117,6 +117,7 @@ def toggle_code_context_event(self, event=None):
117117 height = 1 ,
118118 width = 1 , # Don't request more than we get.
119119 padx = padx , border = border , relief = SUNKEN , state = 'disabled' )
120+ self .context .bind ('<ButtonRelease-1>' , self .jumptoline )
120121 # Pack the context widget before and above the text_frame widget,
121122 # thus ensuring that it will appear directly above text_frame.
122123 self .context .pack (side = TOP , fill = X , expand = False ,
@@ -196,6 +197,20 @@ def update_code_context(self):
196197 self .context .insert ('end' , '\n ' .join (context_strings [showfirst :]))
197198 self .context ['state' ] = 'disabled'
198199
200+ def jumptoline (self , event = None ):
201+ "Show clicked context line at top of editor."
202+ lines = len (self .info )
203+ if lines == 1 : # No context lines are showing.
204+ newtop = 1
205+ else :
206+ # Line number clicked.
207+ contextline = int (float (self .context .index ('insert' )))
208+ # Lines not displayed due to maxlines.
209+ offset = max (1 , lines - self .context_depth ) - 1
210+ newtop = self .info [offset + contextline ][0 ]
211+ self .text .yview (f'{ newtop } .0' )
212+ self .update_code_context ()
213+
199214 def timer_event (self ):
200215 "Event on editor text widget triggered every UPDATEINTERVAL ms."
201216 if self .context :
0 commit comments