-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Give Command ownership over KeyChord #9543
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fd6f9d5
Give Command ownership over KeyChord
carlos-zamora e3adbb4
remove KeyChordText from Command
carlos-zamora 03b9a06
fix nested key chords
carlos-zamora 5ce4f46
Merge branch 'main' into dev/cazamor/tsm/upgrade-command
carlos-zamora 14ba645
xaml format
carlos-zamora 100a7a9
add [] notation support to converter
carlos-zamora e5e91c9
Merge branch 'main' into dev/cazamor/tsm/upgrade-command
carlos-zamora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "pch.h" | ||
#include "KeyChordConverter.h" | ||
#include "KeyChordToStringConverter.g.cpp" | ||
#include "KeyChordToVisibilityConverter.g.cpp" | ||
|
||
using namespace winrt::Windows; | ||
using namespace winrt::Windows::UI::Xaml; | ||
using namespace winrt::Windows::UI::Text; | ||
|
||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | ||
{ | ||
Foundation::IInspectable KeyChordToStringConverter::Convert(Foundation::IInspectable const& value, | ||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */, | ||
Foundation::IInspectable const& /* parameter */, | ||
hstring const& /* language */) | ||
{ | ||
const auto& keys{ winrt::unbox_value<Control::KeyChord>(value) }; | ||
return box_value(Model::KeyChordSerialization::ToString(keys)); | ||
} | ||
|
||
Foundation::IInspectable KeyChordToStringConverter::ConvertBack(Foundation::IInspectable const& value, | ||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */, | ||
Foundation::IInspectable const& /*parameter*/, | ||
hstring const& /* language */) | ||
{ | ||
const auto& keys{ winrt::unbox_value<hstring>(value) }; | ||
return box_value(Model::KeyChordSerialization::FromString(keys)); | ||
} | ||
|
||
Foundation::IInspectable KeyChordToVisibilityConverter::Convert(Foundation::IInspectable const& value, | ||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */, | ||
Foundation::IInspectable const& /* parameter */, | ||
hstring const& /* language */) | ||
{ | ||
return box_value(value ? Visibility::Visible : Visibility::Collapsed); | ||
} | ||
|
||
Foundation::IInspectable KeyChordToVisibilityConverter::ConvertBack(Foundation::IInspectable const& /*value*/, | ||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */, | ||
Foundation::IInspectable const& /*parameter*/, | ||
hstring const& /* language */) | ||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#pragma once | ||
|
||
#include "KeyChordToStringConverter.g.h" | ||
#include "KeyChordToVisibilityConverter.g.h" | ||
#include "../inc/cppwinrt_utils.h" | ||
|
||
DECLARE_CONVERTER(winrt::Microsoft::Terminal::Settings::Editor, KeyChordToStringConverter); | ||
DECLARE_CONVERTER(winrt::Microsoft::Terminal::Settings::Editor, KeyChordToVisibilityConverter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
#pragma once | ||
|
||
#include "KeyChordSerialization.g.h" | ||
#include "JsonUtils.h" | ||
#include "../inc/cppwinrt_utils.h" | ||
|
||
namespace winrt::Microsoft::Terminal::Settings::Model::implementation | ||
|
@@ -17,6 +18,15 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation | |
}; | ||
} | ||
|
||
template<> | ||
struct Microsoft::Terminal::Settings::Model::JsonUtils::ConversionTrait<winrt::Microsoft::Terminal::Control::KeyChord> | ||
{ | ||
winrt::Microsoft::Terminal::Control::KeyChord FromJson(const Json::Value& json); | ||
bool CanConvert(const Json::Value& json); | ||
Json::Value ToJson(const winrt::Microsoft::Terminal::Control::KeyChord& val); | ||
std::string TypeDescription() const; | ||
}; | ||
|
||
Comment on lines
+21
to
+29
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. @DHowett Here's the beginning of a transition to adding more |
||
namespace winrt::Microsoft::Terminal::Settings::Model::factory_implementation | ||
{ | ||
// C++/WinRT generates a constructor even though one is not specified in the IDL | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Surprisingly, we still need something like this to support the following scenario:
In this situation, "copy" still gets the "ctrl+c" key binding, but "openSettings" does not.
A fix will be included in the upcoming commit.
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.
For the record, the current implementation displays "hello" without a kbd, but "custom" with one. Exactly backwards. And
ctrl+q
does not actually execute the action.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.
This is now fixed. As a part of
ActionMap
, it would be nice if we didn't have to do this. But I'm keeping an eye out to make sure this works as intended in the next PR.For now, this is fine.
ActionMap
will probably get some tests to make sure we get the behavior we want.