eric7/Plugins/ViewManagerPlugins/Listspace/Listspace.py

branch
eric7
changeset 8532
a392af4b87e8
parent 8519
fd4722a8f782
child 8881
54e42bc2437a
diff -r 4ce885e452ac -r a392af4b87e8 eric7/Plugins/ViewManagerPlugins/Listspace/Listspace.py
--- a/eric7/Plugins/ViewManagerPlugins/Listspace/Listspace.py	Mon Aug 23 18:05:18 2021 +0200
+++ b/eric7/Plugins/ViewManagerPlugins/Listspace/Listspace.py	Mon Aug 23 19:15:36 2021 +0200
@@ -15,6 +15,8 @@
     QMenu, QApplication
 )
 
+from EricWidgets.EricApplication import ericApp
+
 from ViewManager.ViewManager import ViewManager
 
 import QScintilla.Editor
@@ -22,6 +24,7 @@
 from QScintilla.EditorAssembly import EditorAssembly
 
 import UI.PixmapCache
+import Preferences
 
 
 class StackedWidget(QStackedWidget):
@@ -254,6 +257,24 @@
         """
         Private method to initialize the viewlist context menu.
         """
+        self.__startMenu = QMenu(self.tr("Start"), self)
+        self.__startMenu.addAction(
+            UI.PixmapCache.getIcon("runScript"),
+            self.tr('Run Script...'),
+            self.__contextMenuRunScript)
+        self.__startMenu.addAction(
+            UI.PixmapCache.getIcon("debugScript"),
+            self.tr('Debug Script...'),
+            self.__contextMenuDebugScript)
+        self.__startMenu.addAction(
+            UI.PixmapCache.getIcon("profileScript"),
+            self.tr('Profile Script...'),
+            self.__contextMenuProfileScript)
+        self.__startMenu.addAction(
+            UI.PixmapCache.getIcon("coverageScript"),
+            self.tr('Coverage run of Script...'),
+            self.__contextMenuCoverageScript)
+        
         self.__menu = QMenu(self)
         self.__menu.addAction(
             UI.PixmapCache.getIcon("tabClose"),
@@ -279,6 +300,8 @@
             self.tr("Open 'rejection' file"),
             self.__contextMenuOpenRejections)
         self.__menu.addSeparator()
+        self.__startAct = self.__menu.addMenu(self.__startMenu)
+        self.__menu.addSeparator()
         self.__menu.addAction(
             UI.PixmapCache.getIcon("printPreview"),
             self.tr("Print Preview"), self.__contextMenuPrintPreviewFile)
@@ -313,8 +336,15 @@
                         rej = "{0}.rej".format(fileName)
                         self.openRejectionsMenuAct.setEnabled(
                             os.path.exists(rej))
+                        
+                        ext = os.path.splitext(fileName)[1]
+                        self.__startAct.setEnabled(
+                            ext in Preferences.getDebugger(
+                                "Python3Extensions").split()
+                        )
                     else:
                         self.openRejectionsMenuAct.setEnabled(False)
+                        self.__startAct.setEnabled(False)
                     
                     self.closeOthersMenuAct.setEnabled(
                         self.viewlist.count() > 1)
@@ -872,7 +902,43 @@
             if fn:
                 cb = QApplication.clipboard()
                 cb.setText(fn)
-        
+    
+    def __contextMenuRunScript(self):
+        """
+        Private method to run the editor script.
+        """
+        if self.contextMenuEditor:
+            fn = self.contextMenuEditor.getFileName()
+            if fn:
+                ericApp().getObject("DebugUI").doRun(False, script=fn)
+    
+    def __contextMenuDebugScript(self):
+        """
+        Private method to debug the editor script.
+        """
+        if self.contextMenuEditor:
+            fn = self.contextMenuEditor.getFileName()
+            if fn:
+                ericApp().getObject("DebugUI").doDebug(False, script=fn)
+    
+    def __contextMenuProfileScript(self):
+        """
+        Private method to profile the editor script.
+        """
+        if self.contextMenuEditor:
+            fn = self.contextMenuEditor.getFileName()
+            if fn:
+                ericApp().getObject("DebugUI").doProfile(False, script=fn)
+    
+    def __contextMenuCoverageScript(self):
+        """
+        Private method to run a coverage test of the editor script.
+        """
+        if self.contextMenuEditor:
+            fn = self.contextMenuEditor.getFileName()
+            if fn:
+                ericApp().getObject("DebugUI").doCoverage(False, script=fn)
+    
     def __currentChanged(self, index):
         """
         Private slot to handle the currentChanged signal.

eric ide

mercurial