Editor: Add action to select word under cursor

Task-number: QTCREATORBUG-641
Change-Id: I83e2705c7250646b13cd3ec52779a1496e6a472c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2016-08-02 08:17:35 +02:00
parent cc873518c0
commit db0c289f02
4 changed files with 14 additions and 0 deletions

View File

@@ -1357,6 +1357,15 @@ bool TextEditorWidget::selectBlockDown()
return true;
}
void TextEditorWidget::selectWordUnderCursor()
{
QTextCursor tc = textCursor();
if (tc.hasSelection())
return;
tc.select(QTextCursor::WordUnderCursor);
setTextCursor(tc);
}
void TextEditorWidget::copyLineUp()
{
d->copyLineUpDown(true);

View File

@@ -396,6 +396,7 @@ public:
virtual bool selectBlockUp();
virtual bool selectBlockDown();
void selectWordUnderCursor();
void moveLineUp();
void moveLineDown();

View File

@@ -451,6 +451,9 @@ void TextEditorActionHandlerPrivate::createActions()
[this] (TextEditorWidget *w) { w->selectBlockDown(); }, true, tr("Select Block Down"),
QKeySequence(tr("Ctrl+Shift+Alt+U")),
G_EDIT_BLOCKS, advancedEditMenu);
registerAction(SELECT_WORD_UNDER_CURSOR,
[this] (TextEditorWidget *w) { w->selectWordUnderCursor(); }, true,
tr("Select Word Under Cursor"));
// register GOTO Actions
registerAction(GOTO_LINE_START,

View File

@@ -127,6 +127,7 @@ const char GOTO_BLOCK_END[] = "TextEditor.GotoBlockEnd";
const char GOTO_BLOCK_END_WITH_SELECTION[] = "TextEditor.GotoBlockEndWithSelection";
const char SELECT_BLOCK_UP[] = "TextEditor.SelectBlockUp";
const char SELECT_BLOCK_DOWN[] = "TextEditor.SelectBlockDown";
const char SELECT_WORD_UNDER_CURSOR[] = "TextEditor.SelectWordUnderCursor";
const char VIEW_PAGE_UP[] = "TextEditor.viewPageUp";
const char VIEW_PAGE_DOWN[] = "TextEditor.viewPageDown";
const char VIEW_LINE_UP[] = "TextEditor.viewLineUp";