Permalink
Browse files

qtconsole: Create a prompt newline by inserting a new block (w/o form…

…atting)


Closes #2314
  • Loading branch information...
bfroehle committed Aug 31, 2012
1 parent 0af1e9d commit 52bdc1d6ee4635eed02937c7d0de7da7e49739ed
Showing with 13 additions and 1 deletion.
  1. +13 −1 IPython/frontend/qt/console/console_widget.py
@@ -858,6 +858,11 @@ def _append_custom(self, insert, input, before_prompt=False):
return result
+ def _append_block(self, block_format=None, before_prompt=False):
+ """ Appends an new QTextBlock to the end of the console buffer.
+ """
+ self._append_custom(self._insert_block, block_format, before_prompt)
+
def _append_html(self, html, before_prompt=False):
""" Appends HTML at the end of the console buffer.
"""
@@ -1545,6 +1550,13 @@ def _insert_continuation_prompt(self, cursor):
self._continuation_prompt = self._insert_html_fetching_plain_text(
cursor, self._continuation_prompt_html)
+ def _insert_block(self, cursor, block_format=None):
+ """ Inserts an empty QTextBlock using the specified cursor.
+ """
+ if block_format is None:
+ block_format = QtGui.QTextBlockFormat()
+ cursor.insertBlock(block_format)
+
def _insert_html(self, cursor, html):
""" Inserts HTML using the specified cursor in such a way that future
formatting is unaffected.
@@ -1866,7 +1878,7 @@ def _show_prompt(self, prompt=None, html=False, newline=True):
cursor.movePosition(QtGui.QTextCursor.Left,
QtGui.QTextCursor.KeepAnchor)
if cursor.selection().toPlainText() != '\n':
- self._append_plain_text('\n')
+ self._append_block()
# Write the prompt.
self._append_plain_text(self._prompt_sep)

0 comments on commit 52bdc1d

Please sign in to comment.