From 29117a930e8a4c294f6ad2fd35e115cc992742e0 Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Sun, 27 Mar 2022 11:33:44 +0000 Subject: [PATCH] Add an action to select the word under the cursor (#3633) --- CHANGELOG.md | 2 +- src/controllers/hotkeys/ActionNames.hpp | 1 + src/widgets/splits/SplitInput.cpp | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dda3dd50..7926e57f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unversioned -- Major: Added customizable shortcuts. (#2340) +- Major: Added customizable shortcuts. (#2340, #3633) - Minor: Make animated emote playback speed match browser (Firefox and Chrome) behaviour. (#3506) - Minor: Added middle click split to open in browser (#3356) - Minor: Added new search predicate to filter for messages matching a regex (#3282) diff --git a/src/controllers/hotkeys/ActionNames.hpp b/src/controllers/hotkeys/ActionNames.hpp index 88d52e0f..5470d7dc 100644 --- a/src/controllers/hotkeys/ActionNames.hpp +++ b/src/controllers/hotkeys/ActionNames.hpp @@ -135,6 +135,7 @@ inline const std::map actionNames{ ActionDefinition{"Choose previously sent message"}}, {"redo", ActionDefinition{"Redo"}}, {"selectAll", ActionDefinition{"Select all"}}, + {"selectWord", ActionDefinition{"Select word"}}, {"sendMessage", ActionDefinition{ "Send message", diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 437c56e9..7383030d 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -456,6 +456,13 @@ void SplitInput::addShortcuts() this->ui_.textEdit->selectAll(); return ""; }}, + {"selectWord", + [this](std::vector) -> QString { + auto cursor = this->ui_.textEdit->textCursor(); + cursor.select(QTextCursor::WordUnderCursor); + this->ui_.textEdit->setTextCursor(cursor); + return ""; + }}, }; this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory(