QScintilla/Shell.py

changeset 5709
f81d0eca2c62
parent 5631
d0beabfaad42
child 5710
b5809b948010
equal deleted inserted replaced
5708:9b01b4004314 5709:f81d0eca2c62
45 @param horizontal flag indicating a horizontal layout (boolean) 45 @param horizontal flag indicating a horizontal layout (boolean)
46 @param parent parent widget (QWidget) 46 @param parent parent widget (QWidget)
47 """ 47 """
48 super(ShellAssembly, self).__init__(parent) 48 super(ShellAssembly, self).__init__(parent)
49 49
50 self.__shell = Shell(dbs, vm, self) 50 self.__shell = Shell(dbs, vm, False, self)
51 51
52 from UI.SearchWidget import SearchWidget 52 from UI.SearchWidget import SearchWidget
53 self.__searchWidget = SearchWidget(self.__shell, self, horizontal) 53 self.__searchWidget = SearchWidget(self.__shell, self, horizontal)
54 self.__searchWidget.hide() 54 self.__searchWidget.hide()
55 55
93 @signal searchStringFound(found) emitted to indicate the search 93 @signal searchStringFound(found) emitted to indicate the search
94 result (boolean) 94 result (boolean)
95 """ 95 """
96 searchStringFound = pyqtSignal(bool) 96 searchStringFound = pyqtSignal(bool)
97 97
98 def __init__(self, dbs, vm, parent=None): 98 def __init__(self, dbs, vm, windowedVariant, parent=None):
99 """ 99 """
100 Constructor 100 Constructor
101 101
102 @param dbs reference to the debug server object 102 @param dbs reference to the debug server object
103 @param vm reference to the viewmanager object 103 @param vm reference to the viewmanager object
104 @param parent parent widget (QWidget) 104 @param parent parent widget (QWidget)
105 @param windowedVariant flag indicating the shell window variant
106 (boolean)
105 """ 107 """
106 super(Shell, self).__init__(parent) 108 super(Shell, self).__init__(parent)
107 self.setUtf8(True) 109 self.setUtf8(True)
108 110
109 self.vm = vm 111 self.vm = vm
110 self.__mainWindow = parent 112 self.__mainWindow = parent
111 self.__lastSearch = () 113 self.__lastSearch = ()
114 self.__windowed = windowedVariant
112 115
113 self.linesepRegExp = r"\r\n|\n|\r" 116 self.linesepRegExp = r"\r\n|\n|\r"
114 117
118 # TODO: change this for Shell Window
115 self.passive = Preferences.getDebugger("PassiveDbgEnabled") 119 self.passive = Preferences.getDebugger("PassiveDbgEnabled")
116 if self.passive: 120 if self.passive:
117 self.setWindowTitle(self.tr('Shell - Passive')) 121 self.setWindowTitle(self.tr('Shell - Passive'))
118 else: 122 else:
119 self.setWindowTitle(self.tr('Shell')) 123 self.setWindowTitle(self.tr('Shell'))
120 124
121 self.setWhatsThis(self.tr( 125 if self.__windowed:
122 """<b>The Shell Window</b>""" 126 self.setWhatsThis(self.tr(
123 """<p>This is simply an interpreter running in a window. The""" 127 """<b>The Shell Window</b>"""
124 """ interpreter is the one that is used to run the program""" 128 """<p>You can use the cursor keys while entering commands."""
125 """ being debugged. This means that you can execute any command""" 129 """ There is also a history of commands that can be recalled"""
126 """ while the program being debugged is running.</p>""" 130 """ using the up and down cursor keys. Pressing the up or"""
127 """<p>You can use the cursor keys while entering commands. There""" 131 """ down key after some text has been entered will start an"""
128 """ is also a history of commands that can be recalled using the""" 132 """ incremental search.</p>"""
129 """ up and down cursor keys. Pressing the up or down key after""" 133 """<p>The shell has some special commands. 'reset' kills the"""
130 """ some text has been entered will start an incremental search.""" 134 """ shell and starts a new one. 'clear' clears the display"""
131 """</p>""" 135 """ of the shell window. 'start' is used to switch the shell"""
132 """<p>The shell has some special commands. 'reset' kills the""" 136 """ language and must be followed by a supported language."""
133 """ shell and starts a new one. 'clear' clears the display of""" 137 """ Supported languages are listed by the 'languages'"""
134 """ the shell window. 'start' is used to switch the shell""" 138 """ command. These commands (except 'languages') are"""
135 """ language and must be followed by a supported language.""" 139 """ available through the context menu as well.</p>"""
136 """ Supported languages are listed by the 'languages' command.""" 140 """<p>Pressing the Tab key after some text has been entered"""
137 """ These commands (except 'languages') are available through""" 141 """ will show a list of possible completions. The relevant"""
138 """ the context menu as well.</p>""" 142 """ entry may be selected from this list. If only one entry"""
139 """<p>Pressing the Tab key after some text has been entered will""" 143 """ is available, this will be inserted automatically.</p>"""
140 """ show a list of possible commandline completions. The""" 144 ))
141 """ relevant entry may be selected from this list. If only one""" 145 else:
142 """ entry is available, this will inserted automatically.</p>""" 146 self.setWhatsThis(self.tr(
143 """<p>In passive debugging mode the shell is only available""" 147 """<b>The Shell Window</b>"""
144 """ after the program to be debugged has connected to the IDE""" 148 """<p>This is simply an interpreter running in a window. The"""
145 """ until it has finished. This is indicated by a different""" 149 """ interpreter is the one that is used to run the program"""
146 """ prompt and by an indication in the window caption.</p>""" 150 """ being debugged. This means that you can execute any"""
147 )) 151 """ command while the program being debugged is running.</p>"""
152 """<p>You can use the cursor keys while entering commands."""
153 """ There is also a history of commands that can be recalled"""
154 """ using the up and down cursor keys. Pressing the up or"""
155 """ down key after some text has been entered will start an"""
156 """ incremental search.</p>"""
157 """<p>The shell has some special commands. 'reset' kills the"""
158 """ shell and starts a new one. 'clear' clears the display"""
159 """ of the shell window. 'start' is used to switch the shell"""
160 """ language and must be followed by a supported language."""
161 """ Supported languages are listed by the 'languages'"""
162 """ command. These commands (except 'languages') are"""
163 """ available through the context menu as well.</p>"""
164 """<p>Pressing the Tab key after some text has been entered"""
165 """ will show a list of possible completions. The relevant"""
166 """ entry may be selected from this list. If only one entry"""
167 """ is available, this will be inserted automatically.</p>"""
168 """<p>In passive debugging mode the shell is only available"""
169 """ after the program to be debugged has connected to the"""
170 """ IDE until it has finished. This is indicated by a"""
171 """ different prompt and by an indication in the window"""
172 """ caption.</p>"""
173 ))
148 174
149 self.userListActivated.connect(self.__completionListSelected) 175 self.userListActivated.connect(self.__completionListSelected)
150 self.linesChanged.connect(self.__resizeLinenoMargin) 176 self.linesChanged.connect(self.__resizeLinenoMargin)
151 177
152 self.__showStdOutErr = Preferences.getShell("ShowStdOutErr") 178 if self.__windowed:
179 self.__showStdOutErr = True
180 else:
181 self.__showStdOutErr = Preferences.getShell("ShowStdOutErr")
153 if self.__showStdOutErr: 182 if self.__showStdOutErr:
154 dbs.clientProcessStdout.connect(self.__writeStdOut) 183 dbs.clientProcessStdout.connect(self.__writeStdOut)
155 dbs.clientProcessStderr.connect(self.__writeStdErr) 184 dbs.clientProcessStderr.connect(self.__writeStdErr)
156 dbs.clientOutput.connect(self.__write) 185 dbs.clientOutput.connect(self.__write)
157 dbs.clientStatement.connect(self.__clientStatement) 186 dbs.clientStatement.connect(self.__clientStatement)
230 self.menu.addAction(self.tr('Reset'), self.__reset) 259 self.menu.addAction(self.tr('Reset'), self.__reset)
231 self.menu.addAction( 260 self.menu.addAction(
232 self.tr('Reset and Clear'), self.__resetAndClear) 261 self.tr('Reset and Clear'), self.__resetAndClear)
233 self.menu.addSeparator() 262 self.menu.addSeparator()
234 self.menu.addMenu(self.lmenu) 263 self.menu.addMenu(self.lmenu)
235 self.menu.addSeparator() 264 if not self.__windowed:
236 self.menu.addAction(self.tr("Configure..."), self.__configure) 265 self.menu.addSeparator()
266 self.menu.addAction(self.tr("Configure..."), self.__configure)
237 267
238 self.__bindLexer() 268 self.__bindLexer()
239 self.__setTextDisplay() 269 self.__setTextDisplay()
240 self.__setMargin0() 270 self.__setMargin0()
241 271
694 @param exceptionMessage message given by the exception (string) 724 @param exceptionMessage message given by the exception (string)
695 @param stackTrace list of stack entries (list of string) 725 @param stackTrace list of stack entries (list of string)
696 """ 726 """
697 self .__clientError() 727 self .__clientError()
698 728
699 if Preferences.getDebugger("ShowExceptionInShell"): 729 if not self.__windowed and \
730 Preferences.getDebugger("ShowExceptionInShell"):
700 if exceptionType: 731 if exceptionType:
701 if stackTrace: 732 if stackTrace:
702 self.__write( 733 self.__write(
703 self.tr('Exception "{0}"\n{1}\nFile: {2}, Line: {3}\n') 734 self.tr('Exception "{0}"\n{1}\nFile: {2}, Line: {3}\n')
704 .format( 735 .format(
727 @param characterNo character number of the syntax error position 758 @param characterNo character number of the syntax error position
728 (integer) 759 (integer)
729 """ 760 """
730 self .__clientError() 761 self .__clientError()
731 762
732 if Preferences.getDebugger("ShowExceptionInShell"): 763 if not self.__windowed and \
764 Preferences.getDebugger("ShowExceptionInShell"):
733 if message is None: 765 if message is None:
734 self.__write(self.tr("Unspecified syntax error.\n")) 766 self.__write(self.tr("Unspecified syntax error.\n"))
735 else: 767 else:
736 self.__write( 768 self.__write(
737 self.tr('Syntax error "{1}" in file {0} at line {2},' 769 self.tr('Syntax error "{1}" in file {0} at line {2},'
1434 self.dbs.startClient(False) 1466 self.dbs.startClient(False)
1435 if self.passive: 1467 if self.passive:
1436 return 1468 return
1437 else: 1469 else:
1438 cmd = '' 1470 cmd = ''
1471 elif cmd in ["quit", "quit()"] and self.__windowed:
1472 # call main window quit()
1473 self.vm.quit()
1474 return
1439 1475
1440 self.dbs.remoteStatement(cmd) 1476 self.dbs.remoteStatement(cmd)
1441 while self.inCommandExecution: 1477 while self.inCommandExecution:
1442 try: 1478 try:
1443 QApplication.processEvents() 1479 QApplication.processEvents()

eric ide

mercurial