Show More
@@ -150,6 +150,7 b' class ConsoleWidget(QtGui.QWidget):' | |||
|
150 | 150 | self._prompt = '' |
|
151 | 151 | self._prompt_html = None |
|
152 | 152 | self._prompt_pos = 0 |
|
153 | self._prompt_sep = '' | |
|
153 | 154 | self._reading = False |
|
154 | 155 | self._reading_callback = None |
|
155 | 156 | self._tab_width = 8 |
@@ -282,24 +283,35 b' class ConsoleWidget(QtGui.QWidget):' | |||
|
282 | 283 | -------- |
|
283 | 284 | A boolean indicating whether the source was executed. |
|
284 | 285 | """ |
|
285 | if not hidden: | |
|
286 | # Do everything here inside an edit block so continuation prompts | |
|
287 | # are removed seamlessly via undo/redo. | |
|
288 | cursor = self._control.textCursor() | |
|
289 | cursor.beginEditBlock() | |
|
286 | # WARNING: The order in which things happen here is very particular, in | |
|
287 | # large part because our syntax highlighting is fragile. If you change | |
|
288 | # something, test carefully! | |
|
290 | 289 | |
|
291 | if source is not None: | |
|
290 | # Decide what to execute. | |
|
291 | if source is None: | |
|
292 | source = self.input_buffer | |
|
293 | if not hidden: | |
|
294 | # A newline is appended later, but it should be considered part | |
|
295 | # of the input buffer. | |
|
296 | source += '\n' | |
|
297 | elif not hidden: | |
|
292 | 298 |
|
|
293 | 299 | |
|
300 | # Execute the source or show a continuation prompt if it is incomplete. | |
|
301 | complete = self._is_complete(source, interactive) | |
|
302 | if hidden: | |
|
303 | if complete: | |
|
304 | self._execute(source, hidden) | |
|
305 | else: | |
|
306 | error = 'Incomplete noninteractive input: "%s"' | |
|
307 | raise RuntimeError(error % source) | |
|
308 | else: | |
|
309 | if complete: | |
|
294 | 310 | self._append_plain_text('\n') |
|
295 | 311 | self._executing_input_buffer = self.input_buffer |
|
296 | 312 | self._executing = True |
|
297 | 313 | self._prompt_finished() |
|
298 | 314 | |
|
299 | real_source = self.input_buffer if source is None else source | |
|
300 | complete = self._is_complete(real_source, interactive) | |
|
301 | if complete: | |
|
302 | if not hidden: | |
|
303 | 315 | # The maximum block count is only in effect during execution. |
|
304 | 316 | # This ensures that _prompt_pos does not become invalid due to |
|
305 | 317 | # text truncation. |
@@ -309,13 +321,17 b' class ConsoleWidget(QtGui.QWidget):' | |||
|
309 | 321 | # disable the undo/redo history, but just to be safe: |
|
310 | 322 | self._control.setUndoRedoEnabled(False) |
|
311 | 323 | |
|
312 |
self._execute( |
|
|
313 | elif hidden: | |
|
314 | raise RuntimeError('Incomplete noninteractive input: "%s"' % source) | |
|
324 | self._execute(source, hidden) | |
|
325 | ||
|
315 | 326 | else: |
|
327 | # Do this inside an edit block so continuation prompts are | |
|
328 | # removed seamlessly via undo/redo. | |
|
329 | cursor = self._control.textCursor() | |
|
330 | cursor.beginEditBlock() | |
|
331 | ||
|
332 | self._append_plain_text('\n') | |
|
316 | 333 | self._show_continuation_prompt() |
|
317 | 334 | |
|
318 | if not hidden: | |
|
319 | 335 | cursor.endEditBlock() |
|
320 | 336 | |
|
321 | 337 | return complete |
@@ -1212,6 +1228,7 b' class ConsoleWidget(QtGui.QWidget):' | |||
|
1212 | 1228 | self._append_plain_text('\n') |
|
1213 | 1229 | |
|
1214 | 1230 | # Write the prompt. |
|
1231 | self._append_plain_text(self._prompt_sep) | |
|
1215 | 1232 | if prompt is None: |
|
1216 | 1233 | if self._prompt_html is None: |
|
1217 | 1234 | self._append_plain_text(self._prompt) |
@@ -1238,8 +1255,6 b' class ConsoleWidget(QtGui.QWidget):' | |||
|
1238 | 1255 | self._continuation_prompt = self._append_html_fetching_plain_text( |
|
1239 | 1256 | self._continuation_prompt_html) |
|
1240 | 1257 | |
|
1241 | self._prompt_started() | |
|
1242 | ||
|
1243 | 1258 | |
|
1244 | 1259 | class HistoryConsoleWidget(ConsoleWidget): |
|
1245 | 1260 | """ A ConsoleWidget that keeps a history of the commands that have been |
@@ -179,7 +179,7 b' class IPythonWidget(FrontendWidget):' | |||
|
179 | 179 | |
|
180 | 180 | # Show a new prompt and save information about it so that it can be |
|
181 | 181 | # updated later if the prompt number turns out to be wrong. |
|
182 |
self._ |
|
|
182 | self._prompt_sep = input_sep | |
|
183 | 183 | self._show_prompt(self._make_in_prompt(number), html=True) |
|
184 | 184 | block = self._control.document().lastBlock() |
|
185 | 185 | length = len(self._prompt) |
@@ -22,7 +22,12 b' def main():' | |||
|
22 | 22 | """ |
|
23 | 23 | # Parse command line arguments. |
|
24 | 24 | parser = ArgumentParser() |
|
25 |
parser.add_argument('- |
|
|
25 | parser.add_argument('-r', '--rich', action='store_true', | |
|
26 | help='use a rich text frontend') | |
|
27 | parser.add_argument('-t', '--tab-simple', action='store_true', | |
|
28 | help='do tab completion ala a Unix terminal') | |
|
29 | ||
|
30 | parser.add_argument('--existing', action='store_true', | |
|
26 | 31 | help='connect to an existing kernel') |
|
27 | 32 | parser.add_argument('--ip', type=str, default=LOCALHOST, |
|
28 | 33 | help='set the kernel\'s IP address [default localhost]') |
@@ -32,13 +37,13 b' def main():' | |||
|
32 | 37 | help='set the SUB channel port [default random]') |
|
33 | 38 | parser.add_argument('--rep', type=int, metavar='PORT', default=0, |
|
34 | 39 | help='set the REP channel port [default random]') |
|
40 | ||
|
35 | 41 | group = parser.add_mutually_exclusive_group() |
|
36 | 42 | group.add_argument('--pure', action='store_true', help = \ |
|
37 | 43 | 'use a pure Python kernel instead of an IPython kernel') |
|
38 | 44 | group.add_argument('--pylab', action='store_true', |
|
39 | 45 | help='use a kernel with PyLab enabled') |
|
40 | parser.add_argument('--rich', action='store_true', | |
|
41 | help='use a rich text frontend') | |
|
46 | ||
|
42 | 47 | args = parser.parse_args() |
|
43 | 48 | |
|
44 | 49 | # Don't let Qt or ZMQ swallow KeyboardInterupts. |
@@ -70,6 +75,7 b' def main():' | |||
|
70 | 75 | widget = RichIPythonWidget() |
|
71 | 76 | else: |
|
72 | 77 | widget = IPythonWidget() |
|
78 | widget.gui_completion = not args.tab_simple | |
|
73 | 79 | widget.kernel_manager = kernel_manager |
|
74 | 80 | widget.setWindowTitle('Python' if args.pure else 'IPython') |
|
75 | 81 | widget.show() |
General Comments 0
You need to be logged in to leave comments.
Login now