src/eric7/QScintilla/Editor.py

branch
eric7
changeset 9413
80c06d472826
parent 9408
e993c39097d3
child 9432
e2445fa08533
--- a/src/eric7/QScintilla/Editor.py	Tue Oct 18 16:05:20 2022 +0200
+++ b/src/eric7/QScintilla/Editor.py	Tue Oct 18 16:06:21 2022 +0200
@@ -35,27 +35,26 @@
 from PyQt6.QtPrintSupport import QPrinter, QPrintDialog, QAbstractPrintDialog
 from PyQt6.Qsci import QsciScintilla, QsciMacro, QsciStyledText
 
-from EricWidgets.EricApplication import ericApp
-from EricWidgets import EricFileDialog, EricMessageBox
-from EricGui.EricOverrideCursor import EricOverrideCursor
-
-from EricUtilities.EricCache import EricCache
+from eric7.EricWidgets.EricApplication import ericApp
+from eric7.EricWidgets import EricFileDialog, EricMessageBox
+from eric7.EricGui.EricOverrideCursor import EricOverrideCursor
+
+from eric7.EricUtilities.EricCache import EricCache
 
 from .QsciScintillaCompat import QsciScintillaCompat
 from .EditorMarkerMap import EditorMarkerMap
 from .SpellChecker import SpellChecker
 
-from Globals import recentNameBreakpointConditions
-
-import Preferences
-import Utilities
-from Utilities import MouseUtilities
-
-import UI.PixmapCache
-
-from UI import PythonDisViewer
-
-from CodeFormatting.BlackFormattingAction import BlackFormattingAction
+from eric7.Globals import recentNameBreakpointConditions
+
+from eric7 import Preferences, Utilities
+from eric7.Utilities import MouseUtilities
+
+from eric7.EricGui import EricPixmapCache
+
+from eric7.UI import PythonDisViewer
+
+from eric7.CodeFormatting.BlackFormattingAction import BlackFormattingAction
 
 EditorAutoCompletionListID = 1
 TemplateCompletionListID = 2
@@ -336,16 +335,16 @@
         self.__changeMarkerUnsaved = self.markerDefine(
             self.__createChangeMarkerPixmap("OnlineChangeTraceMarkerUnsaved")
         )
-        self.breakpoint = self.markerDefine(UI.PixmapCache.getPixmap("break"))
-        self.cbreakpoint = self.markerDefine(UI.PixmapCache.getPixmap("cBreak"))
-        self.tbreakpoint = self.markerDefine(UI.PixmapCache.getPixmap("tBreak"))
-        self.tcbreakpoint = self.markerDefine(UI.PixmapCache.getPixmap("tCBreak"))
-        self.dbreakpoint = self.markerDefine(UI.PixmapCache.getPixmap("breakDisabled"))
-        self.bookmark = self.markerDefine(UI.PixmapCache.getPixmap("bookmark16"))
-        self.syntaxerror = self.markerDefine(UI.PixmapCache.getPixmap("syntaxError"))
-        self.notcovered = self.markerDefine(UI.PixmapCache.getPixmap("notcovered"))
-        self.taskmarker = self.markerDefine(UI.PixmapCache.getPixmap("task"))
-        self.warning = self.markerDefine(UI.PixmapCache.getPixmap("warning"))
+        self.breakpoint = self.markerDefine(EricPixmapCache.getPixmap("break"))
+        self.cbreakpoint = self.markerDefine(EricPixmapCache.getPixmap("cBreak"))
+        self.tbreakpoint = self.markerDefine(EricPixmapCache.getPixmap("tBreak"))
+        self.tcbreakpoint = self.markerDefine(EricPixmapCache.getPixmap("tCBreak"))
+        self.dbreakpoint = self.markerDefine(EricPixmapCache.getPixmap("breakDisabled"))
+        self.bookmark = self.markerDefine(EricPixmapCache.getPixmap("bookmark16"))
+        self.syntaxerror = self.markerDefine(EricPixmapCache.getPixmap("syntaxError"))
+        self.notcovered = self.markerDefine(EricPixmapCache.getPixmap("notcovered"))
+        self.taskmarker = self.markerDefine(EricPixmapCache.getPixmap("task"))
+        self.warning = self.markerDefine(EricPixmapCache.getPixmap("warning"))
 
         # define the line markers
         if Preferences.getEditor("LineMarkersBackground"):
