diff options
author | David Schulz <david.schulz@qt.io> | 2020-10-26 12:06:59 +0100 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2021-01-11 12:44:40 +0000 |
commit | d03f723060431fb56d2ef7e548b59752578958f1 (patch) | |
tree | 1c1ca57c7432e463872a9a04d277fa4c16dd3f26 /src/plugins/texteditor/texteditorplugin.cpp | |
parent | 48a6f8ad8240b4b8f2e7ac5a567e5874ad462be6 (diff) |
TextEditor: add macro variable containing the word under cursor
Fixes: QTCREATORBUG-24836
Change-Id: Ib872fd12e5842bdb752dd3969ef9c5eb9dd2f650
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/texteditor/texteditorplugin.cpp')
-rw-r--r-- | src/plugins/texteditor/texteditorplugin.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp index cb31909c31..977173424c 100644 --- a/src/plugins/texteditor/texteditorplugin.cpp +++ b/src/plugins/texteditor/texteditorplugin.cpp @@ -67,6 +67,7 @@ static const char kCurrentDocumentColumn[] = "CurrentDocument:Column"; static const char kCurrentDocumentRowCount[] = "CurrentDocument:RowCount"; static const char kCurrentDocumentColumnCount[] = "CurrentDocument:ColumnCount"; static const char kCurrentDocumentFontSize[] = "CurrentDocument:FontSize"; +static const char kCurrentDocumentWordUnderCursor[] = "CurrentDocument:WordUnderCursor"; class TextEditorPluginPrivate : public QObject { @@ -234,6 +235,15 @@ void TextEditorPlugin::extensionsInitialized() BaseTextEditor *editor = BaseTextEditor::currentTextEditor(); return editor ? editor->widget()->font().pointSize() : 0; }); + + expander->registerVariable(kCurrentDocumentWordUnderCursor, + tr("Word under the current document's text cursor."), + []() { + BaseTextEditor *editor = BaseTextEditor::currentTextEditor(); + if (!editor) + return QString(); + return Text::wordUnderCursor(editor->editorWidget()->textCursor()); + }); } LineNumberFilter *TextEditorPlugin::lineNumberFilter() |