Skip to content

Commit

Permalink
fixed some cursor selection behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Oct 8, 2010
1 parent 230f3de commit 6659636
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions IPython/frontend/qt/console/console_widget.py
Expand Up @@ -941,6 +941,11 @@ def _event_filter_console_keypress(self, event):
#------ No modifiers --------------------------------------------------- #------ No modifiers ---------------------------------------------------


else: else:
if shift_down:
anchormode=QtGui.QTextCursor.KeepAnchor
else:
anchormode=QtGui.QTextCursor.MoveAnchor

if key == QtCore.Qt.Key_Escape: if key == QtCore.Qt.Key_Escape:
self._keyboard_quit() self._keyboard_quit()
intercepted = True intercepted = True
Expand Down Expand Up @@ -969,8 +974,10 @@ def _event_filter_console_keypress(self, event):
line, col = cursor.blockNumber(), cursor.columnNumber() line, col = cursor.blockNumber(), cursor.columnNumber()
if line > self._get_prompt_cursor().blockNumber() and \ if line > self._get_prompt_cursor().blockNumber() and \
col == len(self._continuation_prompt): col == len(self._continuation_prompt):
self._control.moveCursor(QtGui.QTextCursor.PreviousBlock) self._control.moveCursor(QtGui.QTextCursor.PreviousBlock,
self._control.moveCursor(QtGui.QTextCursor.EndOfBlock) mode=anchormode)
self._control.moveCursor(QtGui.QTextCursor.EndOfBlock,
mode=anchormode)
intercepted = True intercepted = True


# Regular left movement # Regular left movement
Expand All @@ -979,10 +986,12 @@ def _event_filter_console_keypress(self, event):


elif key == QtCore.Qt.Key_Right: elif key == QtCore.Qt.Key_Right:
original_block_number = cursor.blockNumber() original_block_number = cursor.blockNumber()
cursor.movePosition(QtGui.QTextCursor.Right) cursor.movePosition(QtGui.QTextCursor.Right,
mode=anchormode)
if cursor.blockNumber() != original_block_number: if cursor.blockNumber() != original_block_number:
cursor.movePosition(QtGui.QTextCursor.Right, cursor.movePosition(QtGui.QTextCursor.Right,
n=len(self._continuation_prompt)) n=len(self._continuation_prompt),
mode=anchormode)
self._set_cursor(cursor) self._set_cursor(cursor)
intercepted = True intercepted = True


Expand Down

0 comments on commit 6659636

Please sign in to comment.