def onScopeBegin(self): """The user requested jumping to the current scope begin""" if self.isPythonBuffer(): info = getBriefModuleInfoFromMemory(self.text) context = getContext(self, info, True) if context.getScope() != context.GlobalScope: GlobalData().mainWindow.jumpToLine(context.getLastScopeLine())
def highlightInOutline(self): """Triggered when highlight in outline browser is requested""" if self.isPythonBuffer(): info = getBriefModuleInfoFromMemory(self.text) context = getContext(self, info, True, False) line, _ = self.cursorPosition GlobalData().mainWindow.highlightInOutline(context, int(line) + 1) self.setFocus()
def updateBar(self): """Triggered when the timer is fired""" self.__updateTimer.stop() # just in case if not isPythonMime(self.__parentWidget.getMime()): return if not self.__connected: self.__connectEditorSignals() # Parse the buffer content self.__currentInfo = getBriefModuleInfoFromMemory(self.__editor.text) # Decide what icon to use if self.__currentInfo.isOK: self.__updateInfoIcon(self.STATE_OK_UTD) else: self.__updateInfoIcon(self.STATE_BROKEN_UTD) # Calc the cursor context context = getContext(self.__editor, self.__currentInfo, True, False) # Display the context self.__populateGlobalScope() if context.length == 0: self.__globalScopeCombo.setCurrentIndex(-1) else: index = self.__globalScopeCombo.findData( context.levels[0][0].line) self.__globalScopeCombo.setCurrentIndex(index) usedFromStore = 0 index = 1 while index < context.length: if len(self.__path) < index: newPathItem = PathElement(self) self.__path.append(newPathItem) self.__layout.addWidget(newPathItem.icon) self.__layout.addWidget(newPathItem.combo) combo = newPathItem.combo combo.pathIndex = len(self.__path) - 1 combo.jumpToLine.connect(self.__onJumpToLine) else: self.__path[index - 1].icon.setVisible(True) self.__path[index - 1].combo.setVisible(True) combo = self.__path[index - 1].combo combo.clear() # Populate the combo box self.__populateClassesAndFunctions(context.levels[index - 1][0], combo) combo.setCurrentIndex(combo.findData(context.levels[index][0].line)) index += 1 usedFromStore += 1 # it might need to have one more level with nothing selected if context.length > 0: if len(context.levels[context.length - 1][0].functions) > 0 or \ len(context.levels[context.length - 1][0].classes) > 0: # Need to add a combo if len(self.__path) <= usedFromStore: newPathItem = PathElement(self) self.__path.append(newPathItem) self.__layout.addWidget(newPathItem.icon) self.__layout.addWidget(newPathItem.combo) combo = newPathItem.combo combo.pathIndex = len(self.__path) - 1 combo.jumpToLine.connect(self.__onJumpToLine) else: self.__path[index - 1].icon.setVisible(True) self.__path[index - 1].combo.setVisible(True) combo = self.__path[index - 1].combo combo.clear() self.__populateClassesAndFunctions( context.levels[context.length - 1][0], combo) combo.setCurrentIndex(-1) usedFromStore += 1 # Hide extra components if so index = usedFromStore while index < len(self.__path): self.__path[index].icon.setVisible(False) self.__path[index].combo.setVisible(False) index += 1 # Make sure the spacer is the last item self.__layout.removeWidget(self.__spacer) self.__layout.addWidget(self.__spacer)
def updateBar( self ): " Triggered when the timer is fired " self.__updateTimer.stop() # just in case if self.parent().getFileType() not in [ Python3FileType, PythonFileType ]: return if not self.__connected: self.__connectEditorSignals() # Parse the buffer content self.__currentInfo = getBriefModuleInfoFromMemory( self.__editor.text() ) # Decide what icon to use if self.__currentInfo.isOK: self.__updateInfoIcon( self.STATE_OK_UTD ) else: self.__updateInfoIcon( self.STATE_BROKEN_UTD ) # Calc the cursor context context = getContext( self.__editor, self.__currentInfo, True, False ) # Display the context self.__populateGlobalScope() if context.length == 0: self.__globalScopeCombo.setCurrentIndex( -1 ) else: index = self.__globalScopeCombo.findData( context.levels[ 0 ][ 0 ].line ) self.__globalScopeCombo.setCurrentIndex( index ) usedFromStore = 0 index = 1 while index < context.length: if len( self.__path ) < index: newPathItem = PathElement( self ) self.__path.append( newPathItem ) self.__layout.addWidget( newPathItem.icon ) self.__layout.addWidget( newPathItem.combo ) combo = newPathItem.combo combo.pathIndex = len( self.__path ) - 1 combo.jumpToLine.connect( self.__onJumpToLine ) else: self.__path[ index - 1 ].icon.setVisible( True ) self.__path[ index - 1 ].combo.setVisible( True ) combo = self.__path[ index - 1 ].combo combo.clear() # Populate the combo box self.__populateClassesAndFunctions( context.levels[ index - 1 ][ 0 ], combo ) combo.setCurrentIndex( combo.findData( context.levels[ index ][ 0 ].line ) ) index += 1 usedFromStore += 1 # it might need to have one more level with nothing selected if context.length > 0: if len( context.levels[ context.length - 1 ][ 0 ].functions ) > 0 or \ len( context.levels[ context.length - 1 ][ 0 ].classes ) > 0: # Need to add a combo if len( self.__path ) <= usedFromStore: newPathItem = PathElement( self ) self.__path.append( newPathItem ) self.__layout.addWidget( newPathItem.icon ) self.__layout.addWidget( newPathItem.combo ) combo = newPathItem.combo combo.pathIndex = len( self.__path ) - 1 combo.jumpToLine.connect( self.__onJumpToLine ) else: self.__path[ index - 1 ].icon.setVisible( True ) self.__path[ index - 1 ].combo.setVisible( True ) combo = self.__path[ index - 1 ].combo combo.clear() self.__populateClassesAndFunctions( context.levels[ context.length - 1 ][ 0 ], combo ) combo.setCurrentIndex( -1 ) usedFromStore += 1 # Hide extra components if so index = usedFromStore while index < len( self.__path ): self.__path[ index ].icon.setVisible( False ) self.__path[ index ].combo.setVisible( False ) index += 1 # Make sure the spacer is the last item self.__layout.removeWidget( self.__spacer ) self.__layout.addWidget( self.__spacer ) return