eric6/QScintilla/Shell.py

changeset 8146
db2d19af4675
parent 8143
2c730d5fd177
child 8169
139bd30c52c2
--- a/eric6/QScintilla/Shell.py	Tue Mar 02 19:22:12 2021 +0100
+++ b/eric6/QScintilla/Shell.py	Tue Mar 02 19:49:43 2021 +0100
@@ -165,18 +165,19 @@
                 """ cursor keys on the Shell page of the configuration"""
                 """ dialog. Pressing these keys after some text has been"""
                 """ entered will start an incremental search.</p>"""
-                """<p>The shell has some special commands. 'restart' kills"""
-                """ the shell and starts a new one. 'clear' clears the"""
-                """ display of the shell window. 'start' is used to start a"""
+                """<p>The shell has some special commands. '%restart' kills"""
+                """ the shell and starts a new one. '%clear' clears the"""
+                """ display of the shell window. '%start' is used to start a"""
                 """ shell for a virtual environment and should be followed"""
-                """ by a virtual environment name. start' without a virtual"""
-                """ environment name starts the default shell. Available"""
-                """ virtual environments may be listed with the 'envs' or"""
-                """ 'environments' commands. The active virtual environment"""
-                """ can be questioned by the 'which' command. 'quit' or"""
-                """ 'exit' is used to exit the application. These commands"""
-                """ (except environments', 'envs' and 'which') are available"""
-                """ through the window menus as well.</p>"""
+                """ by a virtual environment name. '%start' without a"""
+                """ virtual environment name starts the default shell."""
+                """ Available virtual environments may be listed with the"""
+                """ '%envs' or '%environments' commands. The active virtual"""
+                """ environment can be questioned by the '%which' command."""
+                """ '%quit' or '%exit' is used to exit the application."""
+                """ These commands (except '%environments', '%envs' and"""
+                """ '%which') are available through the window menus as"""
+                """ well.</p>"""
                 """<p>Pressing the Tab key after some text has been entered"""
                 """ will show a list of possible completions. The relevant"""
                 """ entry may be selected from this list. If only one entry"""
@@ -196,17 +197,17 @@
                 """ cursor keys on the Shell page of the configuration"""
                 """ dialog. Pressing these keys after some text has been"""
                 """ entered will start an incremental search.</p>"""
-                """<p>The shell has some special commands. 'restart' kills"""
-                """ the shell and starts a new one. 'clear' clears the"""
-                """ display of the shell window. 'start' is used to start a"""
+                """<p>The shell has some special commands. '%restart' kills"""
+                """ the shell and starts a new one. '%clear' clears the"""
+                """ display of the shell window. '%start' is used to start a"""
                 """ shell for a virtual environment and should be followed"""
-                """ by a virtual environment name. start' without a virtual"""
-                """ environment name starts the default shell. Available"""
-                """ virtual environments may be listed with the 'envs' or"""
-                """ 'environments' commands. The active virtual environment"""
-                """ can be questioned by the 'which' command. These commands"""
-                """ (except environments' and 'envs') are available through"""
-                """ the context menu as well.</p>"""
+                """ by a virtual environment name. '%start' without a"""
+                """ virtual environment name starts the default shell."""
+                """ Available virtual environments may be listed with the"""
+                """ '%envs' or '%environments' commands. The active virtual"""
+                """ environment can be questioned by the '%which' command."""
+                """ These commands (except '%environments' and '%envs') are"""
+                """ available through the context menu as well.</p>"""
                 """<p>Pressing the Tab key after some text has been entered"""
                 """ will show a list of possible completions. The relevant"""
                 """ entry may be selected from this list. If only one entry"""
@@ -1810,77 +1811,90 @@
                     else:
                         self.__setHistoryIndex(historyIndex)
             
