Debugger/DebugUI.py

changeset 5899
0516f6548ca6
parent 5663
52a91f9a7a76
child 6039
d52e90757805
--- a/Debugger/DebugUI.py	Mon Oct 09 19:06:46 2017 +0200
+++ b/Debugger/DebugUI.py	Tue Oct 10 19:05:00 2017 +0200
@@ -77,6 +77,8 @@
         self.editorOpen = False
         
         # read the saved debug info values
+        self.interpreterHistory = Preferences.toList(
+            Preferences.Prefs.settings.value('DebugInfo/InterpreterHistory'))
         self.argvHistory = Preferences.toList(
             Preferences.Prefs.settings.value('DebugInfo/ArgumentsHistory'))
         self.wdHistory = Preferences.toList(
@@ -669,7 +671,26 @@
                                  starttb.windowTitle())
         
         return [starttb, debugtb]
+
+    def setInterpreterHistory(self, interpreterStr, clearHistories=False,
+                              history=None):
+        """
+        Public slot to initialize the interpreter history.
         
+        @param interpreterStr interpreter (string)
+        @param clearHistories flag indicating, that the list should
+            be cleared (boolean)
+        @param history list of history entries to be set (list of strings)
+        """
+        if clearHistories:
+            del self.interpreterHistory[1:]
+        elif history is not None:
+            self.interpreterHistory = history[:]
+        else:
+            if interpreterStr in self.interpreterHistory:
+                self.interpreterHistory.remove(interpreterStr)
+            self.interpreterHistory.insert(0, interpreterStr)
+    
     def setArgvHistory(self, argsStr, clearHistories=False, history=None):
         """
         Public slot to initialize the argv history.
@@ -910,11 +931,14 @@
         """
         Public method to clear the various debug histories.
         """
+        self.interpreterHistory = []
         self.argvHistory = []
         self.wdHistory = []
         self.envHistory = []
         
         Preferences.Prefs.settings.setValue(
+            'DebugInfo/InterpreterHistory', self.interpreterHistory)
+        Preferences.Prefs.settings.setValue(
             'DebugInfo/ArgumentsHistory', self.argvHistory)
         Preferences.Prefs.settings.setValue(
             'DebugInfo/WorkingDirectoryHistory', self.wdHistory)
@@ -926,11 +950,14 @@
         Public method to perform shutdown actions.
         """
         # Just save the 10 most recent entries
+        del self.interpreterHistory[10:]
         del self.argvHistory[10:]
         del self.wdHistory[10:]
         del self.envHistory[10:]
         
         Preferences.Prefs.settings.setValue(
+            'DebugInfo/InterpreterHistory', self.interpreterHistory)
+        Preferences.Prefs.settings.setValue(
             'DebugInfo/ArgumentsHistory', self.argvHistory)
         Preferences.Prefs.settings.setValue(
             'DebugInfo/WorkingDirectoryHistory', self.wdHistory)
@@ -1545,11 +1572,12 @@
         else:
             cap = self.tr("Coverage of Script")
         dlg = StartDialog(
-            cap, self.argvHistory, self.wdHistory,
+            cap, self.interpreterHistory, self.argvHistory, self.wdHistory,
             self.envHistory, self.exceptions, self.ui, 2,
             autoClearShell=self.autoClearShell)
         if dlg.exec_() == QDialog.Accepted:
-            argv, wd, env, exceptions, clearShell, console = dlg.getData()
+            interpreter, argv, wd, env, exceptions, clearShell, console = \
+                dlg.getData()
             eraseCoverage = dlg.getCoverageData()
             
             if runProject:
@@ -1569,7 +1597,7 @@
                 
                 # save the info for later use
                 self.project.setDbgInfo(
-                    argv, wd, env, exceptions, self.excList,
+                    interpreter, argv, wd, env, exceptions, self.excList,
                     self.excIgnoreList, clearShell)
                 
                 self.lastStartAction = 6
@@ -1595,6 +1623,7 @@
             
             # This moves any previous occurrence of these arguments to the head
             # of the list.
+            self.setInterpreterHistory(interpreter)
             self.setArgvHistory(argv)
             self.setWdHistory(wd)
             self.setEnvHistory(env)
@@ -1624,7 +1653,7 @@
                 
                 # Ask the client to open the new program.
                 self.debugServer.remoteCoverage(
-                    fn, argv, wd, env,
+                    interpreter, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell, erase=eraseCoverage,
                     forProject=runProject, runInConsole=console,
                     clientType=self.clientType)
@@ -1632,11 +1661,14 @@
                 self.stopAct.setEnabled(True)
         
         if dlg.clearHistories():
+            self.setInterpreterHistory("", clearHistories=True)
             self.setArgvHistory("", clearHistories=True)
             self.setWdHistory("", clearHistories=True)
             self.setEnvHistory("", clearHistories=True)
         elif dlg.historiesModified():