@@ -354,10 +353,10 @@
             self.__setLineMarkerColours()
         else:
             self.currentline = self.markerDefine(
-                UI.PixmapCache.getPixmap("currentLineMarker")
+                EricPixmapCache.getPixmap("currentLineMarker")
             )
             self.errorline = self.markerDefine(
-                UI.PixmapCache.getPixmap("errorLineMarker")
+                EricPixmapCache.getPixmap("errorLineMarker")
             )
 
         self.breakpointMask = (
@@ -405,7 +404,7 @@
                         self.tr(
                             "<p>The file <b>{0}</b> is not a text file. It will not be"
                             " opened!</p>"
-                        ).format(self.fileName)
+                        ).format(self.fileName),
                     )
                     raise OSError()
 
@@ -422,7 +421,7 @@
                             self.fileName,
                             fileSizeKB,
                             Preferences.getEditor("RejectFilesize"),
-                        )
+                        ),
                     )
                     raise OSError()
                 elif fileSizeKB > Preferences.getEditor("WarnFilesize"):
@@ -635,45 +634,49 @@
         # finale size of the completion images
         imageSize = QSize(22, 22)
 
-        self.registerImage(self.ClassID, UI.PixmapCache.getPixmap("class", imageSize))
+        self.registerImage(self.ClassID, EricPixmapCache.getPixmap("class", imageSize))
         self.registerImage(
             self.ClassProtectedID,
-            UI.PixmapCache.getPixmap("class_protected", imageSize),
+            EricPixmapCache.getPixmap("class_protected", imageSize),
+        )
+        self.registerImage(
+            self.ClassPrivateID, EricPixmapCache.getPixmap("class_private", imageSize)
         )
         self.registerImage(
-            self.ClassPrivateID, UI.PixmapCache.getPixmap("class_private", imageSize)
-        )
-        self.registerImage(self.MethodID, UI.PixmapCache.getPixmap("method", imageSize))
+            self.MethodID, EricPixmapCache.getPixmap("method", imageSize)
+        )
         self.registerImage(
             self.MethodProtectedID,
-            UI.PixmapCache.getPixmap("method_protected", imageSize),
+            EricPixmapCache.getPixmap("method_protected", imageSize),
         )
         self.registerImage(
-            self.MethodPrivateID, UI.PixmapCache.getPixmap("method_private", imageSize)
+            self.MethodPrivateID, EricPixmapCache.getPixmap("method_private", imageSize)
         )
         self.registerImage(
-            self.AttributeID, UI.PixmapCache.getPixmap("attribute", imageSize)
+            self.AttributeID, EricPixmapCache.getPixmap("attribute", imageSize)
         )
         self.registerImage(
             self.AttributeProtectedID,
-            UI.PixmapCache.getPixmap("attribute_protected", imageSize),
+            EricPixmapCache.getPixmap("attribute_protected", imageSize),
         )
         self.registerImage(
             self.AttributePrivateID,
-            UI.PixmapCache.getPixmap("attribute_private", imageSize),
-        )
-        self.registerImage(self.EnumID, UI.PixmapCache.getPixmap("enum", imageSize))
+            EricPixmapCache.getPixmap("attribute_private", imageSize),
+        )
+        self.registerImage(self.EnumID, EricPixmapCache.getPixmap("enum", imageSize))
         self.registerImage(
-            self.KeywordsID, UI.PixmapCache.getPixmap("keywords", imageSize)
-        )
-        self.registerImage(self.ModuleID, UI.PixmapCache.getPixmap("module", imageSize))
-
+            self.KeywordsID, EricPixmapCache.getPixmap("keywords", imageSize)
+        )
         self.registerImage(
-            self.FromDocumentID, UI.PixmapCache.getPixmap("editor", imageSize)
+            self.ModuleID, EricPixmapCache.getPixmap("module", imageSize)
         )
 
         self.registerImage(
-            self.TemplateImageID, UI.PixmapCache.getPixmap("templateViewer", imageSize)
+            self.FromDocumentID, EricPixmapCache.getPixmap("editor", imageSize)
+        )
+
+        self.registerImage(
+            self.TemplateImageID, EricPixmapCache.getPixmap("templateViewer", imageSize)
         )
 
     def addClone(self, editor):