-            if cmd == 'start' or cmd.startswith('start '):
-                if not self.passive:
-                    cmdList = cmd.split(None, 1)
-                    if len(cmdList) < 2:
-                        self.dbs.startClient(False)  # start default backend
+            if cmd.startswith("%"):
+                if cmd == '%start' or cmd.startswith('%start '):
+                    if not self.passive:
+                        cmdList = cmd.split(None, 1)
+                        if len(cmdList) < 2:
+                            self.dbs.startClient(False)
+                            # start default backend
+                        else:
+                            venvName = cmdList[1]
+                            if venvName == self.tr("Project"):
+                                if self.__project.isOpen():
+                                    self.dbs.startClient(
+                                        False,
+                                        forProject=True,
+                                        workingDir=
+                                        self.__project.getProjectPath()
+                                    )
+                                    self.__currentWorkingDirectory = (
+                                        self.__project.getProjectPath()
+                                    )
+                                else:
+                                    self.dbs.startClient(
+                                        False,
+                                        venvName=self.__currentVenv,
+                                        workingDir=
+                                        self.__currentWorkingDirectory
+                                    )
+                                    # same as reset
+                            else:
+                                self.dbs.startClient(False, venvName=venvName)
+                                self.__currentWorkingDirectory = ""
+                        self.__getBanner()
+                        return
+                elif cmd == '%clear':
+                    # Display the banner.
+                    self.__getBanner()
+                    if not self.passive:
+                        return
                     else:
-                        venvName = cmdList[1]
-                        if venvName == self.tr("Project"):
-                            if self.__project.isOpen():
-                                self.dbs.startClient(
-                                    False, forProject=True,
-                                    workingDir=self.__project.getProjectPath())
-                                self.__currentWorkingDirectory = (
-                                    self.__project.getProjectPath()
-                                )
-                            else:
-                                self.dbs.startClient(
-                                    False, venvName=self.__currentVenv,
-                                    workingDir=self.__currentWorkingDirectory)
-                                # same as reset
-                        else:
-                            self.dbs.startClient(False, venvName=venvName)
-                            self.__currentWorkingDirectory = ""
-                    self.__getBanner()
-                    return
-            elif cmd == 'clear':
-                # Display the banner.
-                self.__getBanner()
-                if not self.passive:
+                        cmd = ''
+                elif cmd in ['%reset', '%restart']:
+                    self.dbs.startClient(
+                        False, venvName=self.__currentVenv,
+                        workingDir=self.__currentWorkingDirectory)
+                    if self.passive:
+                        return
+                    else:
+                        cmd = ''
+                elif cmd in ['%envs', '%environments']:
+                    venvs = (
+                        e5App().getObject("VirtualEnvManager")
+                        .getVirtualenvNames()
+                    )
+                    s = (
+                        self.tr('Available Virtual Environments:\n{0}\n')
+                        .format('\n'.join(
+                            "- {0}".format(venv)
+                            for venv in sorted(venvs)
+                        ))
+                    )
+                    self.__write(s)
+                    self.__clientStatement(False)
                     return
-                else:
-                    cmd = ''
-            elif cmd in ['reset', 'restart']:
-                self.dbs.startClient(False, venvName=self.__currentVenv,
-                                     workingDir=self.__currentWorkingDirectory)
-                if self.passive:
+                elif cmd == '%which':
+                    s = self.tr("Current Virtual Environment: '{0}'\n").format(
+                        self.__currentVenv)
+                    self.__write(s)
+                    self.__clientStatement(False)
                     return
-                else:
-                    cmd = ''
-            elif cmd in ['envs', 'environments']:
-                venvs = (
-                    e5App().getObject("VirtualEnvManager")
-                    .getVirtualenvNames()
-                )
-                s = self.tr('Available Virtual Environments:\n{0}\n').format(
-                    '\n'.join("- {0}".format(venv) for venv in sorted(venvs))
-                )
-                self.__write(s)
-                self.__clientStatement(False)
-                return
-            elif cmd == 'which':
-                s = self.tr("Current Virtual Environment: '{0}'\n").format(
-                    self.__currentVenv)
-                self.__write(s)
-                self.__clientStatement(False)
-                return
-            elif (
-                cmd in ["quit", "quit()", "exit", "exit()"] and
-                self.__windowed
-            ):
-                # call main window quit()
-                self.vm.quit()
-                return
-            
-            self.dbs.remoteStatement(self.__debugUI.getSelectedDebuggerId(),
-                                     cmd)
-            while self.inCommandExecution:
-                try:
-                    QApplication.processEvents()
-                except KeyboardInterrupt:
-                    pass
+                elif (
+                    cmd in ["%quit", "%quit()", "%exit", "%exit()"] and
+                    self.__windowed
+                ):
+                    # call main window quit()
+                    self.vm.quit()
+                    return
+            else:
+                self.dbs.remoteStatement(
+                    self.__debugUI.getSelectedDebuggerId(), cmd)
+                while self.inCommandExecution:
+                    try:
+                        QApplication.processEvents()
+                    except KeyboardInterrupt:
+                        pass
         else:
             if not self.__echoInput:
                 cmd = self.buff

eric ide

mercurial