Add an action to select the word under the cursor (#3633)

This commit is contained in:
Mm2PL 2022-03-27 11:33:44 +00:00 committed by GitHub
parent 8f156298af
commit 29117a930e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View file

@ -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)

View file

@ -135,6 +135,7 @@ inline const std::map<HotkeyCategory, ActionDefinitionMap> actionNames{
ActionDefinition{"Choose previously sent message"}},
{"redo", ActionDefinition{"Redo"}},
{"selectAll", ActionDefinition{"Select all"}},
{"selectWord", ActionDefinition{"Select word"}},
{"sendMessage",
ActionDefinition{
"Send message",

View file

@ -456,6 +456,13 @@ void SplitInput::addShortcuts()
this->ui_.textEdit->selectAll();
return "";
}},
{"selectWord",
[this](std::vector<QString>) -> QString {
auto cursor = this->ui_.textEdit->textCursor();
cursor.select(QTextCursor::WordUnderCursor);
this->ui_.textEdit->setTextCursor(cursor);
return "";
}},
};
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory(