eric6/QScintilla/Shell.py

branch
multi_processing
changeset 7389
770ffcb88be5
parent 7386
3de001de249c
child 7408
0d58e708f57b
equal deleted inserted replaced
7386:3de001de249c 7389:770ffcb88be5
608 """ 608 """
609 Private method to get ready for a new remote interpreter. 609 Private method to get ready for a new remote interpreter.
610 """ 610 """
611 self.buff = "" 611 self.buff = ""
612 self.inContinue = False 612 self.inContinue = False
613 self.inRawMode = False 613 self.__inRawMode = False
614 self.echoInput = True 614 self.__echoInput = True
615 self.__rawModeDebuggerId = None
616 self.__rawModeQueue = []
615 self.clientCapabilities = 0 617 self.clientCapabilities = 0
616 self.inCommandExecution = False 618 self.inCommandExecution = False
617 self.interruptCommandExecution = False 619 self.interruptCommandExecution = False
618 620
619 def __clientCapabilities(self, cap, clType, venvName): 621 def __clientCapabilities(self, cap, clType, venvName):
863 Private method to handle the response from the debugger client. 865 Private method to handle the response from the debugger client.
864 866
865 @param more flag indicating that more user input is required 867 @param more flag indicating that more user input is required
866 @type bool 868 @type bool
867 """ 869 """
868 if not self.inRawMode: 870 if not self.__inRawMode:
869 self.inContinue = more 871 self.inContinue = more
870 self.__writePrompt() 872 self.__writePrompt()
871 self.inCommandExecution = False 873 self.inCommandExecution = False
872 874
873 def __clientException(self, exceptionType, exceptionMessage, stackTrace): 875 def __clientException(self, exceptionType, exceptionMessage, stackTrace):
991 self.__blockTextProcessing = True 993 self.__blockTextProcessing = True
992 # Get all text which is still waiting for output 994 # Get all text which is still waiting for output
993 QApplication.processEvents() 995 QApplication.processEvents()
994 996
995 # Finally process the accumulated text 997 # Finally process the accumulated text
998 self.__flushQueuedText()
999
1000 def __flushQueuedText(self):
1001 """
1002 Private slot to flush the accumulated text output.
1003 """
996 self.__write(self.__queuedText) 1004 self.__write(self.__queuedText)
997 1005
998 self.__queuedText = '' 1006 self.__queuedText = ''
999 self.__blockTextProcessing = False 1007 self.__blockTextProcessing = False
1000 1008
1001 # little trick to get the cursor position registered within QScintilla 1009 # little trick to get the cursor position registered within QScintilla
1002 self.SendScintilla(QsciScintilla.SCI_CHARLEFT) 1010 self.SendScintilla(QsciScintilla.SCI_CHARLEFT)
1003 self.SendScintilla(QsciScintilla.SCI_CHARRIGHT) 1011 self.SendScintilla(QsciScintilla.SCI_CHARRIGHT)
1004 1012
1005 def __write(self, s): 1013 def __write(self, s):
1006 """ 1014 """
1007 Private method to display some text without queuing. 1015 Private method to display some text without queuing.
1008 1016
1009 @param s text to be displayed 1017 @param s text to be displayed
1030 1038
1031 @param s text to be displayed (string) 1039 @param s text to be displayed (string)
1032 """ 1040 """
1033 self.__write(self.tr("StdErr: {0}").format(s)) 1041 self.__write(self.tr("StdErr: {0}").format(s))
1034 1042
1035 def __raw_input(self, s, echo): 1043 def __raw_input(self, prompt, echo, debuggerId):
1036 """ 1044 """
1037 Private method to handle raw input. 1045 Private method to handle raw input.
1038 1046
1039 @param s prompt to be displayed (string) 1047 @param prompt the input prompt
1040 @param echo Flag indicating echoing of the input (boolean) 1048 @type str
1041 """ 1049 @param echo flag indicating an echoing of the input
1042 # Get all text which is still waiting for output 1050 @type bool
1043 QApplication.processEvents() 1051 @param debuggerId ID of the debugger backend
1044 1052 @type str
1045 self.setFocus() 1053 """
1046 self.inRawMode = True 1054 if self.__inRawMode:
1047 self.echoInput = echo 1055 # we are processing another raw input event already
1048 self.__writeQueued(s) 1056 self.__rawModeQueue.append((debuggerId, prompt, echo))
1049 line, col = self.__getEndPos() 1057 else:
1050 self.setCursorPosition(line, col) 1058 self.setFocus()
1051 buf = self.text(line) 1059 self.__inRawMode = True
1052 if buf.startswith(sys.ps1): 1060 self.__echoInput = echo
1053 buf = buf.replace(sys.ps1, "") 1061 self.__rawModeDebuggerId = debuggerId
1054 if buf.startswith(sys.ps2): 1062
1055 buf = buf.replace(sys.ps2, "") 1063 # Get all text which is still waiting for output
1056 self.prompt = buf 1064 QApplication.processEvents()
1057 # move cursor to end of line 1065 self.__flushQueuedText()
1058 self.moveCursorToEOL() 1066
1067 self.__write(self.tr("<{0}> {1}").format(debuggerId, prompt))
1068 line, col = self.__getEndPos()
1069 self.setCursorPosition(line, col)
1070 buf = self.text(line)
1071 if buf.startswith(sys.ps1):
1072 buf = buf.replace(sys.ps1, "")
1073 if buf.startswith(sys.ps2):
1074 buf = buf.replace(sys.ps2, "")
1075 self.prompt = buf
1076 # move cursor to end of line
1077 self.moveCursorToEOL()
1059 1078
1060 def paste(self): 1079 def paste(self):
1061 """ 1080 """
1062 Public slot to handle the paste action. 1081 Public slot to handle the paste action.
1063 """ 1082 """
1309 if len(txt) and txt >= " ": 1328 if len(txt) and txt >= " ":
1310 if not self.__isCursorOnLastLine(): 1329 if not self.__isCursorOnLastLine():
1311 line, col = self.__getEndPos() 1330 line, col = self.__getEndPos()
1312 self.setCursorPosition(line, col) 1331 self.setCursorPosition(line, col)
1313 self.prline, self.prcol = self.getCursorPosition() 1332 self.prline, self.prcol = self.getCursorPosition()
1314 if self.echoInput: 1333 if self.__echoInput:
1315 ac = self.isListActive() 1334 ac = self.isListActive()
1316 super(Shell, self).keyPressEvent(ev) 1335 super(Shell, self).keyPressEvent(ev)
1317 self.incrementalSearchActive = True 1336 self.incrementalSearchActive = True
1318 if ac and self.racEnabled: 1337 if ac and self.racEnabled:
1319 self.dbs.remoteCompletion(self.completionText + txt) 1338 self.dbs.remoteCompletion(self.completionText + txt)
1751 @param cmd command to be executed by debug client 1770 @param cmd command to be executed by debug client
1752 @type str 1771 @type str
1753 @param historyIndex history index to be set 1772 @param historyIndex history index to be set
1754 @type int 1773 @type int
1755 """ 1774 """
1756 if not self.inRawMode: 1775 if not self.__inRawMode:
1757 self.inCommandExecution = True 1776 self.inCommandExecution = True
1758 self.interruptCommandExecution = False 1777 self.interruptCommandExecution = False
1759 if not cmd: 1778 if not cmd:
1760 # make sure cmd is a string 1779 # make sure cmd is a string
1761 cmd = '' 1780 cmd = ''
1851 try: 1870 try:
1852 QApplication.processEvents() 1871 QApplication.processEvents()
1853 except KeyboardInterrupt: 1872 except KeyboardInterrupt:
1854 pass 1873 pass
1855 else: 1874 else:
1856 if not self.echoInput: 1875 if not self.__echoInput:
1857 cmd = self.buff 1876 cmd = self.buff
1858 self.buff = "" 1877 self.buff = ""
1859 elif cmd: 1878 elif cmd:
1860 cmd = cmd[len(self.prompt):] 1879 cmd = cmd[len(self.prompt):]
1861 self.inRawMode = False 1880 self.__inRawMode = False
1862 self.echoInput = True 1881 self.__echoInput = True
1863 1882
1864 self.dbs.remoteRawInput(cmd) 1883 self.dbs.remoteRawInput(self.__rawModeDebuggerId, cmd)
1884
1885 if self.__rawModeQueue:
1886 debuggerId, prompt, echo = self.__rawModeQueue.pop(0)
1887 self.__raw_input(prompt, echo, debuggerId)
1865 1888
1866 def __showVenvName(self): 1889 def __showVenvName(self):
1867 """ 1890 """
1868 Private method to show the name of the active virtual environment. 1891 Private method to show the name of the active virtual environment.
1869 """ 1892 """

eric ide

mercurial