diff -r ab6e87f6f1c4 -r 6d24ab9c0404 src/eric7/ViewManager/ViewManager.py --- a/src/eric7/ViewManager/ViewManager.py Mon Feb 13 17:51:03 2023 +0100 +++ b/src/eric7/ViewManager/ViewManager.py Mon Feb 13 17:52:26 2023 +0100 @@ -5402,7 +5402,7 @@ "ViewManager", """<p>The file <b>{0}</b> has unsaved changes.</p>""", ).format(fn), - editor.saveFile, + editor.saveFile if editor.isLocalFile() else None, ) if res: self.setEditorName(editor, editor.getFileName()) @@ -5938,8 +5938,8 @@ @param addNext flag indicating that if a new editor needs to be created, it should be added next to the current editor @type bool - @param indexes of the editor, first the split view index, second the - index within the view + @param indexes tuple containing the indexes of the editor, first the split + view index, second the index within the view @type tuple of two int @return tuple of two values giving a flag indicating a new window creation and a reference to the editor displaying this file @@ -6161,7 +6161,10 @@ def newEditor(self): """ - Public slot to generate a new empty editor. + Public method to generate a new empty editor. + + @return reference to the new editor + @rtype Editor """ from eric7.QScintilla.EditorAssembly import EditorAssembly @@ -6177,6 +6180,38 @@ self.editorOpened.emit("") self.editorOpenedEd.emit(editor) + return editor + + def newEditorWithText(self, text, language="", fileName=""): + """ + Public method to generate a new editor with a given text and associated file + name. + + @param text text for the editor + @type str + @param language source language (defaults to "") + @type str (optional) + @param fileName associated file name (defaults to "") + @type str (optional) + """ + from eric7.QScintilla.EditorAssembly import EditorAssembly + + assembly = EditorAssembly( + self.dbs, fileName, vm=self, filetype=language, tv=ericApp().getObject("TaskViewer") + ) + editor = assembly.getEditor() + self.editors.append(editor) + self.__connectEditor(editor) + self._addView(assembly, fileName) + self.__editorOpened() + self._checkActions(editor) + self.editorOpened.emit(fileName) + self.editorOpenedEd.emit(editor) + + editor.setText(text) + editor.setModified(False) + editor.clearChangeMarkers() + def printEditor(self, editor): """ Public slot to print an editor. @@ -7482,7 +7517,7 @@ (boolean) """ if editor is not None: - self.saveAct.setEnabled(editor.isModified()) + self.saveAct.setEnabled(editor.isModified() and editor.isLocalFile()) self.revertAct.setEnabled(editor.isModified()) self.undoAct.setEnabled(editor.isUndoAvailable())