From 0d5f7a8e82dc00cc33af48daa8c31e40224736e9 2014-10-16 19:16:00 From: MinRK Date: 2014-10-16 19:16:00 Subject: [PATCH] highlight input from other front ends in qtconsole --- diff --git a/IPython/qt/console/ipython_widget.py b/IPython/qt/console/ipython_widget.py index 37db61e..41b6a03 100644 --- a/IPython/qt/console/ipython_widget.py +++ b/IPython/qt/console/ipython_widget.py @@ -219,16 +219,24 @@ class IPythonWidget(FrontendWidget): items.append(cell) last_cell = cell self._set_history(items) - + + def _insert_other_input(self, cursor, content): + """Insert function for input from other frontends""" + cursor.beginEditBlock() + start = cursor.position() + n = content.get('execution_count', 0) + cursor.insertText('\n') + self._insert_html(cursor, self._make_in_prompt(n)) + cursor.insertText(content['code']) + self._highlighter.rehighlightBlock(cursor.block()) + cursor.endEditBlock() + def _handle_execute_input(self, msg): """Handle an execute_input message""" self.log.debug("execute_input: %s", msg.get('content', '')) if self.include_output(msg): - content = msg['content'] - prompt_number = content.get('execution_count', 0) - self._append_html(self._make_in_prompt(prompt_number), True) - self._append_plain_text(content['code'], True) - + self._append_custom(self._insert_other_input, msg['content'], before_prompt=True) + def _handle_execute_result(self, msg): """ Reimplemented for IPython-style "display hook".