aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/textutils.cpp
diff options
context:
space:
mode:
authorEike Ziller <[email protected]>2019-02-12 13:08:46 +0100
committerEike Ziller <[email protected]>2019-02-15 14:06:50 +0000
commit2bebfe9985e1da4a6227e82ef2b596b26ec964ea (patch)
tree349c07630206a7a1413ac3ed329e68f0401474c1 /src/libs/utils/textutils.cpp
parentb1e1c91e04c850918eb64cc6b4a3e4d343c0d73a (diff)
Help: Add fallback word lookup for context help to base text editor
If we do not have a hover handler, or that did not produce any result, use the word under cursor and try with that. This adds at least some help fallback mechanism to all text editors, e.g. we get some context help (though a bit crude) for Pyside "for free". Change-Id: I1b6d91ad6f46bfd12e242b1aec9f4fcadae23403 Reviewed-by: Cristian Maureira-Fredes <[email protected]> Reviewed-by: David Schulz <[email protected]>
Diffstat (limited to 'src/libs/utils/textutils.cpp')
-rw-r--r--src/libs/utils/textutils.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libs/utils/textutils.cpp b/src/libs/utils/textutils.cpp
index f72dd89321c..21fb3caf511 100644
--- a/src/libs/utils/textutils.cpp
+++ b/src/libs/utils/textutils.cpp
@@ -140,6 +140,13 @@ QTextCursor wordStartCursor(const QTextCursor &textCursor)
return cursor;
}
+QString wordUnderCursor(const QTextCursor &cursor)
+{
+ QTextCursor tc(cursor);
+ tc.select(QTextCursor::WordUnderCursor);
+ return tc.selectedText();
+}
+
int utf8NthLineOffset(const QTextDocument *textDocument, const QByteArray &buffer, int line)
{
if (textDocument->blockCount() < line)