-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Add ability to save input action from command line #16513
Changes from 18 commits
83e3b8c
dd46338
8bec5ec
eec4f6b
e54b4a4
03f57ac
e0b0477
0ad6296
d4eaec3
50baa7b
addf247
49a74c8
cf56a9a
3f15d6e
2bf8391
f5ceac9
d6873c1
cd13fc3
8377749
452bfce
6c79af0
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 |
---|---|---|
|
@@ -4184,6 +4184,66 @@ namespace winrt::TerminalApp::implementation | |
} | ||
} | ||
|
||
winrt::fire_and_forget TerminalPage::ActionSaved(winrt::hstring input, winrt::hstring name, winrt::hstring keyChord) | ||
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. Why put these two functions here instead of having them next to the related code inside 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. updated |
||
{ | ||
auto weakThis{ get_weak() }; | ||
co_await wil::resume_foreground(Dispatcher()); | ||
if (auto page{ weakThis.get() }) | ||
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. Does this code get called from a background thread? 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. you are right, It was not running on a background thread, before and after the co_await it was on the Window thread. Updated to just use void and removed the co_await. |
||
{ | ||
// If we haven't ever loaded the TeachingTip, then do so now and | ||
// create the toast for it. | ||
if (page->_actionSavedToast == nullptr) | ||
{ | ||
if (auto tip{ page->FindName(L"ActionSavedToast").try_as<MUX::Controls::TeachingTip>() }) | ||
{ | ||
page->_actionSavedToast = std::make_shared<Toast>(tip); | ||
// Make sure to use the weak ref when setting up this | ||
// callback. | ||
tip.Closed({ page->get_weak(), &TerminalPage::_FocusActiveControl }); | ||
} | ||
} | ||
_UpdateTeachingTipTheme(ActionSavedToast().try_as<winrt::Windows::UI::Xaml::FrameworkElement>()); | ||
|
||
SavedActionName(name); | ||
SavedActionKeyChord(keyChord); | ||
SavedActionCommandLine(input); | ||
|
||
if (page->_actionSavedToast != nullptr) | ||
{ | ||
page->_actionSavedToast->Open(); | ||
} | ||
} | ||
} | ||
|
||
winrt::fire_and_forget TerminalPage::ActionSaveFailed(winrt::hstring message) | ||
{ | ||
auto weakThis{ get_weak() }; | ||
co_await wil::resume_foreground(Dispatcher()); | ||
if (auto page{ weakThis.get() }) | ||
{ | ||
// If we haven't ever loaded the TeachingTip, then do so now and | ||
// create the toast for it. | ||
if (page->_actionSaveFailedToast == nullptr) | ||
{ | ||
if (auto tip{ page->FindName(L"ActionSaveFailedToast").try_as<MUX::Controls::TeachingTip>() }) | ||
{ | ||
page->_actionSaveFailedToast = std::make_shared<Toast>(tip); | ||
// Make sure to use the weak ref when setting up this | ||
// callback. | ||
tip.Closed({ page->get_weak(), &TerminalPage::_FocusActiveControl }); | ||
} | ||
} | ||
_UpdateTeachingTipTheme(ActionSaveFailedToast().try_as<winrt::Windows::UI::Xaml::FrameworkElement>()); | ||
|
||
ActionSaveFailedMessage().Text(message); | ||
|
||
if (page->_actionSaveFailedToast != nullptr) | ||
{ | ||
page->_actionSaveFailedToast->Open(); | ||
} | ||
} | ||
} | ||
|
||
// Method Description: | ||
// - Called when an attempt to rename the window has failed. This will open | ||
// the toast displaying a message to the user that the attempt to rename | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:TerminalApp" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:mtu="using:Microsoft.Terminal.UI" | ||
xmlns:mux="using:Microsoft.UI.Xaml.Controls" | ||
Background="Transparent" | ||
mc:Ignorable="d"> | ||
|
@@ -204,5 +205,43 @@ | |
Title="{x:Bind WindowProperties.VirtualWorkingDirectory, Mode=OneWay}" | ||
x:Load="False" | ||
IsLightDismissEnabled="True" /> | ||
|
||
<mux:TeachingTip x:Name="ActionSavedToast" | ||
x:Uid="ActionSavedToast" | ||
Title="Action Saved" | ||
HorizontalAlignment="Stretch" | ||
x:Load="False" | ||
IsLightDismissEnabled="True"> | ||
<mux:TeachingTip.Content> | ||
<StackPanel HorizontalAlignment="Stretch" | ||
Orientation="Vertical"> | ||
<TextBlock x:Name="ActionSavedNameText" | ||
Visibility="{x:Bind mtu:Converters.StringNotEmptyToVisibility(SavedActionName), Mode=OneWay}"> | ||
<Run Text="Name: " /> | ||
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. 📝: I think I'm fine with these not being localized, since they're literal params to the action args, and we've got precedent for that in the cmdpal already |
||
<Run Text="{x:Bind SavedActionName, Mode=OneWay}" /> | ||
</TextBlock> | ||
<TextBlock x:Name="ActionSavedKeyChordText" | ||
Visibility="{x:Bind mtu:Converters.StringNotEmptyToVisibility(SavedActionKeyChord), Mode=OneWay}"> | ||
<Run Text="Key Chord: " /> | ||
<Run Text="{x:Bind SavedActionKeyChord, Mode=OneWay}" /> | ||
</TextBlock> | ||
<TextBlock x:Name="ActionSavedCommandLineText" | ||
Visibility="{x:Bind mtu:Converters.StringNotEmptyToVisibility(SavedActionCommandLine), Mode=OneWay}"> | ||
<Run Text="Input: " /> | ||
<Run Text="{x:Bind SavedActionCommandLine, Mode=OneWay}" /> | ||
</TextBlock> | ||
</StackPanel> | ||
</mux:TeachingTip.Content> | ||
</mux:TeachingTip> | ||
<mux:TeachingTip x:Name="ActionSaveFailedToast" | ||
x:Uid="ActionSaveFailedToast" | ||
Title="Action Save Failed" | ||
x:Load="False" | ||
IsLightDismissEnabled="True"> | ||
<mux:TeachingTip.Content> | ||
<TextBlock x:Name="ActionSaveFailedMessage" | ||
Text="" /> | ||
</mux:TeachingTip.Content> | ||
</mux:TeachingTip> | ||
</Grid> | ||
</Page> |
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 shouldn't modify the
realArgs.Commandline()
but instead extract the hstring and then modify the local reference. Like this: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.
updated