From b632108f01b132ad8bee6f1b5d6f2ce09fc0856b 2010-09-01 17:15:48 From: epatters Date: 2010-09-01 17:15:48 Subject: [PATCH] Fixed scrolling bugs when using rich text mode. (Work around probable bug in Qt.) --- diff --git a/IPython/frontend/qt/console/console_widget.py b/IPython/frontend/qt/console/console_widget.py index d2c4bb4..b1983a3 100644 --- a/IPython/frontend/qt/console/console_widget.py +++ b/IPython/frontend/qt/console/console_widget.py @@ -340,9 +340,13 @@ class ConsoleWidget(Configurable, QtGui.QWidget): cursor.beginEditBlock() cursor.insertText('\n') self._insert_continuation_prompt(cursor) - self._control.moveCursor(QtGui.QTextCursor.End) cursor.endEditBlock() + # Do not do this inside the edit block. It works as expected + # when using a QPlainTextEdit control, but does not have an + # effect when using a QTextEdit. I believe this is a Qt bug. + self._control.moveCursor(QtGui.QTextCursor.End) + return complete def _get_input_buffer(self): @@ -714,19 +718,19 @@ class ConsoleWidget(Configurable, QtGui.QWidget): if cursor.selectedText().trimmed().isEmpty(): self.execute(interactive=True) else: + # Do this inside an edit block for clean undo/redo. cursor.beginEditBlock() cursor.setPosition(position) cursor.insertText('\n') self._insert_continuation_prompt(cursor) - + cursor.endEditBlock() + # Ensure that the whole input buffer is visible. # FIXME: This will not be usable if the input buffer # is taller than the console widget. self._control.moveCursor(QtGui.QTextCursor.End) self._control.setTextCursor(cursor) - cursor.endEditBlock() - elif key == QtCore.Qt.Key_Up: if self._reading or not self._up_pressed(): intercepted = True diff --git a/IPython/frontend/qt/console/frontend_widget.py b/IPython/frontend/qt/console/frontend_widget.py index 674a816..6537119 100644 --- a/IPython/frontend/qt/console/frontend_widget.py +++ b/IPython/frontend/qt/console/frontend_widget.py @@ -176,7 +176,7 @@ class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin): if self._control_key_down(event.modifiers()): if key == QtCore.Qt.Key_C and self._executing: self.interrupt_kernel() - return True_ + return True elif key == QtCore.Qt.Key_Period: message = 'Are you sure you want to restart the kernel?' self.restart_kernel(message)