56 |
56 |
57 self.__shell = Shell(dbs, vm, project, False, self) |
57 self.__shell = Shell(dbs, vm, project, False, self) |
58 |
58 |
59 from UI.SearchWidget import SearchWidget |
59 from UI.SearchWidget import SearchWidget |
60 self.__searchWidget = SearchWidget(self.__shell, self, horizontal) |
60 self.__searchWidget = SearchWidget(self.__shell, self, horizontal) |
61 self.__searchWidget.setSizePolicy(QSizePolicy.Fixed, |
61 self.__searchWidget.setSizePolicy(QSizePolicy.Policy.Fixed, |
62 QSizePolicy.Preferred) |
62 QSizePolicy.Policy.Preferred) |
63 self.__searchWidget.hide() |
63 self.__searchWidget.hide() |
64 |
64 |
65 if horizontal: |
65 if horizontal: |
66 self.__layout = QHBoxLayout(self) |
66 self.__layout = QHBoxLayout(self) |
67 else: |
67 else: |
163 """ using the up and down cursor keys while holding down the""" |
163 """ using the up and down cursor keys while holding down the""" |
164 """ Ctrl-key. This can be switched to just the up and down""" |
164 """ Ctrl-key. This can be switched to just the up and down""" |
165 """ cursor keys on the Shell page of the configuration""" |
165 """ cursor keys on the Shell page of the configuration""" |
166 """ dialog. Pressing these keys after some text has been""" |
166 """ dialog. Pressing these keys after some text has been""" |
167 """ entered will start an incremental search.</p>""" |
167 """ entered will start an incremental search.</p>""" |
168 """<p>The shell has some special commands. 'restart' kills""" |
168 """<p>The shell has some special commands. '%restart' kills""" |
169 """ the shell and starts a new one. 'clear' clears the""" |
169 """ the shell and starts a new one. '%clear' clears the""" |
170 """ display of the shell window. 'start' is used to start a""" |
170 """ display of the shell window. '%start' is used to start a""" |
171 """ shell for a virtual environment and should be followed""" |
171 """ shell for a virtual environment and should be followed""" |
172 """ by a virtual environment name. start' without a virtual""" |
172 """ by a virtual environment name. '%start' without a""" |
173 """ environment name starts the default shell. Available""" |
173 """ virtual environment name starts the default shell.""" |
174 """ virtual environments may be listed with the 'envs' or""" |
174 """ Available virtual environments may be listed with the""" |
175 """ 'environments' commands. The active virtual environment""" |
175 """ '%envs' or '%environments' commands. The active virtual""" |
176 """ can be questioned by the 'which' command. 'quit' or""" |
176 """ environment can be questioned by the '%which' command.""" |
177 """ 'exit' is used to exit the application. These commands""" |
177 """ '%quit' or '%exit' is used to exit the application.""" |
178 """ (except environments', 'envs' and 'which') are available""" |
178 """ These commands (except '%environments', '%envs' and""" |
179 """ through the window menus as well.</p>""" |
179 """ '%which') are available through the window menus as""" |
|
180 """ well.</p>""" |
180 """<p>Pressing the Tab key after some text has been entered""" |
181 """<p>Pressing the Tab key after some text has been entered""" |
181 """ will show a list of possible completions. The relevant""" |
182 """ will show a list of possible completions. The relevant""" |
182 """ entry may be selected from this list. If only one entry""" |
183 """ entry may be selected from this list. If only one entry""" |
183 """ is available, this will be inserted automatically.</p>""" |
184 """ is available, this will be inserted automatically.</p>""" |
184 )) |
185 )) |
194 """ using the up and down cursor keys while holding down the""" |
195 """ using the up and down cursor keys while holding down the""" |
195 """ Ctrl-key. This can be switched to just the up and down""" |
196 """ Ctrl-key. This can be switched to just the up and down""" |
196 """ cursor keys on the Shell page of the configuration""" |
197 """ cursor keys on the Shell page of the configuration""" |
197 """ dialog. Pressing these keys after some text has been""" |
198 """ dialog. Pressing these keys after some text has been""" |
198 """ entered will start an incremental search.</p>""" |
199 """ entered will start an incremental search.</p>""" |
199 """<p>The shell has some special commands. 'restart' kills""" |
200 """<p>The shell has some special commands. '%restart' kills""" |
200 """ the shell and starts a new one. 'clear' clears the""" |
201 """ the shell and starts a new one. '%clear' clears the""" |
201 """ display of the shell window. 'start' is used to start a""" |
202 """ display of the shell window. '%start' is used to start a""" |
202 """ shell for a virtual environment and should be followed""" |
203 """ shell for a virtual environment and should be followed""" |
203 """ by a virtual environment name. start' without a virtual""" |
204 """ by a virtual environment name. '%start' without a""" |
204 """ environment name starts the default shell. Available""" |
205 """ virtual environment name starts the default shell.""" |
205 """ virtual environments may be listed with the 'envs' or""" |
206 """ Available virtual environments may be listed with the""" |
206 """ 'environments' commands. The active virtual environment""" |
207 """ '%envs' or '%environments' commands. The active virtual""" |
207 """ can be questioned by the 'which' command. These commands""" |
208 """ environment can be questioned by the '%which' command.""" |
208 """ (except environments' and 'envs') are available through""" |
209 """ These commands (except '%environments' and '%envs') are""" |
209 """ the context menu as well.</p>""" |
210 """ available through the context menu as well.</p>""" |
210 """<p>Pressing the Tab key after some text has been entered""" |
211 """<p>Pressing the Tab key after some text has been entered""" |
211 """ will show a list of possible completions. The relevant""" |
212 """ will show a list of possible completions. The relevant""" |
212 """ entry may be selected from this list. If only one entry""" |
213 """ entry may be selected from this list. If only one entry""" |
213 """ is available, this will be inserted automatically.</p>""" |
214 """ is available, this will be inserted automatically.</p>""" |
214 """<p>In passive debugging mode the shell is only available""" |
215 """<p>In passive debugging mode the shell is only available""" |
372 Preferences.getShell("HistoryNavigateByCursor") |
373 Preferences.getShell("HistoryNavigateByCursor") |
373 ) |
374 ) |
374 |
375 |
375 self.__queuedText = '' |
376 self.__queuedText = '' |
376 self.__blockTextProcessing = False |
377 self.__blockTextProcessing = False |
377 self.queueText.connect(self.__concatenateText, Qt.QueuedConnection) |
378 self.queueText.connect(self.__concatenateText, |
|
379 Qt.ConnectionType.QueuedConnection) |
378 |
380 |
379 self.__project = project |
381 self.__project = project |
380 if self.__project: |
382 if self.__project: |
381 self.__project.projectOpened.connect(self.__projectOpened) |
383 self.__project.projectOpened.connect(self.__projectOpened) |
382 self.__project.projectClosed.connect(self.__projectClosed) |
384 self.__project.projectClosed.connect(self.__projectClosed) |
383 |
385 |
384 self.grabGesture(Qt.PinchGesture) |
386 self.grabGesture(Qt.GestureType.PinchGesture) |
385 |
387 |
386 def __showStartMenu(self): |
388 def __showStartMenu(self): |
387 """ |
389 """ |
388 Private slot to prepare the start submenu. |
390 Private slot to prepare the start submenu. |
389 """ |
391 """ |
489 Preferences.getEditor("WhitespaceSize")) |
492 Preferences.getEditor("WhitespaceSize")) |
490 except AttributeError: |
493 except AttributeError: |
491 # QScintilla before 2.5 doesn't support this |
494 # QScintilla before 2.5 doesn't support this |
492 pass |
495 pass |
493 else: |
496 else: |
494 self.setWhitespaceVisibility(QsciScintilla.WsInvisible) |
497 self.setWhitespaceVisibility( |
|
498 QsciScintilla.WhitespaceVisibility.WsInvisible) |
495 self.setEolVisibility(Preferences.getEditor("ShowEOL")) |
499 self.setEolVisibility(Preferences.getEditor("ShowEOL")) |
496 if Preferences.getEditor("BraceHighlighting"): |
500 if Preferences.getEditor("BraceHighlighting"): |
497 self.setBraceMatching(QsciScintilla.SloppyBraceMatch) |
501 self.setBraceMatching(QsciScintilla.BraceMatch.SloppyBraceMatch) |
498 else: |
502 else: |
499 self.setBraceMatching(QsciScintilla.NoBraceMatch) |
503 self.setBraceMatching(QsciScintilla.BraceMatch.NoBraceMatch) |
500 self.setMatchedBraceForegroundColor( |
504 self.setMatchedBraceForegroundColor( |
501 Preferences.getEditorColour("MatchingBrace")) |
505 Preferences.getEditorColour("MatchingBrace")) |
502 self.setMatchedBraceBackgroundColor( |
506 self.setMatchedBraceBackgroundColor( |
503 Preferences.getEditorColour("MatchingBraceBack")) |
507 Preferences.getEditorColour("MatchingBraceBack")) |
504 self.setUnmatchedBraceForegroundColor( |
508 self.setUnmatchedBraceForegroundColor( |
508 if Preferences.getEditor("CustomSelectionColours"): |
512 if Preferences.getEditor("CustomSelectionColours"): |
509 self.setSelectionBackgroundColor( |
513 self.setSelectionBackgroundColor( |
510 Preferences.getEditorColour("SelectionBackground")) |
514 Preferences.getEditorColour("SelectionBackground")) |
511 else: |
515 else: |
512 self.setSelectionBackgroundColor( |
516 self.setSelectionBackgroundColor( |
513 QApplication.palette().color(QPalette.Highlight)) |
517 QApplication.palette().color(QPalette.ColorRole.Highlight)) |
514 if Preferences.getEditor("ColourizeSelText"): |
518 if Preferences.getEditor("ColourizeSelText"): |
515 self.resetSelectionForegroundColor() |
519 self.resetSelectionForegroundColor() |
516 elif Preferences.getEditor("CustomSelectionColours"): |
520 elif Preferences.getEditor("CustomSelectionColours"): |
517 self.setSelectionForegroundColor( |
521 self.setSelectionForegroundColor( |
518 Preferences.getEditorColour("SelectionForeground")) |
522 Preferences.getEditorColour("SelectionForeground")) |
519 else: |
523 else: |
520 self.setSelectionForegroundColor( |
524 self.setSelectionForegroundColor( |
521 QApplication.palette().color(QPalette.HighlightedText)) |
525 QApplication.palette().color( |
|
526 QPalette.ColorRole.HighlightedText)) |
522 self.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol")) |
527 self.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol")) |
523 self.setCaretForegroundColor( |
528 self.setCaretForegroundColor( |
524 Preferences.getEditorColour("CaretForeground")) |
529 Preferences.getEditorColour("CaretForeground")) |
525 self.setCaretLineVisible(False) |
530 self.setCaretLineVisible(False) |
526 self.caretWidth = Preferences.getEditor("CaretWidth") |
531 self.caretWidth = Preferences.getEditor("CaretWidth") |
527 self.setCaretWidth(self.caretWidth) |
532 self.setCaretWidth(self.caretWidth) |
528 if Preferences.getShell("WrapEnabled"): |
533 if Preferences.getShell("WrapEnabled"): |
529 self.setWrapMode(QsciScintilla.WrapWord) |
534 self.setWrapMode(QsciScintilla.WrapMode.WrapWord) |
530 else: |
535 else: |
531 self.setWrapMode(QsciScintilla.WrapNone) |
536 self.setWrapMode(QsciScintilla.WrapMode.WrapNone) |
532 self.useMonospaced = Preferences.getShell("UseMonospacedFont") |
537 self.useMonospaced = Preferences.getShell("UseMonospacedFont") |
533 self.__setMonospaced(self.useMonospaced) |
538 self.__setMonospaced(self.useMonospaced) |
534 |
539 |
535 self.setCursorFlashTime(QApplication.cursorFlashTime()) |
540 self.setCursorFlashTime(QApplication.cursorFlashTime()) |
536 |
541 |
584 Preferences.getEditorColour("CallTipsForeground")) |
589 Preferences.getEditorColour("CallTipsForeground")) |
585 self.setCallTipsHighlightColor( |
590 self.setCallTipsHighlightColor( |
586 Preferences.getEditorColour("CallTipsHighlight")) |
591 Preferences.getEditorColour("CallTipsHighlight")) |
587 self.setCallTipsVisible(Preferences.getEditor("CallTipsVisible")) |
592 self.setCallTipsVisible(Preferences.getEditor("CallTipsVisible")) |
588 calltipsStyle = Preferences.getEditor("CallTipsStyle") |
593 calltipsStyle = Preferences.getEditor("CallTipsStyle") |
589 if calltipsStyle == QsciScintilla.CallTipsNoContext: |
594 if calltipsStyle == QsciScintilla.CallTipsStyle.CallTipsNoContext: |
590 self.setCallTipsStyle(QsciScintilla.CallTipsNoContext) |
595 self.setCallTipsStyle( |
|
596 QsciScintilla.CallTipsStyle.CallTipsNoContext) |
591 elif ( |
597 elif ( |
592 calltipsStyle == |
598 calltipsStyle == |
593 QsciScintilla.CallTipsNoAutoCompletionContext |
599 QsciScintilla.CallTipsStyle.CallTipsNoAutoCompletionContext |
594 ): |
600 ): |
595 self.setCallTipsStyle( |
601 self.setCallTipsStyle( |
596 QsciScintilla.CallTipsNoAutoCompletionContext) |
602 QsciScintilla.CallTipsStyle |
|
603 .CallTipsNoAutoCompletionContext) |
597 else: |
604 else: |
598 self.setCallTipsStyle(QsciScintilla.CallTipsContext) |
605 self.setCallTipsStyle( |
599 else: |
606 QsciScintilla.CallTipsStyle.CallTipsContext) |
600 self.setCallTipsStyle(QsciScintilla.CallTipsNone) |
607 else: |
|
608 self.setCallTipsStyle(QsciScintilla.CallTipsStyle.CallTipsNone) |
601 |
609 |
602 def setDebuggerUI(self, ui): |
610 def setDebuggerUI(self, ui): |
603 """ |
611 """ |
604 Public method to set the debugger UI. |
612 Public method to set the debugger UI. |
605 |
613 |
784 """ |
792 """ |
785 Public slot to show the shell history dialog. |
793 Public slot to show the shell history dialog. |
786 """ |
794 """ |
787 from .ShellHistoryDialog import ShellHistoryDialog |
795 from .ShellHistoryDialog import ShellHistoryDialog |
788 dlg = ShellHistoryDialog(self.__history, self.vm, self) |
796 dlg = ShellHistoryDialog(self.__history, self.vm, self) |
789 if dlg.exec() == QDialog.Accepted: |
797 if dlg.exec() == QDialog.DialogCode.Accepted: |
790 self.__historyLists[self.clientType], idx = dlg.getHistory() |
798 self.__historyLists[self.clientType], idx = dlg.getHistory() |
791 self.__history = self.__historyLists[self.clientType] |
799 self.__history = self.__historyLists[self.clientType] |
792 self.__setHistoryIndex(index=idx) |
800 self.__setHistoryIndex(index=idx) |
793 |
801 |
794 def clearAllHistories(self): |
802 def clearAllHistories(self): |
1230 Protected method to handle the mouse press event. |
1238 Protected method to handle the mouse press event. |
1231 |
1239 |
1232 @param event the mouse press event (QMouseEvent) |
1240 @param event the mouse press event (QMouseEvent) |
1233 """ |
1241 """ |
1234 self.setFocus() |
1242 self.setFocus() |
1235 if event.button() == Qt.MidButton: |
1243 if event.button() == Qt.MouseButton.MidButton: |
1236 lines = QApplication.clipboard().text(QClipboard.Selection) |
1244 lines = QApplication.clipboard().text(QClipboard.Mode.Selection) |
1237 self.paste(lines) |
1245 self.paste(lines) |
1238 else: |
1246 else: |
1239 super(Shell, self).mousePressEvent(event) |
1247 super(Shell, self).mousePressEvent(event) |
1240 |
1248 |
1241 def wheelEvent(self, evt): |
1249 def wheelEvent(self, evt): |
1242 """ |
1250 """ |
1243 Protected method to handle wheel events. |
1251 Protected method to handle wheel events. |
1244 |
1252 |
1245 @param evt reference to the wheel event (QWheelEvent) |
1253 @param evt reference to the wheel event (QWheelEvent) |
1246 """ |
1254 """ |
1247 if evt.modifiers() & Qt.ControlModifier: |
1255 if evt.modifiers() & Qt.KeyboardModifier.ControlModifier: |
1248 delta = evt.angleDelta().y() |
1256 delta = evt.angleDelta().y() |
1249 if delta < 0: |
1257 if delta < 0: |
1250 self.zoomOut() |
1258 self.zoomOut() |
1251 elif delta > 0: |
1259 elif delta > 0: |
1252 self.zoomIn() |
1260 self.zoomIn() |
1801 ): |
1809 ): |
1802 self.__setHistoryIndex(index=-1) |
1810 self.__setHistoryIndex(index=-1) |
1803 else: |
1811 else: |
1804 self.__setHistoryIndex(historyIndex) |
1812 self.__setHistoryIndex(historyIndex) |
1805 |
1813 |
1806 if cmd == 'start' or cmd.startswith('start '): |
1814 if cmd.startswith("%"): |
1807 if not self.passive: |
1815 if cmd == '%start' or cmd.startswith('%start '): |
1808 cmdList = cmd.split(None, 1) |
1816 if not self.passive: |
1809 if len(cmdList) < 2: |
1817 cmdList = cmd.split(None, 1) |
1810 self.dbs.startClient(False) # start default backend |
1818 if len(cmdList) < 2: |
|
1819 self.dbs.startClient(False) |
|
1820 # start default backend |
|
1821 else: |
|
1822 venvName = cmdList[1] |
|
1823 if venvName == self.tr("Project"): |
|
1824 if self.__project.isOpen(): |
|
1825 self.dbs.startClient( |
|
1826 False, |
|
1827 forProject=True, |
|
1828 workingDir=self.__project |
|
1829 .getProjectPath() |
|
1830 ) |
|
1831 self.__currentWorkingDirectory = ( |
|
1832 self.__project.getProjectPath() |
|
1833 ) |
|
1834 else: |
|
1835 self.dbs.startClient( |
|
1836 False, |
|
1837 venvName=self.__currentVenv, |
|
1838 workingDir=self |
|
1839 .__currentWorkingDirectory |
|
1840 ) |
|
1841 # same as reset |
|
1842 else: |
|
1843 self.dbs.startClient(False, venvName=venvName) |
|
1844 self.__currentWorkingDirectory = "" |
|
1845 self.__getBanner() |
|
1846 return |
|
1847 elif cmd == '%clear': |
|
1848 # Display the banner. |
|
1849 self.__getBanner() |
|
1850 if not self.passive: |
|
1851 return |
1811 else: |
1852 else: |
1812 venvName = cmdList[1] |
1853 cmd = '' |
1813 if venvName == self.tr("Project"): |
1854 elif cmd in ['%reset', '%restart']: |
1814 if self.__project.isOpen(): |
1855 self.dbs.startClient( |
1815 self.dbs.startClient( |
1856 False, venvName=self.__currentVenv, |
1816 False, forProject=True, |
1857 workingDir=self.__currentWorkingDirectory) |
1817 workingDir=self.__project.getProjectPath()) |
1858 if self.passive: |
1818 self.__currentWorkingDirectory = ( |
1859 return |
1819 self.__project.getProjectPath() |
1860 else: |
1820 ) |
1861 cmd = '' |
1821 else: |
1862 elif cmd in ['%envs', '%environments']: |
1822 self.dbs.startClient( |
1863 venvs = ( |
1823 False, venvName=self.__currentVenv, |
1864 e5App().getObject("VirtualEnvManager") |
1824 workingDir=self.__currentWorkingDirectory) |
1865 .getVirtualenvNames() |
1825 # same as reset |
1866 ) |
1826 else: |
1867 s = ( |
1827 self.dbs.startClient(False, venvName=venvName) |
1868 self.tr('Available Virtual Environments:\n{0}\n') |
1828 self.__currentWorkingDirectory = "" |
1869 .format('\n'.join( |
1829 self.__getBanner() |
1870 "- {0}".format(venv) |
|
1871 for venv in sorted(venvs) |
|
1872 )) |
|
1873 ) |
|
1874 self.__write(s) |
|
1875 self.__clientStatement(False) |
1830 return |
1876 return |
1831 elif cmd == 'clear': |
1877 elif cmd == '%which': |
1832 # Display the banner. |
1878 s = self.tr("Current Virtual Environment: '{0}'\n").format( |
1833 self.__getBanner() |
1879 self.__currentVenv) |
1834 if not self.passive: |
1880 self.__write(s) |
|
1881 self.__clientStatement(False) |
1835 return |
1882 return |
1836 else: |
1883 elif ( |
1837 cmd = '' |
1884 cmd in ["%quit", "%quit()", "%exit", "%exit()"] and |
1838 elif cmd in ['reset', 'restart']: |
1885 self.__windowed |
1839 self.dbs.startClient(False, venvName=self.__currentVenv, |
1886 ): |
1840 workingDir=self.__currentWorkingDirectory) |
1887 # call main window quit() |
1841 if self.passive: |
1888 self.vm.quit() |
1842 return |
1889 return |
1843 else: |
1890 else: |
1844 cmd = '' |
1891 self.dbs.remoteStatement( |
1845 elif cmd in ['envs', 'environments']: |
1892 self.__debugUI.getSelectedDebuggerId(), cmd) |
1846 venvs = ( |
1893 while self.inCommandExecution: |
1847 e5App().getObject("VirtualEnvManager") |
1894 try: |
1848 .getVirtualenvNames() |
1895 QApplication.processEvents() |
1849 ) |
1896 except KeyboardInterrupt: |
1850 s = self.tr('Available Virtual Environments:\n{0}\n').format( |
1897 pass |
1851 '\n'.join("- {0}".format(venv) for venv in sorted(venvs)) |
|
1852 ) |
|
1853 self.__write(s) |
|
1854 self.__clientStatement(False) |
|
1855 return |
|
1856 elif cmd == 'which': |
|
1857 s = self.tr("Current Virtual Environment: '{0}'\n").format( |
|
1858 self.__currentVenv) |
|
1859 self.__write(s) |
|
1860 self.__clientStatement(False) |
|
1861 return |
|
1862 elif ( |
|
1863 cmd in ["quit", "quit()", "exit", "exit()"] and |
|
1864 self.__windowed |
|
1865 ): |
|
1866 # call main window quit() |
|
1867 self.vm.quit() |
|
1868 return |
|
1869 |
|
1870 self.dbs.remoteStatement(self.__debugUI.getSelectedDebuggerId(), |
|
1871 cmd) |
|
1872 while self.inCommandExecution: |
|
1873 try: |
|
1874 QApplication.processEvents() |
|
1875 except KeyboardInterrupt: |
|
1876 pass |
|
1877 else: |
1898 else: |
1878 if not self.__echoInput: |
1899 if not self.__echoInput: |
1879 cmd = self.buff |
1900 cmd = self.buff |
1880 self.buff = "" |
1901 self.buff = "" |
1881 elif cmd: |
1902 elif cmd: |