@@ -853,43 +856,43 @@
         self.__menus["SpellCheck"] = self.spellCheckMenu
 
         self.menuActs["Undo"] = self.menu.addAction(
-            UI.PixmapCache.getIcon("editUndo"), self.tr("Undo"), self.undo
+            EricPixmapCache.getIcon("editUndo"), self.tr("Undo"), self.undo
         )
         self.menuActs["Redo"] = self.menu.addAction(
-            UI.PixmapCache.getIcon("editRedo"), self.tr("Redo"), self.redo
+            EricPixmapCache.getIcon("editRedo"), self.tr("Redo"), self.redo
         )
         self.menuActs["Revert"] = self.menu.addAction(
             self.tr("Revert to last saved state"), self.revertToUnmodified
         )
         self.menu.addSeparator()
         self.menuActs["Cut"] = self.menu.addAction(
-            UI.PixmapCache.getIcon("editCut"), self.tr("Cut"), self.cut
+            EricPixmapCache.getIcon("editCut"), self.tr("Cut"), self.cut
         )
         self.menuActs["Copy"] = self.menu.addAction(
-            UI.PixmapCache.getIcon("editCopy"), self.tr("Copy"), self.copy
+            EricPixmapCache.getIcon("editCopy"), self.tr("Copy"), self.copy
         )
         self.menuActs["Paste"] = self.menu.addAction(
-            UI.PixmapCache.getIcon("editPaste"), self.tr("Paste"), self.paste
+            EricPixmapCache.getIcon("editPaste"), self.tr("Paste"), self.paste
         )
         if not self.miniMenu:
             self.menu.addSeparator()
             self.menu.addAction(
-                UI.PixmapCache.getIcon("editIndent"),
+                EricPixmapCache.getIcon("editIndent"),
                 self.tr("Indent"),
                 self.indentLineOrSelection,
             )
             self.menu.addAction(
-                UI.PixmapCache.getIcon("editUnindent"),
+                EricPixmapCache.getIcon("editUnindent"),
                 self.tr("Unindent"),
                 self.unindentLineOrSelection,
             )
             self.menuActs["Comment"] = self.menu.addAction(
-                UI.PixmapCache.getIcon("editComment"),
+                EricPixmapCache.getIcon("editComment"),
                 self.tr("Comment"),
                 self.commentLineOrSelection,
             )
             self.menuActs["Uncomment"] = self.menu.addAction(
-                UI.PixmapCache.getIcon("editUncomment"),
+                EricPixmapCache.getIcon("editUncomment"),
                 self.tr("Uncomment"),
                 self.uncommentLineOrSelection,
             )
@@ -958,12 +961,12 @@
         self.menuActs["Tools"] = self.menu.addMenu(self.toolsMenu)
         self.menu.addSeparator()
         self.menu.addAction(
-            UI.PixmapCache.getIcon("documentNewView"),
+            EricPixmapCache.getIcon("documentNewView"),
             self.tr("New Document View"),
             self.__newView,
         )
         self.menuActs["NewSplit"] = self.menu.addAction(
-            UI.PixmapCache.getIcon("splitVertical"),
+            EricPixmapCache.getIcon("splitVertical"),
             self.tr("New Document View (with new split)"),
             self.__newViewNewSplit,
         )
@@ -972,15 +975,15 @@
         self.reopenEncodingMenu = self.__initContextMenuReopenWithEncoding()
         self.menuActs["Reopen"] = self.menu.addMenu(self.reopenEncodingMenu)
         self.menuActs["Save"] = self.menu.addAction(
-            UI.PixmapCache.getIcon("fileSave"), self.tr("Save"), self.__contextSave
+            EricPixmapCache.getIcon("fileSave"), self.tr("Save"), self.__contextSave
         )
         self.menu.addAction(
-            UI.PixmapCache.getIcon("fileSaveAs"),
+            EricPixmapCache.getIcon("fileSaveAs"),
             self.tr("Save As..."),
             self.__contextSaveAs,
         )
         self.menu.addAction(
-            UI.PixmapCache.getIcon("fileSaveCopy"),
+            EricPixmapCache.getIcon("fileSaveCopy"),
             self.tr("Save Copy..."),
             self.__contextSaveCopy,
         )
@@ -1115,7 +1118,7 @@
         )
         menu.addSeparator()
         menu.addAction(
-            UI.PixmapCache.getIcon("open"),
+            EricPixmapCache.getIcon("open"),
             self.tr("Load Diagram..."),
             self.__loadDiagram,
         )
@@ -1135,7 +1138,7 @@
 
         self.languagesActGrp = QActionGroup(self)
         self.noLanguageAct = menu.addAction(
-            UI.PixmapCache.getIcon("fileText"), self.tr("Text")
+            EricPixmapCache.getIcon("fileText"), self.tr("Text")
         )
         self.noLanguageAct.setCheckable(True)
         self.noLanguageAct.setData("None")
