a toast for showing the CWD of the Terminal. This is for debugging

This commit is contained in:
Mike Griese
2023-05-01 14:20:00 -05:00
parent 816f8b2026
commit 072620625a
8 changed files with 51 additions and 1 deletions

View File

@@ -1021,6 +1021,13 @@ namespace winrt::TerminalApp::implementation
args.Handled(true);
}
void TerminalPage::_HandleDisplayWorkingDirectory(const IInspectable& /*sender*/,
const ActionEventArgs& args)
{
ShowTerminalWorkingDirectory();
args.Handled(true);
}
void TerminalPage::_HandleGlobalSummon(const IInspectable& /*sender*/,
const ActionEventArgs& args)
{

View File

@@ -700,6 +700,9 @@
<data name="RenameFailedToast.Subtitle" xml:space="preserve">
<value>Another window with that name already exists</value>
</data>
<data name="WindowCwdToast.Subtitle" xml:space="preserve">
<value>This is the CWD of the Terminal window itself</value>
</data>
<data name="WindowMaximizeButtonToolTip" xml:space="preserve">
<value>Maximize</value>
</data>
@@ -823,4 +826,4 @@
<data name="ClosePaneToolTip" xml:space="preserve">
<value>Close the active pane if multiple panes are present</value>
</data>
</root>
</root>

View File

@@ -4067,6 +4067,33 @@ namespace winrt::TerminalApp::implementation
}
}
winrt::fire_and_forget TerminalPage::ShowTerminalWorkingDirectory()
{
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->_windowCwdToast == nullptr)
{
if (auto tip{ page->FindName(L"WindowCwdToast").try_as<MUX::Controls::TeachingTip>() })
{
page->_windowCwdToast = 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(WindowCwdToast().try_as<winrt::Windows::UI::Xaml::FrameworkElement>());
if (page->_windowCwdToast != nullptr)
{
page->_windowCwdToast->Open();
}
}
}
// Method Description:
// - Called when the user hits the "Ok" button on the WindowRenamer TeachingTip.
// - Will raise an event that will bubble up to the monarch, asking if this

View File

@@ -149,6 +149,7 @@ namespace winrt::TerminalApp::implementation
winrt::fire_and_forget IdentifyWindow();
winrt::fire_and_forget RenameFailed();
winrt::fire_and_forget ShowTerminalWorkingDirectory();
winrt::fire_and_forget ProcessStartupActions(Windows::Foundation::Collections::IVector<Microsoft::Terminal::Settings::Model::ActionAndArgs> actions,
const bool initial,
@@ -257,6 +258,7 @@ namespace winrt::TerminalApp::implementation
std::shared_ptr<Toast> _windowIdToast{ nullptr };
std::shared_ptr<Toast> _windowRenameFailedToast{ nullptr };
std::shared_ptr<Toast> _windowCwdToast{ nullptr };
winrt::Windows::UI::Xaml::Controls::TextBox::LayoutUpdated_revoker _renamerLayoutUpdatedRevoker;
int _renamerLayoutCount{ 0 };

View File

@@ -205,5 +205,12 @@
Text="{x:Bind WindowProperties.WindowName, Mode=OneWay}" />
</mux:TeachingTip.Content>
</mux:TeachingTip>
<mux:TeachingTip x:Name="WindowCwdToast"
x:Uid="WindowCwdToast"
Title="{x:Bind WindowProperties.VirtualWorkingDirectory, Mode=OneWay}"
x:Load="False"
IsLightDismissEnabled="True"
Subtitle="{x:Bind WindowProperties.VirtualWorkingDirectory, Mode=OneWay}" />
</Grid>
</Page>

View File

@@ -72,6 +72,7 @@ static constexpr std::string_view IdentifyWindowKey{ "identifyWindow" };
static constexpr std::string_view IdentifyWindowsKey{ "identifyWindows" };
static constexpr std::string_view RenameWindowKey{ "renameWindow" };
static constexpr std::string_view OpenWindowRenamerKey{ "openWindowRenamer" };
static constexpr std::string_view DisplayWorkingDirectoryKey{ "displayTerminalCwd" };
static constexpr std::string_view GlobalSummonKey{ "globalSummon" };
static constexpr std::string_view QuakeModeKey{ "quakeMode" };
static constexpr std::string_view FocusPaneKey{ "focusPane" };
@@ -401,6 +402,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
{ ShortcutAction::IdentifyWindows, RS_(L"IdentifyWindowsCommandKey") },
{ ShortcutAction::RenameWindow, RS_(L"ResetWindowNameCommandKey") },
{ ShortcutAction::OpenWindowRenamer, RS_(L"OpenWindowRenamerCommandKey") },
{ ShortcutAction::DisplayWorkingDirectory, L"Display Terminal's CWD TODO! localize" },
{ ShortcutAction::GlobalSummon, MustGenerate },
{ ShortcutAction::QuakeMode, RS_(L"QuakeModeCommandKey") },
{ ShortcutAction::FocusPane, MustGenerate },

View File

@@ -85,6 +85,7 @@
ON_ALL_ACTIONS(IdentifyWindows) \
ON_ALL_ACTIONS(RenameWindow) \
ON_ALL_ACTIONS(OpenWindowRenamer) \
ON_ALL_ACTIONS(DisplayWorkingDirectory) \
ON_ALL_ACTIONS(GlobalSummon) \
ON_ALL_ACTIONS(QuakeMode) \
ON_ALL_ACTIONS(FocusPane) \

View File

@@ -374,6 +374,7 @@
{ "command": "openSystemMenu", "keys": "alt+space" },
{ "command": "quit" },
{ "command": "restoreLastClosed"},
{ "command": "displayTerminalCwd"},
// Tab Management
// "command": "closeTab" is unbound by default.