src/eric7/ViewManager/ViewManager.py

branch
eric7
changeset 9758
6d24ab9c0404
parent 9695
ad962e9b904d
child 9786
f94b530722af
equal deleted inserted replaced
9757:ab6e87f6f1c4 9758:6d24ab9c0404
5400 QCoreApplication.translate("ViewManager", "File Modified"), 5400 QCoreApplication.translate("ViewManager", "File Modified"),
5401 QCoreApplication.translate( 5401 QCoreApplication.translate(
5402 "ViewManager", 5402 "ViewManager",
5403 """<p>The file <b>{0}</b> has unsaved changes.</p>""", 5403 """<p>The file <b>{0}</b> has unsaved changes.</p>""",
5404 ).format(fn), 5404 ).format(fn),
5405 editor.saveFile, 5405 editor.saveFile if editor.isLocalFile() else None,
5406 ) 5406 )
5407 if res: 5407 if res:
5408 self.setEditorName(editor, editor.getFileName()) 5408 self.setEditorName(editor, editor.getFileName())
5409 return res 5409 return res
5410 5410
5936 @param filetype type of the source file 5936 @param filetype type of the source file
5937 @type str 5937 @type str
5938 @param addNext flag indicating that if a new editor needs to be 5938 @param addNext flag indicating that if a new editor needs to be
5939 created, it should be added next to the current editor 5939 created, it should be added next to the current editor
5940 @type bool 5940 @type bool
5941 @param indexes of the editor, first the split view index, second the 5941 @param indexes tuple containing the indexes of the editor, first the split
5942 index within the view 5942 view index, second the index within the view
5943 @type tuple of two int 5943 @type tuple of two int
5944 @return tuple of two values giving a flag indicating a new window 5944 @return tuple of two values giving a flag indicating a new window
5945 creation and a reference to the editor displaying this file 5945 creation and a reference to the editor displaying this file
5946 @rtype tuple of (bool, Editor) 5946 @rtype tuple of (bool, Editor)
5947 """ 5947 """
6159 exporterFormat = act.data() 6159 exporterFormat = act.data()
6160 aw.exportFile(exporterFormat) 6160 aw.exportFile(exporterFormat)
6161 6161
6162 def newEditor(self): 6162 def newEditor(self):
6163 """ 6163 """
6164 Public slot to generate a new empty editor. 6164 Public method to generate a new empty editor.
6165
6166 @return reference to the new editor
6167 @rtype Editor
6165 """ 6168 """
6166 from eric7.QScintilla.EditorAssembly import EditorAssembly 6169 from eric7.QScintilla.EditorAssembly import EditorAssembly
6167 6170
6168 assembly = EditorAssembly( 6171 assembly = EditorAssembly(
6169 self.dbs, "", self, tv=ericApp().getObject("TaskViewer") 6172 self.dbs, "", self, tv=ericApp().getObject("TaskViewer")
6174 self._addView(assembly, None) 6177 self._addView(assembly, None)
6175 self.__editorOpened() 6178 self.__editorOpened()
6176 self._checkActions(editor) 6179 self._checkActions(editor)
6177 self.editorOpened.emit("") 6180 self.editorOpened.emit("")
6178 self.editorOpenedEd.emit(editor) 6181 self.editorOpenedEd.emit(editor)
6182
6183 return editor
6184
6185 def newEditorWithText(self, text, language="", fileName=""):
6186 """
6187 Public method to generate a new editor with a given text and associated file
6188 name.
6189
6190 @param text text for the editor
6191 @type str
6192 @param language source language (defaults to "")
6193 @type str (optional)
6194 @param fileName associated file name (defaults to "")
6195 @type str (optional)
6196 """
6197 from eric7.QScintilla.EditorAssembly import EditorAssembly
6198
6199 assembly = EditorAssembly(
6200 self.dbs, fileName, vm=self, filetype=language, tv=ericApp().getObject("TaskViewer")
6201 )
6202 editor = assembly.getEditor()
6203 self.editors.append(editor)
6204 self.__connectEditor(editor)
6205 self._addView(assembly, fileName)
6206 self.__editorOpened()
6207 self._checkActions(editor)
6208 self.editorOpened.emit(fileName)
6209 self.editorOpenedEd.emit(editor)
6210
6211 editor.setText(text)
6212 editor.setModified(False)
6213 editor.clearChangeMarkers()
6179 6214
6180 def printEditor(self, editor): 6215 def printEditor(self, editor):
6181 """ 6216 """
6182 Public slot to print an editor. 6217 Public slot to print an editor.
6183 6218
7480 @param editor editor window 7515 @param editor editor window
7481 @param setSb flag indicating an update of the status bar is wanted 7516 @param setSb flag indicating an update of the status bar is wanted
7482 (boolean) 7517 (boolean)
7483 """ 7518 """
7484 if editor is not None: 7519 if editor is not None:
7485 self.saveAct.setEnabled(editor.isModified()) 7520 self.saveAct.setEnabled(editor.isModified() and editor.isLocalFile())
7486 self.revertAct.setEnabled(editor.isModified()) 7521 self.revertAct.setEnabled(editor.isModified())
7487 7522
7488 self.undoAct.setEnabled(editor.isUndoAvailable()) 7523 self.undoAct.setEnabled(editor.isUndoAvailable())
7489 self.redoAct.setEnabled(editor.isRedoAvailable()) 7524 self.redoAct.setEnabled(editor.isRedoAvailable())
7490 self.gotoLastEditAct.setEnabled(editor.isLastEditPositionAvailable()) 7525 self.gotoLastEditAct.setEnabled(editor.isLastEditPositionAvailable())

eric ide

mercurial