##// END OF EJS Templates
BUG: Fix sporadic "Position 'x' out of range" warning from Qt console....
epatters -
Show More
@@ -965,6 +965,7 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
965 self._cancel_text_completion()
965 self._cancel_text_completion()
966
966
967 if self._in_buffer(position):
967 if self._in_buffer(position):
968 # Special handling when a reading a line of raw input.
968 if self._reading:
969 if self._reading:
969 self._append_plain_text('\n')
970 self._append_plain_text('\n')
970 self._reading = False
971 self._reading = False
@@ -1222,9 +1223,12 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
1222
1223
1223 # Don't move the cursor if Control/Cmd is pressed to allow copy-paste
1224 # Don't move the cursor if Control/Cmd is pressed to allow copy-paste
1224 # using the keyboard in any part of the buffer. Also, permit scrolling
1225 # using the keyboard in any part of the buffer. Also, permit scrolling
1225 # with Page Up/Down keys.
1226 # with Page Up/Down keys. Finally, if we're executing, don't move the
1227 # cursor (if even this made sense, we can't guarantee that the prompt
1228 # position is still valid due to text truncation).
1226 if not (self._control_key_down(event.modifiers(), include_command=True)
1229 if not (self._control_key_down(event.modifiers(), include_command=True)
1227 or key in (QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown)):
1230 or key in (QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown)
1231 or self._executing):
1228 self._keep_cursor_in_buffer()
1232 self._keep_cursor_in_buffer()
1229
1233
1230 return intercepted
1234 return intercepted
@@ -1289,13 +1293,11 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
1289 -------
1293 -------
1290 The formatted string.
1294 The formatted string.
1291 """
1295 """
1292 # Note: this code is adapted from columnize 0.3.2.
1293 # See http://code.google.com/p/pycolumnize/
1294
1295 # Calculate the number of characters available.
1296 # Calculate the number of characters available.
1296 width = self._control.viewport().width()
1297 width = self._control.viewport().width()
1297 char_width = QtGui.QFontMetrics(self.font).width(' ')
1298 char_width = QtGui.QFontMetrics(self.font).width(' ')
1298 displaywidth = max(10, (width / char_width) - 1)
1299 displaywidth = max(10, (width / char_width) - 1)
1300
1299 return columnize(items, separator, displaywidth)
1301 return columnize(items, separator, displaywidth)
1300
1302
1301 def _get_block_plain_text(self, block):
1303 def _get_block_plain_text(self, block):
General Comments 0
You need to be logged in to leave comments. Login now