176 # Initialize history |
176 # Initialize history |
177 self.historyLists = {} |
177 self.historyLists = {} |
178 self.maxHistoryEntries = Preferences.getShell("MaxHistoryEntries") |
178 self.maxHistoryEntries = Preferences.getShell("MaxHistoryEntries") |
179 self.history = [] |
179 self.history = [] |
180 self.histidx = -1 |
180 self.histidx = -1 |
|
181 # remove obsolete shell histories (Python and Ruby) |
|
182 for clientType in ["Python", "Ruby"]: |
|
183 Preferences.Prefs.settings.remove("Shell/Histories/" + clientType) |
181 |
184 |
182 self.clientType = '' |
185 self.clientType = '' |
183 |
186 |
184 # clear QScintilla defined keyboard commands |
187 # clear QScintilla defined keyboard commands |
185 # we do our own handling through the view manager |
188 # we do our own handling through the view manager |
300 |
303 |
301 def closeShell(self): |
304 def closeShell(self): |
302 """ |
305 """ |
303 Public method to shutdown the shell. |
306 Public method to shutdown the shell. |
304 """ |
307 """ |
305 for key in list(self.historyLists.keys()): |
308 for clientType in self.historyLists: |
306 self.saveHistory(key) |
309 self.saveHistory(clientType) |
307 |
310 |
308 def __bindLexer(self, language='Python3'): |
311 def __bindLexer(self, language='Python3'): |
309 """ |
312 """ |
310 Private slot to set the lexer. |
313 Private slot to set the lexer. |
311 |
314 |
576 |
579 |
577 def __clearHistory(self): |
580 def __clearHistory(self): |
578 """ |
581 """ |
579 Private slot to clear the current history. |
582 Private slot to clear the current history. |
580 """ |
583 """ |
581 self.history = [] |
584 if self.clientType: |
|
585 self.historyLists[self.clientType] = [] |
|
586 self.history = self.historyLists[self.clientType] |
|
587 else: |
|
588 self.history = [] |
|
589 self.histidx = -1 |
582 |
590 |
583 def __selectHistory(self): |
591 def __selectHistory(self): |
584 """ |
592 """ |
585 Private slot to select a history entry to execute. |
593 Private slot to select a history entry to execute. |
586 """ |
594 """ |
602 dlg = ShellHistoryDialog(self.history, self.vm, self) |
610 dlg = ShellHistoryDialog(self.history, self.vm, self) |
603 if dlg.exec_() == QDialog.Accepted: |
611 if dlg.exec_() == QDialog.Accepted: |
604 self.historyLists[self.clientType] = dlg.getHistory() |
612 self.historyLists[self.clientType] = dlg.getHistory() |
605 self.history = self.historyLists[self.clientType] |
613 self.history = self.historyLists[self.clientType] |
606 self.histidx = -1 |
614 self.histidx = -1 |
|
615 |
|
616 def clearAllHistories(self): |
|
617 """ |
|
618 Public method to clear all available histories and sync them. |
|
619 """ |
|
620 Preferences.Prefs.settings.beginGroup("Shell/Histories") |
|
621 for clientType in Preferences.Prefs.settings.childKeys(): |
|
622 self.historyLists[clientType] = [] |
|
623 self.saveHistory(clientType) |
|
624 Preferences.Prefs.settings.endGroup() |
|
625 |
|
626 self.__clearHistory() |
607 |
627 |
608 def getClientType(self): |
628 def getClientType(self): |
609 """ |
629 """ |
610 Public slot to get the clients type. |
630 Public slot to get the clients type. |
611 |
631 |