-            argvHistory, wdHistory, envHistory = dlg.getHistories()
+            argvHistory, wdHistory, envHistory, interpreterHistory = \
+                dlg.getHistories()
+            self.setInterpreterHistory("", history=interpreterHistory)
             self.setArgvHistory("", history=argvHistory)
             self.setWdHistory("", history=wdHistory)
             self.setEnvHistory("", history=envHistory)
@@ -1673,11 +1705,12 @@
         else:
             cap = self.tr("Profile of Script")
         dlg = StartDialog(
-            cap, self.argvHistory, self.wdHistory, self.envHistory,
-            self.exceptions, self.ui, 3,
+            cap, self.interpreterHistory, self.argvHistory, self.wdHistory,
+            self.envHistory, self.exceptions, self.ui, 3,
             autoClearShell=self.autoClearShell)
         if dlg.exec_() == QDialog.Accepted:
-            argv, wd, env, exceptions, clearShell, console = dlg.getData()
+            interpreter, argv, wd, env, exceptions, clearShell, console = \
+                dlg.getData()
             eraseTimings = dlg.getProfilingData()
             
             if runProject:
@@ -1697,7 +1730,7 @@
                 
                 # save the info for later use
                 self.project.setDbgInfo(
-                    argv, wd, env, exceptions, self.excList,
+                    interpreter, argv, wd, env, exceptions, self.excList,
                     self.excIgnoreList, clearShell)
                 
                 self.lastStartAction = 8
@@ -1723,6 +1756,7 @@
             
             # This moves any previous occurrence of these arguments to the head
             # of the list.
+            self.setInterpreterHistory(interpreter)
             self.setArgvHistory(argv)
             self.setWdHistory(wd)
             self.setEnvHistory(env)
@@ -1752,7 +1786,7 @@
                 
                 # Ask the client to open the new program.
                 self.debugServer.remoteProfile(
-                    fn, argv, wd, env,
+                    interpreter, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell, erase=eraseTimings,
                     forProject=runProject, runInConsole=console,
                     clientType=self.clientType)
@@ -1760,11 +1794,14 @@
                 self.stopAct.setEnabled(True)
         
         if dlg.clearHistories():
+            self.setInterpreterHistory("", clearHistories=True)
             self.setArgvHistory("", clearHistories=True)
             self.setWdHistory("", clearHistories=True)
             self.setEnvHistory("", clearHistories=True)
         elif dlg.historiesModified():
-            argvHistory, wdHistory, envHistory = dlg.getHistories()
+            argvHistory, wdHistory, envHistory, interpreterHistory = \
+                dlg.getHistories()
+            self.setInterpreterHistory("", history=interpreterHistory)
             self.setArgvHistory("", history=argvHistory)
             self.setWdHistory("", history=wdHistory)
             self.setEnvHistory("", history=envHistory)
@@ -1801,13 +1838,14 @@
         else:
             cap = self.tr("Run Script")
         dlg = StartDialog(
-            cap, self.argvHistory, self.wdHistory, self.envHistory,
-            self.exceptions, self.ui, 1,
+            cap, self.interpreterHistory, self.argvHistory, self.wdHistory,
+            self.envHistory, self.exceptions, self.ui, 1,
             autoClearShell=self.autoClearShell,
             autoFork=self.forkAutomatically,
             forkChild=self.forkIntoChild)
         if dlg.exec_() == QDialog.Accepted:
-            argv, wd, env, exceptions, clearShell, console = dlg.getData()
+            interpreter, argv, wd, env, exceptions, clearShell, console = \
+                dlg.getData()
             forkAutomatically, forkIntoChild = dlg.getRunData()
             
             if runProject:
@@ -1827,7 +1865,7 @@
                 
                 # save the info for later use
                 self.project.setDbgInfo(
-                    argv, wd, env, exceptions, self.excList,
+                    interpreter, argv, wd, env, exceptions, self.excList,
                     self.excIgnoreList, clearShell)
                 
                 self.lastStartAction = 4
@@ -1853,6 +1891,7 @@
             
             # This moves any previous occurrence of these arguments to the head
             # of the list.
+            self.setInterpreterHistory(interpreter)
             self.setArgvHistory(argv)
             self.setWdHistory(wd)
             self.setEnvHistory(env)
@@ -1883,7 +1922,7 @@
                 
                 # Ask the client to open the new program.
                 self.debugServer.remoteRun(
-                    fn, argv, wd, env,
+                    interpreter, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell, forProject=runProject,
                     runInConsole=console, autoFork=forkAutomatically,
                     forkChild=forkIntoChild, clientType=self.clientType)
@@ -1891,11 +1930,14 @@
                 self.stopAct.setEnabled(True)
         
         if dlg.clearHistories():
+            self.setInterpreterHistory("", clearHistories=True)
             self.setArgvHistory("", clearHistories=True)
             self.setWdHistory("", clearHistories=True)
             self.setEnvHistory("", clearHistories=True)
         elif dlg.historiesModified():