@@ -1151,7 +1154,7 @@
             if language != "Guessed":
                 self.supportedLanguages[language] = supportedLanguages[language][:2]
                 act = menu.addAction(
-                    UI.PixmapCache.getIcon(supportedLanguages[language][2]),
+                    EricPixmapCache.getIcon(supportedLanguages[language][2]),
                     self.supportedLanguages[language][0],
                 )
                 act.setCheckable(True)
@@ -1205,7 +1208,7 @@
         @rtype QMenu
         """
         menu = QMenu(self.tr("Re-Open With Encoding"))
-        menu.setIcon(UI.PixmapCache.getIcon("open"))
+        menu.setIcon(EricPixmapCache.getIcon("open"))
 
         for encoding in sorted(Utilities.supportedCodecs):
             act = menu.addAction(encoding)
@@ -1228,19 +1231,19 @@
 
         self.eolActGrp = QActionGroup(self)
 
-        act = menu.addAction(UI.PixmapCache.getIcon("eolLinux"), self.tr("Unix"))
+        act = menu.addAction(EricPixmapCache.getIcon("eolLinux"), self.tr("Unix"))
         act.setCheckable(True)
         act.setData("\n")
         self.supportedEols["\n"] = act
         self.eolActGrp.addAction(act)
 
-        act = menu.addAction(UI.PixmapCache.getIcon("eolWindows"), self.tr("Windows"))
+        act = menu.addAction(EricPixmapCache.getIcon("eolWindows"), self.tr("Windows"))
         act.setCheckable(True)
         act.setData("\r\n")
         self.supportedEols["\r\n"] = act
         self.eolActGrp.addAction(act)
 
-        act = menu.addAction(UI.PixmapCache.getIcon("eolMac"), self.tr("Macintosh"))
+        act = menu.addAction(EricPixmapCache.getIcon("eolMac"), self.tr("Macintosh"))
         act.setCheckable(True)
         act.setData("\r")
         self.supportedEols["\r"] = act
@@ -1259,18 +1262,18 @@
         @rtype QMenu
         """
         menu = QMenu(self.tr("Spelling"))
-        menu.setIcon(UI.PixmapCache.getIcon("spellchecking"))
+        menu.setIcon(EricPixmapCache.getIcon("spellchecking"))
 
         self.spellLanguagesMenu = self.__initContextMenuSpellLanguages()
         self.__menus["SpellLanguages"] = self.spellLanguagesMenu
 
         self.menuActs["SpellCheck"] = menu.addAction(
-            UI.PixmapCache.getIcon("spellchecking"),
+            EricPixmapCache.getIcon("spellchecking"),
             self.tr("Check spelling..."),
             self.checkSpelling,
         )
         self.menuActs["SpellCheckSelection"] = menu.addAction(
-            UI.PixmapCache.getIcon("spellchecking"),
+            EricPixmapCache.getIcon("spellchecking"),
             self.tr("Check spelling of selection..."),
             self.__checkSpellingSelection,
         )
@@ -2612,7 +2615,7 @@
                     else []
                 )
 
