Commit 4d6cb992 authored by Robert Loehning's avatar Robert Loehning
Browse files

Squish: Use generic function textUnderCursor(...)



Change-Id: I7ea6e9af1435e716266f4dfd917fe9ac568a67a5
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 62fed3c4
...@@ -112,19 +112,16 @@ def selectFromLocator(filter, itemName = None): ...@@ -112,19 +112,16 @@ def selectFromLocator(filter, itemName = None):
doubleClick(wantedItem, 5, 5, 0, Qt.LeftButton) doubleClick(wantedItem, 5, 5, 0, Qt.LeftButton)
def wordUnderCursor(window): def wordUnderCursor(window):
cursor = window.textCursor() return textUnderCursor(window, QTextCursor.StartOfWord, QTextCursor.EndOfWord)
oldposition = cursor.position()
cursor.movePosition(QTextCursor.StartOfWord)
cursor.movePosition(QTextCursor.EndOfWord, QTextCursor.KeepAnchor)
returnValue = cursor.selectedText()
cursor.setPosition(oldposition)
return returnValue
def lineUnderCursor(window): def lineUnderCursor(window):
return textUnderCursor(window, QTextCursor.StartOfLine, QTextCursor.EndOfLine)
def textUnderCursor(window, fromPos, toPos):
cursor = window.textCursor() cursor = window.textCursor()
oldposition = cursor.position() oldposition = cursor.position()
cursor.movePosition(QTextCursor.StartOfLine) cursor.movePosition(fromPos)
cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor) cursor.movePosition(toPos, QTextCursor.KeepAnchor)
returnValue = cursor.selectedText() returnValue = cursor.selectedText()
cursor.setPosition(oldposition) cursor.setPosition(oldposition)
return returnValue return returnValue
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment