Show More
@@ -197,6 +197,9 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
197 | 197 | self._local_kernel = kw.get('local_kernel', |
|
198 | 198 | FrontendWidget._local_kernel) |
|
199 | 199 | |
|
200 | # Whether or not a clear_output call is pending new output. | |
|
201 | self._pending_clearoutput = False | |
|
202 | ||
|
200 | 203 | #--------------------------------------------------------------------------- |
|
201 | 204 | # 'ConsoleWidget' public interface |
|
202 | 205 | #--------------------------------------------------------------------------- |
@@ -339,6 +342,14 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
339 | 342 | #--------------------------------------------------------------------------- |
|
340 | 343 | # 'BaseFrontendMixin' abstract interface |
|
341 | 344 | #--------------------------------------------------------------------------- |
|
345 | def _handle_clear_output(self, msg): | |
|
346 | """Handle clear output messages.""" | |
|
347 | if not self._hidden and self._is_from_this_session(msg): | |
|
348 | wait = msg['content'].get('wait', True) | |
|
349 | if wait: | |
|
350 | self._pending_clearoutput = True | |
|
351 | else: | |
|
352 | self.clear_output() | |
|
342 | 353 | |
|
343 | 354 | def _handle_complete_reply(self, rep): |
|
344 | 355 | """ Handle replies for tab completion. |
@@ -520,6 +531,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
520 | 531 | """ |
|
521 | 532 | self.log.debug("pyout: %s", msg.get('content', '')) |
|
522 | 533 | if not self._hidden and self._is_from_this_session(msg): |
|
534 | self.flush_clearoutput() | |
|
523 | 535 | text = msg['content']['data'] |
|
524 | 536 | self._append_plain_text(text + '\n', before_prompt=True) |
|
525 | 537 | |
@@ -528,13 +540,8 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
528 | 540 | """ |
|
529 | 541 | self.log.debug("stream: %s", msg.get('content', '')) |
|
530 | 542 | if not self._hidden and self._is_from_this_session(msg): |
|
531 | # Most consoles treat tabs as being 8 space characters. Convert tabs | |
|
532 | # to spaces so that output looks as expected regardless of this | |
|
533 | # widget's tab width. | |
|
534 | text = msg['content']['data'].expandtabs(8) | |
|
535 | ||
|
536 | self._append_plain_text(text, before_prompt=True) | |
|
537 | self._control.moveCursor(QtGui.QTextCursor.End) | |
|
543 | self.flush_clearoutput() | |
|
544 | self.append_stream(msg['content']['data']) | |
|
538 | 545 | |
|
539 | 546 | def _handle_shutdown_reply(self, msg): |
|
540 | 547 | """ Handle shutdown signal, only if from other console. |
@@ -685,6 +692,31 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||
|
685 | 692 | before_prompt=True |
|
686 | 693 | ) |
|
687 | 694 | |
|
695 | def append_stream(self, text): | |
|
696 | """Appends text to the output stream.""" | |
|
697 | # Most consoles treat tabs as being 8 space characters. Convert tabs | |
|
698 | # to spaces so that output looks as expected regardless of this | |
|
699 | # widget's tab width. | |
|
700 | text = text.expandtabs(8) | |
|
701 | ||
|
702 | print([ord(c) for c in text]) | |
|
703 | self._append_plain_text(text, before_prompt=True) | |
|
704 | self._control.moveCursor(QtGui.QTextCursor.End) | |
|
705 | ||
|
706 | def flush_clearoutput(self): | |
|
707 | """If a clearoutput is pending, execute it.""" | |
|
708 | if self._pending_clearoutput: | |
|
709 | self._pending_clearoutput = False | |
|
710 | self.clear_output() | |
|
711 | ||
|
712 | def clear_output(self): | |
|
713 | """Clear the output area.""" | |
|
714 | cursor = self._control.textCursor() | |
|
715 | cursor.beginEditBlock() | |
|
716 | cursor.movePosition(cursor.StartOfLine, cursor.KeepAnchor) | |
|
717 | cursor.insertText('') | |
|
718 | cursor.endEditBlock() | |
|
719 | ||
|
688 | 720 | #--------------------------------------------------------------------------- |
|
689 | 721 | # 'FrontendWidget' protected interface |
|
690 | 722 | #--------------------------------------------------------------------------- |
@@ -140,7 +140,6 b' class IPythonWidget(FrontendWidget):' | |||
|
140 | 140 | #--------------------------------------------------------------------------- |
|
141 | 141 | # 'BaseFrontendMixin' abstract interface |
|
142 | 142 | #--------------------------------------------------------------------------- |
|
143 | ||
|
144 | 143 | def _handle_complete_reply(self, rep): |
|
145 | 144 | """ Reimplemented to support IPython's improved completion machinery. |
|
146 | 145 | """ |
@@ -223,6 +222,7 b' class IPythonWidget(FrontendWidget):' | |||
|
223 | 222 | """ |
|
224 | 223 | self.log.debug("pyout: %s", msg.get('content', '')) |
|
225 | 224 | if not self._hidden and self._is_from_this_session(msg): |
|
225 | self.flush_clearoutput() | |
|
226 | 226 | content = msg['content'] |
|
227 | 227 | prompt_number = content.get('execution_count', 0) |
|
228 | 228 | data = content['data'] |
@@ -250,6 +250,7 b' class IPythonWidget(FrontendWidget):' | |||
|
250 | 250 | # eventually will as this allows all frontends to monitor the display |
|
251 | 251 | # data. But we need to figure out how to handle this in the GUI. |
|
252 | 252 | if not self._hidden and self._is_from_this_session(msg): |
|
253 | self.flush_clearoutput() | |
|
253 | 254 | source = msg['content']['source'] |
|
254 | 255 | data = msg['content']['data'] |
|
255 | 256 | metadata = msg['content']['metadata'] |
@@ -114,6 +114,7 b' class RichIPythonWidget(IPythonWidget):' | |||
|
114 | 114 | """ Overridden to handle rich data types, like SVG. |
|
115 | 115 | """ |
|
116 | 116 | if not self._hidden and self._is_from_this_session(msg): |
|
117 | self.flush_clearoutput() | |
|
117 | 118 | content = msg['content'] |
|
118 | 119 | prompt_number = content.get('execution_count', 0) |
|
119 | 120 | data = content['data'] |
@@ -140,6 +141,7 b' class RichIPythonWidget(IPythonWidget):' | |||
|
140 | 141 | """ Overridden to handle rich data types, like SVG. |
|
141 | 142 | """ |
|
142 | 143 | if not self._hidden and self._is_from_this_session(msg): |
|
144 | self.flush_clearoutput() | |
|
143 | 145 | source = msg['content']['source'] |
|
144 | 146 | data = msg['content']['data'] |
|
145 | 147 | metadata = msg['content']['metadata'] |
General Comments 0
You need to be logged in to leave comments.
Login now