-                from Debugger.EditBreakpointDialog import EditBreakpointDialog
+                from eric7.Debugger.EditBreakpointDialog import EditBreakpointDialog
 
                 dlg = EditBreakpointDialog(
                     (self.fileName, ln),
@@ -2944,7 +2947,7 @@
         """
         Public slot to extract all tasks.
         """
-        from Tasks.Task import Task
+        from eric7.Tasks.Task import Task
 
         markers = {
             taskType: Preferences.getTasks(markersName).split()
@@ -4482,10 +4485,10 @@
             self.__setLineMarkerColours()
         else:
             self.markerDefine(
-                UI.PixmapCache.getPixmap("currentLineMarker"), self.currentline
+                EricPixmapCache.getPixmap("currentLineMarker"), self.currentline
             )
             self.markerDefine(
-                UI.PixmapCache.getPixmap("errorLineMarker"), self.errorline
+                EricPixmapCache.getPixmap("errorLineMarker"), self.errorline
             )
 
         # set the text display
@@ -5667,9 +5670,11 @@
 
         splitOrientation = self.vm.getSplitOrientation()
         if splitOrientation == Qt.Orientation.Horizontal:
-            self.menuActs["NewSplit"].setIcon(UI.PixmapCache.getIcon("splitHorizontal"))
-        else:
-            self.menuActs["NewSplit"].setIcon(UI.PixmapCache.getIcon("splitVertical"))
+            self.menuActs["NewSplit"].setIcon(
+                EricPixmapCache.getIcon("splitHorizontal")
+            )
+        else:
+            self.menuActs["NewSplit"].setIcon(EricPixmapCache.getIcon("splitVertical"))
 
         self.menuActs["Tools"].setEnabled(not self.toolsMenu.isEmpty())
 
@@ -6096,7 +6101,7 @@
         if not self.checkDirty():
             return
 
-        from DataViews.CodeMetricsDialog import CodeMetricsDialog
+        from eric7.DataViews.CodeMetricsDialog import CodeMetricsDialog
 
         self.codemetrics = CodeMetricsDialog()
         self.codemetrics.show()
@@ -6155,7 +6160,7 @@
         fn = self.__getCodeCoverageFile()
         self.__coverageFile = fn
         if fn:
-            from DataViews.PyCoverageDialog import PyCoverageDialog
+            from eric7.DataViews.PyCoverageDialog import PyCoverageDialog
 
             self.codecoverage = PyCoverageDialog()
             self.codecoverage.show()
@@ -6319,7 +6324,7 @@
         else:
             return
 
-        from DataViews.PyProfileDialog import PyProfileDialog
+        from eric7.DataViews.PyProfileDialog import PyProfileDialog
 
         self.profiledata = PyProfileDialog()
         self.profiledata.show()
@@ -7619,7 +7624,7 @@
         Private method to handle the Add localized resource context menu
         action.
         """
-        from Project.AddLanguageDialog import AddLanguageDialog
+        from eric7.Project.AddLanguageDialog import AddLanguageDialog
 
         dlg = AddLanguageDialog(self)
         if dlg.exec() == QDialog.DialogCode.Accepted:
@@ -7650,7 +7655,7 @@
         """
         Private method to handle the Class Diagram context menu action.
         """
-        from Graphics.UMLDialog import UMLDialog, UMLDialogType
+        from eric7.Graphics.UMLDialog import UMLDialog, UMLDialogType
 
         if not self.checkDirty():
             return
@@ -7668,7 +7673,7 @@
         """
         Private method to handle the Package Diagram context menu action.
         """
-        from Graphics.UMLDialog import UMLDialog, UMLDialogType
+        from eric7.Graphics.UMLDialog import UMLDialog, UMLDialogType
 
         if not self.checkDirty():
             return
@@ -7693,7 +7698,7 @@
         """
         Private method to handle the Imports Diagram context menu action.
         """
-        from Graphics.UMLDialog import UMLDialog, UMLDialogType
+        from eric7.Graphics.UMLDialog import UMLDialog, UMLDialogType
 
         if not self.checkDirty():
             return
@@ -7717,7 +7722,7 @@
         """
         Private method to handle the Imports Diagram context menu action.
         """
-        from Graphics.UMLDialog import UMLDialog, UMLDialogType
+        from eric7.Graphics.UMLDialog import UMLDialog, UMLDialogType
 
         res = EricMessageBox.yesNo(
             self,
@@ -7734,7 +7739,7 @@
         """
         Private slot to load a diagram from file.
         """
-        from Graphics.UMLDialog import UMLDialog, UMLDialogType
+        from eric7.Graphics.UMLDialog import UMLDialog, UMLDialogType
 
         self.loadedDiagram = UMLDialog(
             UMLDialogType.NO_DIAGRAM, self.project, parent=self
@@ -8074,7 +8079,7 @@
         if suggestions:
             self.spellingMenu.addSeparator()
         self.spellingMenu.addAction(
-            UI.PixmapCache.getIcon("spellchecking"),
+            EricPixmapCache.getIcon("spellchecking"),
             self.tr("Check spelling..."),
             self.__checkSpellingWord,
         )
@@ -8956,7 +8961,7 @@
 
             docstringMenu = DocstringMenuForEnterOnly(self)
             act = docstringMenu.addAction(
-                UI.PixmapCache.getIcon("fileText"),
+                EricPixmapCache.getIcon("fileText"),
                 self.tr("Generate Docstring"),
                 lambda: generator.insertDocstring(cursorPosition, fromStart=False),
             )
@@ -9067,8 +9072,10 @@
         @param action formatting operation to be performed
         @type BlackFormattingAction
         """
-        from CodeFormatting.BlackConfigurationDialog import BlackConfigurationDialog
-        from CodeFormatting.BlackFormattingDialog import BlackFormattingDialog
+        from eric7.CodeFormatting.BlackConfigurationDialog import (
+            BlackConfigurationDialog,
+        )
+        from eric7.CodeFormatting.BlackFormattingDialog import BlackFormattingDialog
 
         if not self.isModified() or self.saveFile():
             withProject = (

eric ide

mercurial