-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce vk() and sc() key chord specifiers #10666
Changes from 1 commit
0bb6e34
561d40a
7297b41
b8d6f68
9fb176b
877acab
f901604
098aff1
bb6e64d
253072f
c3cc1fc
a38e415
9c54d77
d1bef1e
a8b29ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,6 +151,7 @@ userenv | |
wcsstr | ||
wcstoui | ||
winmain | ||
wmemcmp | ||
wpc | ||
wsregex | ||
wwinmain | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -513,9 +513,9 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation | |
// If we had to find one from a layer above that, parent->_MaskingActions | ||
// would have found it, so we inherit it for free! | ||
const auto& inheritedCmd{ parent->_GetActionByID(actionID) }; | ||
if (inheritedCmd.has_value() && inheritedCmd.value()) | ||
if (inheritedCmd && *inheritedCmd) | ||
{ | ||
const auto& inheritedCmdImpl{ get_self<Command>(inheritedCmd.value()) }; | ||
const auto& inheritedCmdImpl{ get_self<Command>(*inheritedCmd) }; | ||
zadjii-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
maskingCmd = *inheritedCmdImpl->Copy(); | ||
_MaskingActions.emplace(actionID, maskingCmd); | ||
} | ||
|
@@ -683,18 +683,20 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation | |
// - keys: the key chord of the command to search for | ||
// Return Value: | ||
// - the command with the given key chord | ||
// - nullptr if the key chord is explicitly unbound | ||
// - nullptr if the key chord doesn't exist | ||
Model::Command ActionMap::GetActionByKeyChord(Control::KeyChord const& keys) const | ||
{ | ||
// Check the current layer | ||
const auto cmd{ _GetActionByKeyChordInternal(keys) }; | ||
if (cmd.has_value()) | ||
const auto modifiers = keys.Modifiers(); | ||
|
||
if (auto vkey = keys.Vkey()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would it be tremendously dumb to oneline this as return _GetActionByKeyChordInternal({ modifiers, keys.Vkey(), 0 }).value_or( _GetActionByKeyChordInternal({ modifiers, 0, keys.ScanCode() }).value_or(nullptr)); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would certainly be nice! But it would also eagerly check both variants, before returning either, and I'm not sure if that's a good idea... |
||
{ | ||
return *cmd; | ||
if (auto command = _GetActionByKeyChordInternal({ modifiers, vkey, 0 })) | ||
{ | ||
return *command; | ||
} | ||
} | ||
|
||
// This key chord is not explicitly bound | ||
return nullptr; | ||
return _GetActionByKeyChordInternal({ modifiers, 0, keys.ScanCode() }).value_or(nullptr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll now have to run I used to have a comment explaining this here, but I must've lost it at some point. I'll re-add one. |
||
} | ||
|
||
// Method Description: | ||
|
@@ -709,8 +711,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation | |
std::optional<Model::Command> ActionMap::_GetActionByKeyChordInternal(Control::KeyChord const& keys) const | ||
{ | ||
// Check the current layer | ||
const auto actionIDPair{ _KeyMap.find(keys) }; | ||
if (actionIDPair != _KeyMap.end()) | ||
if (const auto actionIDPair = _KeyMap.find(keys); actionIDPair != _KeyMap.end()) | ||
{ | ||
// the command was explicitly bound, | ||
// return what we found (invalid commands exposed as nullptr) | ||
|
@@ -723,7 +724,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation | |
for (const auto& parent : _parents) | ||
{ | ||
const auto& inheritedCmd{ parent->_GetActionByKeyChordInternal(keys) }; | ||
if (inheritedCmd.has_value()) | ||
if (inheritedCmd) | ||
{ | ||
return *inheritedCmd; | ||
} | ||
|
@@ -765,7 +766,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation | |
const auto hash{ Hash(actionAndArgs) }; | ||
if (const auto& cmd{ _GetActionByID(hash) }) | ||
{ | ||
return cmd.value().Keys(); | ||
return cmd->Keys(); | ||
} | ||
|
||
// Check our parents | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to add a 5th constructor, so I removed 1 instead.