-            argvHistory, wdHistory, envHistory = dlg.getHistories()
+            argvHistory, wdHistory, envHistory, interpreterHistory = \
+                dlg.getHistories()
+            self.setInterpreterHistory("", history=interpreterHistory)
             self.setArgvHistory("", history=argvHistory)
             self.setWdHistory("", history=wdHistory)
             self.setEnvHistory("", history=envHistory)
@@ -1932,12 +1974,14 @@
         else:
             cap = self.tr("Debug Script")
         dlg = StartDialog(
-            cap, self.argvHistory, self.wdHistory, self.envHistory,
-            self.exceptions, self.ui, 0, tracePython=self.tracePython,
-            autoClearShell=self.autoClearShell, autoContinue=self.autoContinue,
-            autoFork=self.forkAutomatically, forkChild=self.forkIntoChild)
+            cap, self.interpreterHistory, self.argvHistory, self.wdHistory,
+            self.envHistory, self.exceptions, self.ui, 0,
+            tracePython=self.tracePython, autoClearShell=self.autoClearShell,
+            autoContinue=self.autoContinue, autoFork=self.forkAutomatically,
+            forkChild=self.forkIntoChild)
         if dlg.exec_() == QDialog.Accepted:
-            argv, wd, env, exceptions, clearShell, console = dlg.getData()
+            interpreter, argv, wd, env, exceptions, clearShell, console = \
+                dlg.getData()
             tracePython, autoContinue, forkAutomatically, forkIntoChild = \
                 dlg.getDebugData()
             
@@ -1958,7 +2002,7 @@
                 
                 # save the info for later use
                 self.project.setDbgInfo(
-                    argv, wd, env, exceptions, self.excList,
+                    interpreter, argv, wd, env, exceptions, self.excList,
                     self.excIgnoreList, clearShell, tracePython=tracePython,
                     autoContinue=self.autoContinue)
                 
@@ -1985,6 +2029,7 @@
             
             # This moves any previous occurrence of these arguments to the head
             # of the list.
+            self.setInterpreterHistory(interpreter)
             self.setArgvHistory(argv)
             self.setWdHistory(wd)
             self.setEnvHistory(env)
@@ -2027,7 +2072,7 @@
                 
                 # Ask the client to open the new program.
                 self.debugServer.remoteLoad(
-                    fn, argv, wd, env,
+                    interpreter, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell,
                     tracePython=tracePython,
                     autoContinue=autoContinue, forProject=debugProject,
@@ -2041,11 +2086,14 @@
                 self.stopAct.setEnabled(True)
         
         if dlg.clearHistories():
+            self.setInterpreterHistory("", clearHistories=True)
             self.setArgvHistory("", clearHistories=True)
             self.setWdHistory("", clearHistories=True)
             self.setEnvHistory("", clearHistories=True)
         elif dlg.historiesModified():
-            argvHistory, wdHistory, envHistory = dlg.getHistories()
+            argvHistory, wdHistory, envHistory, interpreterHistory = \
+                dlg.getHistories()
+            self.setInterpreterHistory("", history=interpreterHistory)
             self.setArgvHistory("", history=argvHistory)
             self.setWdHistory("", history=wdHistory)
             self.setEnvHistory("", history=envHistory)
@@ -2076,6 +2124,7 @@
             return      # should not happen
                     
         # get the saved stuff
+        interpreter = self.interpreterHistory[0]
         wd = self.wdHistory[0]
         argv = self.argvHistory[0]
         fn = self.lastDebuggedFile
@@ -2100,7 +2149,7 @@
                 
                 # Ask the client to debug the new program.
                 self.debugServer.remoteLoad(
-                    fn, argv, wd, env,
+                    interpreter, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell,
                     tracePython=self.tracePython,
                     autoContinue=self.autoContinue,
@@ -2117,7 +2166,7 @@
             elif self.lastStartAction in [3, 4]:
                 # Ask the client to run the new program.
                 self.debugServer.remoteRun(
-                    fn, argv, wd, env,
+                    interpreter, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell,
                     forProject=forProject,
                     runInConsole=self.runInConsole,
@@ -2128,7 +2177,7 @@
             elif self.lastStartAction in [5, 6]:
                 # Ask the client to coverage run the new program.
                 self.debugServer.remoteCoverage(
-                    fn, argv, wd, env,
+                    interpreter, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell,
                     erase=self.eraseCoverage,
                     forProject=forProject,
@@ -2138,7 +2187,7 @@
             elif self.lastStartAction in [7, 8]:
                 # Ask the client to profile run the new program.
                 self.debugServer.remoteProfile(
-                    fn, argv, wd, env,
+                    interpreter, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell,
                     erase=self.eraseTimings,
                     forProject=forProject,

eric ide

mercurial