QScintilla/Shell.py

changeset 5108
f5cb9cb98e6a
parent 5020
d0afdfd8e45b
child 5126
d28b92dabc2b
diff -r 1ecc6c9abca5 -r f5cb9cb98e6a QScintilla/Shell.py
--- a/QScintilla/Shell.py	Tue Aug 23 19:02:43 2016 +0200
+++ b/QScintilla/Shell.py	Wed Aug 24 20:00:29 2016 +0200
@@ -178,6 +178,9 @@
         self.maxHistoryEntries = Preferences.getShell("MaxHistoryEntries")
         self.history = []
         self.histidx = -1
+        # remove obsolete shell histories (Python and Ruby)
+        for clientType in ["Python", "Ruby"]:
+            Preferences.Prefs.settings.remove("Shell/Histories/" + clientType)
         
         self.clientType = ''
         
@@ -302,8 +305,8 @@
         """
         Public method to shutdown the shell.
         """
-        for key in list(self.historyLists.keys()):
-            self.saveHistory(key)
+        for clientType in self.historyLists:
+            self.saveHistory(clientType)
         
     def __bindLexer(self, language='Python3'):
         """
@@ -578,7 +581,12 @@
         """
         Private slot to clear the current history.
         """
-        self.history = []
+        if self.clientType:
+            self.historyLists[self.clientType] = []
+            self.history = self.historyLists[self.clientType]
+        else:
+            self.history = []
+        self.histidx = -1
         
     def __selectHistory(self):
         """
@@ -605,6 +613,18 @@
             self.history = self.historyLists[self.clientType]
             self.histidx = -1
         
+    def clearAllHistories(self):
+        """
+        Public method to clear all available histories and sync them.
+        """
+        Preferences.Prefs.settings.beginGroup("Shell/Histories")
+        for clientType in Preferences.Prefs.settings.childKeys():
+            self.historyLists[clientType] = []
+            self.saveHistory(clientType)
+        Preferences.Prefs.settings.endGroup()
+        
+        self.__clearHistory()
+        
     def getClientType(self):
         """
         Public slot to get the clients type.

eric ide

mercurial