(self)
Update context information and lines visible in the context pane.

        No update is done if the text hasn't been scrolled.  If the text
        was scrolled, the lines that should be shown in the context will
        be retrieved and the context area will be updated with the code,
        up to the number of maxlines.
Update context information and lines visible in the context pane.
Update context information and lines visible in the context pane .
def update_code_context(self):
        """Update context information and lines visible in the context pane.

        No update is done if the text hasn't been scrolled.  If the text
        was scrolled, the lines that should be shown in the context will
        be retrieved and the context area will be updated with the code,
        up to the number of maxlines.
        """
        new_topvisible = self.editwin.getlineno("@0,0")
        if self.topvisible == new_topvisible:      # Haven't scrolled.
            return
        if self.topvisible < new_topvisible:       # Scroll down.
            lines, lastindent = self.get_context(new_topvisible,
                                                 self.topvisible)
            # Retain only context info applicable to the region
            # between topvisible and new_topvisible.
            while self.info[-1][1] >= lastindent:
                del self.info[-1]
        else:  # self.topvisible > new_topvisible: # Scroll up.
            stopindent = self.info[-1][1] + 1
            # Retain only context info associated
            # with lines above new_topvisible.
            while self.info[-1][0] >= new_topvisible:
                stopindent = self.info[-1][1]
                del self.info[-1]
            lines, lastindent = self.get_context(new_topvisible,
                                                 self.info[-1][0]+1,
                                                 stopindent)
        self.info.extend(lines)
        self.topvisible = new_topvisible
        # Last context_depth context lines.
        context_strings = [x[2] for x in self.info[-self.context_depth:]]
        showfirst = 0 if context_strings[0] else 1
        # Update widget.
        self.context['height'] = len(context_strings) - showfirst
        self.context['state'] = 'normal'
        self.context.delete('1.0', 'end')
        self.context.insert('end', '\n'.join(context_strings[showfirst:]))
        self.context['state'] = 'disabled'
def update_code_context ( self ) : new_topvisible = self . editwin . getlineno ( "@0,0" ) if self . topvisible == new_topvisible : # Haven't scrolled. return if self . topvisible < new_topvisible : # Scroll down. lines , lastindent = self . get_context ( new_topvisible , self . topvisible ) # Retain only context info applicable to the region # between topvisible and new_topvisible. while self . info [ - 1 ] [ 1 ] >= lastindent : del self . info [ - 1 ] else : # self.topvisible > new_topvisible: # Scroll up. stopindent = self . info [ - 1 ] [ 1 ] + 1 # Retain only context info associated # with lines above new_topvisible. while self . info [ - 1 ] [ 0 ] >= new_topvisible : stopindent = self . info [ - 1 ] [ 1 ] del self . info [ - 1 ] lines , lastindent = self . get_context ( new_topvisible , self . info [ - 1 ] [ 0 ] + 1 , stopindent ) self . info . extend ( lines ) self . topvisible = new_topvisible # Last context_depth context lines. context_strings = [ x [ 2 ] for x in self . info [ - self . context_depth : ] ] showfirst = 0 if context_strings [ 0 ] else 1 # Update widget. self . context [ 'height' ] = len ( context_strings ) - showfirst self . context [ 'state' ] = 'normal' self . context . delete ( '1.0' , 'end' ) self . context . insert ( 'end' , '\n' . join ( context_strings [ showfirst : ] ) ) self . context [ 'state' ] = 'disabled'