Show More
@@ -174,6 +174,8 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
174 | self._filter_drag = False |
|
174 | self._filter_drag = False | |
175 | self._filter_resize = False |
|
175 | self._filter_resize = False | |
176 | self._html_exporter = HtmlExporter(self._control) |
|
176 | self._html_exporter = HtmlExporter(self._control) | |
|
177 | self._input_buffer_executing = '' | |||
|
178 | self._input_buffer_pending = '' | |||
177 | self._kill_ring = QtKillRing(self._control) |
|
179 | self._kill_ring = QtKillRing(self._control) | |
178 | self._prompt = '' |
|
180 | self._prompt = '' | |
179 | self._prompt_html = None |
|
181 | self._prompt_html = None | |
@@ -439,7 +441,7 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
439 | else: |
|
441 | else: | |
440 | if complete: |
|
442 | if complete: | |
441 | self._append_plain_text('\n') |
|
443 | self._append_plain_text('\n') | |
442 |
self. |
|
444 | self._input_buffer_executing = self.input_buffer | |
443 | self._executing = True |
|
445 | self._executing = True | |
444 | self._prompt_finished() |
|
446 | self._prompt_finished() | |
445 |
|
447 | |||
@@ -478,11 +480,14 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
478 |
|
480 | |||
479 | def _get_input_buffer(self): |
|
481 | def _get_input_buffer(self): | |
480 | """ The text that the user has entered entered at the current prompt. |
|
482 | """ The text that the user has entered entered at the current prompt. | |
|
483 | ||||
|
484 | If the console is currently executing, the text that is executing will | |||
|
485 | always be returned. | |||
481 | """ |
|
486 | """ | |
482 | # If we're executing, the input buffer may not even exist anymore due to |
|
487 | # If we're executing, the input buffer may not even exist anymore due to | |
483 | # the limit imposed by 'buffer_size'. Therefore, we store it. |
|
488 | # the limit imposed by 'buffer_size'. Therefore, we store it. | |
484 | if self._executing: |
|
489 | if self._executing: | |
485 |
return self. |
|
490 | return self._input_buffer_executing | |
486 |
|
491 | |||
487 | cursor = self._get_end_cursor() |
|
492 | cursor = self._get_end_cursor() | |
488 | cursor.setPosition(self._prompt_pos, QtGui.QTextCursor.KeepAnchor) |
|
493 | cursor.setPosition(self._prompt_pos, QtGui.QTextCursor.KeepAnchor) | |
@@ -492,11 +497,16 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
492 | return input_buffer.replace('\n' + self._continuation_prompt, '\n') |
|
497 | return input_buffer.replace('\n' + self._continuation_prompt, '\n') | |
493 |
|
498 | |||
494 | def _set_input_buffer(self, string): |
|
499 | def _set_input_buffer(self, string): | |
495 |
""" |
|
500 | """ Sets the text in the input buffer. | |
|
501 | ||||
|
502 | If the console is currently executing, this call has no *immediate* | |||
|
503 | effect. When the execution is finished, the input buffer will be updated | |||
|
504 | appropriately. | |||
496 | """ |
|
505 | """ | |
497 | # For now, it is an error to modify the input buffer during execution. |
|
506 | # If we're executing, store the text for later. | |
498 | if self._executing: |
|
507 | if self._executing: | |
499 | raise RuntimeError("Cannot change input buffer during execution.") |
|
508 | self._input_buffer_pending = string | |
|
509 | return | |||
500 |
|
510 | |||
501 | # Remove old text. |
|
511 | # Remove old text. | |
502 | cursor = self._get_end_cursor() |
|
512 | cursor = self._get_end_cursor() | |
@@ -1575,10 +1585,16 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
1575 | self._control.setReadOnly(False) |
|
1585 | self._control.setReadOnly(False) | |
1576 | self._control.setAttribute(QtCore.Qt.WA_InputMethodEnabled, True) |
|
1586 | self._control.setAttribute(QtCore.Qt.WA_InputMethodEnabled, True) | |
1577 |
|
1587 | |||
1578 | self._control.moveCursor(QtGui.QTextCursor.End) |
|
|||
1579 | self._executing = False |
|
1588 | self._executing = False | |
1580 | self._prompt_started_hook() |
|
1589 | self._prompt_started_hook() | |
1581 |
|
1590 | |||
|
1591 | # If the input buffer has changed while executing, load it. | |||
|
1592 | if self._input_buffer_pending: | |||
|
1593 | self.input_buffer = self._input_buffer_pending | |||
|
1594 | self._input_buffer_pending = '' | |||
|
1595 | ||||
|
1596 | self._control.moveCursor(QtGui.QTextCursor.End) | |||
|
1597 | ||||
1582 | def _readline(self, prompt='', callback=None): |
|
1598 | def _readline(self, prompt='', callback=None): | |
1583 | """ Reads one line of input from the user. |
|
1599 | """ Reads one line of input from the user. | |
1584 |
|
1600 |
@@ -102,7 +102,6 b' class IPythonWidget(FrontendWidget):' | |||||
102 | super(IPythonWidget, self).__init__(*args, **kw) |
|
102 | super(IPythonWidget, self).__init__(*args, **kw) | |
103 |
|
103 | |||
104 | # IPythonWidget protected variables. |
|
104 | # IPythonWidget protected variables. | |
105 | self._code_to_load = None |
|
|||
106 | self._payload_handlers = { |
|
105 | self._payload_handlers = { | |
107 | self._payload_source_edit : self._handle_payload_edit, |
|
106 | self._payload_source_edit : self._handle_payload_edit, | |
108 | self._payload_source_exit : self._handle_payload_exit, |
|
107 | self._payload_source_exit : self._handle_payload_exit, | |
@@ -322,11 +321,6 b' class IPythonWidget(FrontendWidget):' | |||||
322 | self._set_continuation_prompt( |
|
321 | self._set_continuation_prompt( | |
323 | self._make_continuation_prompt(self._prompt), html=True) |
|
322 | self._make_continuation_prompt(self._prompt), html=True) | |
324 |
|
323 | |||
325 | # Load code from the %loadpy magic, if necessary. |
|
|||
326 | if self._code_to_load is not None: |
|
|||
327 | self.input_buffer = dedent(self._code_to_load.rstrip()) |
|
|||
328 | self._code_to_load = None |
|
|||
329 |
|
||||
330 | def _show_interpreter_prompt_for_reply(self, msg): |
|
324 | def _show_interpreter_prompt_for_reply(self, msg): | |
331 | """ Reimplemented for IPython-style prompts. |
|
325 | """ Reimplemented for IPython-style prompts. | |
332 | """ |
|
326 | """ | |
@@ -460,9 +454,7 b' class IPythonWidget(FrontendWidget):' | |||||
460 | self.exit_requested.emit() |
|
454 | self.exit_requested.emit() | |
461 |
|
455 | |||
462 | def _handle_payload_next_input(self, item): |
|
456 | def _handle_payload_next_input(self, item): | |
463 | # Simply store the text for now. It is written to the buffer when |
|
457 | self.input_buffer = dedent(item['text'].rstrip()) | |
464 | # _show_interpreter_prompt is called. |
|
|||
465 | self._code_to_load = item['text'] |
|
|||
466 |
|
458 | |||
467 | def _handle_payload_page(self, item): |
|
459 | def _handle_payload_page(self, item): | |
468 | # Since the plain text widget supports only a very small subset of HTML |
|
460 | # Since the plain text widget supports only a very small subset of HTML |
General Comments 0
You need to be logged in to leave comments.
Login now