From 7b7710e6e1f8f7034797098ea204d935439b357d 2010-08-06 21:34:03 From: epatters Date: 2010-08-06 21:34:03 Subject: [PATCH] Setting the input buffer now respects HTML continuation prompts. --- diff --git a/IPython/frontend/qt/console/console_widget.py b/IPython/frontend/qt/console/console_widget.py index f5044a6..87dcafb 100644 --- a/IPython/frontend/qt/console/console_widget.py +++ b/IPython/frontend/qt/console/console_widget.py @@ -402,16 +402,21 @@ class ConsoleWidget(QtGui.QPlainTextEdit): def _set_input_buffer(self, string): """ Replaces the text in the input buffer with 'string'. """ - # Add continuation prompts where necessary. - lines = string.splitlines() - for i in xrange(1, len(lines)): - lines[i] = self._continuation_prompt + lines[i] - string = '\n'.join(lines) - - # Replace buffer with new text. + # Remove old text. cursor = self._get_end_cursor() cursor.setPosition(self._prompt_pos, QtGui.QTextCursor.KeepAnchor) - cursor.insertText(string) + cursor.removeSelectedText() + + # Insert new text with continuation prompts. + lines = string.splitlines(True) + if lines: + self.appendPlainText(lines[0]) + for i in xrange(1, len(lines)): + if self._continuation_prompt_html is None: + self.appendPlainText(self._continuation_prompt) + else: + self.appendHtml(self._continuation_prompt_html) + self.appendPlainText(lines[i]) self.moveCursor(QtGui.QTextCursor.End) input_buffer = property(_get_input_buffer, _set_input_buffer)