eric6/QScintilla/Shell.py

branch
multi_processing
changeset 7389
770ffcb88be5
parent 7386
3de001de249c
child 7408
0d58e708f57b
diff -r 3de001de249c -r 770ffcb88be5 eric6/QScintilla/Shell.py
--- a/eric6/QScintilla/Shell.py	Sun Feb 02 12:01:27 2020 +0100
+++ b/eric6/QScintilla/Shell.py	Sun Feb 02 16:41:40 2020 +0100
@@ -610,8 +610,10 @@
         """
         self.buff = ""
         self.inContinue = False
-        self.inRawMode = False
-        self.echoInput = True
+        self.__inRawMode = False
+        self.__echoInput = True
+        self.__rawModeDebuggerId = None
+        self.__rawModeQueue = []
         self.clientCapabilities = 0
         self.inCommandExecution = False
         self.interruptCommandExecution = False
@@ -865,7 +867,7 @@
         @param more flag indicating that more user input is required
         @type bool
         """
-        if not self.inRawMode:
+        if not self.__inRawMode:
             self.inContinue = more
             self.__writePrompt()
         self.inCommandExecution = False
@@ -993,6 +995,12 @@
         QApplication.processEvents()
         
         # Finally process the accumulated text
+        self.__flushQueuedText()
+    
+    def __flushQueuedText(self):
+        """
+        Private slot to flush the accumulated text output.
+        """
         self.__write(self.__queuedText)
         
         self.__queuedText = ''
@@ -1001,7 +1009,7 @@
         # little trick to get the cursor position registered within QScintilla
         self.SendScintilla(QsciScintilla.SCI_CHARLEFT)
         self.SendScintilla(QsciScintilla.SCI_CHARRIGHT)
-
+    
     def __write(self, s):
         """
         Private method to display some text without queuing.
@@ -1032,30 +1040,41 @@
         """
         self.__write(self.tr("StdErr: {0}").format(s))
         
-    def __raw_input(self, s, echo):
+    def __raw_input(self, prompt, echo, debuggerId):
         """
         Private method to handle raw input.
         
-        @param s prompt to be displayed (string)
-        @param echo Flag indicating echoing of the input (boolean)
+        @param prompt the input prompt
+        @type str
+        @param echo flag indicating an echoing of the input
+        @type bool
+        @param debuggerId ID of the debugger backend
+        @type str
         """
-        # Get all text which is still waiting for output
-        QApplication.processEvents()
-        
-        self.setFocus()
-        self.inRawMode = True
-        self.echoInput = echo
-        self.__writeQueued(s)
-        line, col = self.__getEndPos()
-        self.setCursorPosition(line, col)
-        buf = self.text(line)
-        if buf.startswith(sys.ps1):
-            buf = buf.replace(sys.ps1, "")
-        if buf.startswith(sys.ps2):
-            buf = buf.replace(sys.ps2, "")
-        self.prompt = buf
-        # move cursor to end of line
-        self.moveCursorToEOL()
+        if self.__inRawMode:
+            # we are processing another raw input event already
+            self.__rawModeQueue.append((debuggerId, prompt, echo))
+        else:
+            self.setFocus()
+            self.__inRawMode = True
+            self.__echoInput = echo
+            self.__rawModeDebuggerId = debuggerId
+            
+            # Get all text which is still waiting for output
+            QApplication.processEvents()
+            self.__flushQueuedText()
+            
+            self.__write(self.tr("<{0}> {1}").format(debuggerId, prompt))
+            line, col = self.__getEndPos()
+            self.setCursorPosition(line, col)
+            buf = self.text(line)
+            if buf.startswith(sys.ps1):
+                buf = buf.replace(sys.ps1, "")
+            if buf.startswith(sys.ps2):
+                buf = buf.replace(sys.ps2, "")
+            self.prompt = buf
+            # move cursor to end of line
+            self.moveCursorToEOL()
         
     def paste(self):
         """
@@ -1311,7 +1330,7 @@
                 line, col = self.__getEndPos()
                 self.setCursorPosition(line, col)
                 self.prline, self.prcol = self.getCursorPosition()
-            if self.echoInput:
+            if self.__echoInput:
                 ac = self.isListActive()
                 super(Shell, self).keyPressEvent(ev)
                 self.incrementalSearchActive = True
@@ -1753,7 +1772,7 @@
         @param historyIndex history index to be set
         @type int
         """
-        if not self.inRawMode:
+        if not self.__inRawMode:
             self.inCommandExecution = True
             self.interruptCommandExecution = False
             if not cmd:
@@ -1853,15 +1872,19 @@
                 except KeyboardInterrupt:
                     pass
         else:
-            if not self.echoInput:
+            if not self.__echoInput:
                 cmd = self.buff
                 self.buff = ""
             elif cmd:
                 cmd = cmd[len(self.prompt):]
-            self.inRawMode = False
-            self.echoInput = True
+            self.__inRawMode = False
+            self.__echoInput = True
             
-            self.dbs.remoteRawInput(cmd)
+            self.dbs.remoteRawInput(self.__rawModeDebuggerId, cmd)
+            
+            if self.__rawModeQueue:
+                debuggerId, prompt, echo = self.__rawModeQueue.pop(0)
+                self.__raw_input(prompt, echo, debuggerId)
     
     def __showVenvName(self):
         """

eric ide

mercurial