--- a/src/eric7/QScintilla/Editor.py Fri Jul 05 10:15:29 2024 +0200 +++ b/src/eric7/QScintilla/Editor.py Mon Jul 29 14:43:35 2024 +0200 @@ -228,7 +228,15 @@ } def __init__( - self, dbs, fn="", vm=None, filetype="", editor=None, tv=None, parent=None + self, + dbs, + fn="", + vm=None, + filetype="", + editor=None, + tv=None, + assembly=None, + parent=None, ): """ Constructor @@ -236,18 +244,21 @@ @param dbs reference to the debug server object @type DebugServer @param fn name of the file to be opened. If it is None, a new (empty) - editor is opened. - @type str - @param vm reference to the view manager object - @type ViewManager - @param filetype type of the source file - @type str + editor is opened. (defaults to "") + @type str (optional) + @param vm reference to the view manager object (defaults to None) + @type ViewManager (optional) + @param filetype type of the source file (defaults to "") + @type str (optional) @param editor reference to an Editor object, if this is a cloned view - @type Editor - @param tv reference to the task viewer object - @type TaskViewer - @param parent reference to the parent widget - @type QWidget + (defaults to None) + @type Editor (optional) + @param tv reference to the task viewer object (defaults to None) + @type TaskViewer (optional) + @param assembly reference to the editor assembly object (defaults to None) + @type EditorAssembly (optional) + @param parent reference to the parent widget (defaults to None) + @type QWidget (optional) @exception OSError raised to indicate an issue accessing the file """ super().__init__(parent) @@ -256,6 +267,7 @@ self.enableMultiCursorSupport() + self.__assembly = assembly self.dbs = dbs self.taskViewer = tv self.fileName = "" @@ -317,6 +329,8 @@ # true if we are propagating a lines changed event self.__hasTaskMarkers = False # no task markers present + self.__checkExternalModification = True + # check and reload or warn when modified externally self.macros = {} # list of defined macros self.curMacro = None @@ -421,12 +435,6 @@ 1 << self.__changeMarkerUnsaved ) - # configure the margins - self.__setMarginsDisplay() - self.linesChanged.connect(self.__resizeLinenoMargin) - - self.marginClicked.connect(self.__marginClicked) - # set the eol mode self.__setEolMode() @@ -517,6 +525,12 @@ self.addClone(editor) editor.addClone(self) + # configure the margins + self.__setMarginsDisplay() + self.linesChanged.connect(self.__resizeLinenoMargin) + + self.marginClicked.connect(self.__marginClicked) + self.gotoLine(1) # connect the mouse hover signals @@ -672,6 +686,15 @@ self.SCN_ZOOM.connect(self.__markerMap.update) self.__markerMap.update() + def getAssembly(self): + """ + Public method to get a reference to the editor assembly object. + + @return reference to the editor assembly object + @rtype EditorAssembly + """ + return self.__assembly + def setFileName(self, name): """ Public method to set the file name of the current file. @@ -1999,10 +2022,7 @@ language = Preferences.getEditorLexerAssoc(bindName) if language == "Python": # correction for Python - pyVer = PythonUtilities.determinePythonVersion( - filename, self.text(0), self - ) - language = "Python{0}".format(pyVer) + language = "Python3" if language in [ "Python3", "MicroPython", @@ -2154,9 +2174,8 @@ filename = os.path.basename(filename) apiLanguage = Preferences.getEditorLexerAssoc(filename) if apiLanguage == "": - pyVer = self.__getPyVersion() - if pyVer: - apiLanguage = "Python{0}".format(pyVer) + if PythonUtilities.isPythonSource(self.fileName, self.text(0), self): + apiLanguage = "Python3" elif self.isRubyFile(): apiLanguage = "Ruby" @@ -2302,9 +2321,8 @@ """ ftype = self.filetype if not ftype: - pyVer = self.__getPyVersion() - if pyVer: - ftype = "Python{0}".format(pyVer) + if PythonUtilities.isPythonSource(self.fileName, self.text(0), self): + ftype = "Python3" elif self.isRubyFile(): ftype = "Ruby" else: @@ -2321,16 +2339,6 @@ """ return self.encoding - def __getPyVersion(self): - """ - Private method to return the Python main version or 0 if it's - not a Python file at all. - - @return Python version or 0 if it's not a Python file - @rtype int - """ - return PythonUtilities.determinePythonVersion(self.fileName, self.text(0), self) - def isPyFile(self): """ Public method to return a flag indicating a Python (2 or 3) file. @@ -2338,7 +2346,7 @@ @return flag indicating a Python3 file @rtype bool """ - return self.__getPyVersion() == 3 + return PythonUtilities.isPythonSource(self.fileName, self.text(0), self) def isPy3File(self): """ @@ -2347,7 +2355,7 @@ @return flag indicating a Python3 file @rtype bool """ - return self.__getPyVersion() == 3 + return PythonUtilities.isPythonSource(self.fileName, self.text(0), self) def isMicroPythonFile(self): """ @@ -8374,13 +8382,22 @@ or self.isReadOnly() ) + def setCheckExternalModificationEnabled(self, enable): + """ + Public method to enable or disable the check for external modifications. + + @param enable flag indicating the new enabled state + @type bool + """ + self.__checkExternalModification = enable + @pyqtSlot() def checkRereadFile(self): """ Public slot to check, if the file needs to be re-read, and refresh it if needed. """ - if self.checkModificationTime(): + if self.__checkExternalModification and self.checkModificationTime(): if Preferences.getEditor("AutoReopen") and not self.isModified(): self.__refresh() else: