Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

grep: allow moving between query and result using the arrow keys

The query input field already knew to focus the results when pressing
either enter, return, or the down-arrow key.  Teach the results field to
focus the input field when the up-arrow is pressed.

This makes the behavior consistent with the commit message editor.

Signed-off-by: David Aguilar <>
  • Loading branch information...
commit 00364657d9b4ae5a328c83e6baf1c806d6946d4b 1 parent 1e52aa0
@davvid authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 cola/widgets/
14 cola/widgets/
@@ -107,6 +107,8 @@ def __init__(self, parent):
self.connect(self.input_txt, SIGNAL('textChanged(QString)'),
+ self.connect(self.result_txt, SIGNAL('leave()'),
+ lambda: self.input_txt.setFocus())
qtutils.add_action(self.input_txt, 'FocusResults',
lambda: self.result_txt.setFocus(),
@@ -231,6 +233,18 @@ def paintEvent(self, event):
painter = QtGui.QPainter(self.viewport())
painter.fillRect(rect, Qt.SolidPattern)
+ def keyPressEvent(self, event):
+ if event.key() == Qt.Key_Up:
+ cursor = self.textCursor()
+ position = cursor.position()
+ if position == 0 and not cursor.hasSelection():
+ # The cursor is at the beginning of the line.
+ # If we have selection then simply reset the cursor.
+ # Otherwise, emit a signal so that the parent can
+ # change focus.
+ self.emit(SIGNAL('leave()'))
+ return HintedTextView.keyPressEvent(self, event)
def goto_grep(line):
"""Called when Search -> Grep's right-click 'goto' action."""
Please sign in to comment.
Something went wrong with that request. Please try again.