Skip to content

Commit

Permalink
add an action for just identifying one single window
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Mar 1, 2021
1 parent 9270e0f commit 1f0dceb
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 12 deletions.
15 changes: 15 additions & 0 deletions src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,22 @@ namespace winrt::TerminalApp::implementation
void TerminalPage::_HandleIdentifyWindows(const IInspectable& /*sender*/,
const ActionEventArgs& args)
{
// Raise a IdentifyWindowsRequested event. This will bubble up to the
// AppLogic, to the AppHost, to the Peasant, to the Monarch, then get
// distributed down to _all_ the Peasants, as to display info about the
// window in _every_ Peasant window.
//
// This action is also buggy right now, because TeachingTips behave
// weird in XAML Islands. See microsoft-ui-xaml#4382
_IdentifyWindowsRequestedHandlers(*this, nullptr);
args.Handled(true);
}
void TerminalPage::_HandleIdentifyWindow(const IInspectable& /*sender*/,
const ActionEventArgs& args)
{
// Unlike _HandleIdentifyWindow**s**, this event just displays the
// window ID and name in the current window.
IdentifyWindow();
args.Handled(true);
}
}
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/ShortcutActionDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ namespace winrt::TerminalApp::implementation
ACTION_CASE(FindMatch);
ACTION_CASE(TogglePaneReadOnly);
ACTION_CASE(NewWindow);
ACTION_CASE(IdentifyWindow);
ACTION_CASE(IdentifyWindows);
default:
return false;
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/ShortcutActionDispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ namespace winrt::TerminalApp::implementation
DECLARE_ACTION(FindMatch);
DECLARE_ACTION(TogglePaneReadOnly);
DECLARE_ACTION(NewWindow);
DECLARE_ACTION(IdentifyWindow);
DECLARE_ACTION(IdentifyWindows);
// clang-format on

Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/ShortcutActionDispatch.idl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace TerminalApp
ACTION_EVENT(FindMatch);
ACTION_EVENT(TogglePaneReadOnly);
ACTION_EVENT(NewWindow);
ACTION_EVENT(IdentifyWindow);
ACTION_EVENT(IdentifyWindows);

}
Expand Down
21 changes: 12 additions & 9 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,7 @@ namespace winrt::TerminalApp::implementation
HOOKUP_ACTION(FindMatch);
HOOKUP_ACTION(TogglePaneReadOnly);
HOOKUP_ACTION(NewWindow);
HOOKUP_ACTION(IdentifyWindow);
HOOKUP_ACTION(IdentifyWindows);
}

Expand Down Expand Up @@ -3291,24 +3292,26 @@ namespace winrt::TerminalApp::implementation
}
}

// Method Description:
// - Display the name and ID of this window in a TeachingTip. If the window
// has no name, the name will be presented as "<unnamed-window>".
// - This can be invoked by either:
// * An identifyWindow action, that displays the info only for the current
// window
// * An identifyWindows action, that displays the info for all windows.
// Arguments:
// - <none>
// Return Value:
// - <none>
winrt::fire_and_forget TerminalPage::IdentifyWindow()
{
auto weakThis{ get_weak() };
// co_await 3s;
co_await winrt::resume_foreground(Dispatcher());
if (auto page{ weakThis.get() })
{
page->WindowIdToast().IsOpen(true);
}
}
// winrt::hstring TerminalPage::WindowName()
// {
// return L"<unnamed-window>";
// }
// uint64_t TerminalPage::WindowId()
// {
// return 42;
// }

// -------------------------------- WinRT Events ---------------------------------
// Winrt events need a method for adding a callback to the event and removing the callback.
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ namespace winrt::TerminalApp::implementation
DECLARE_ACTION_HANDLER(FindMatch);
DECLARE_ACTION_HANDLER(TogglePaneReadOnly);
DECLARE_ACTION_HANDLER(NewWindow);
DECLARE_ACTION_HANDLER(IdentifyWindow);
DECLARE_ACTION_HANDLER(IdentifyWindows);
// Make sure to hook new actions up in _RegisterActionCallbacks!
#pragma endregion
Expand Down
3 changes: 3 additions & 0 deletions src/cascadia/TerminalSettingsModel/ActionAndArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static constexpr std::string_view BreakIntoDebuggerKey{ "breakIntoDebugger" };
static constexpr std::string_view FindMatchKey{ "findMatch" };
static constexpr std::string_view TogglePaneReadOnlyKey{ "toggleReadOnlyMode" };
static constexpr std::string_view NewWindowKey{ "newWindow" };
static constexpr std::string_view IdentifyWindowKey{ "identifyWindow" };
static constexpr std::string_view IdentifyWindowsKey{ "identifyWindows" };

static constexpr std::string_view ActionKey{ "action" };
Expand Down Expand Up @@ -120,6 +121,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
{ FindMatchKey, ShortcutAction::FindMatch },
{ TogglePaneReadOnlyKey, ShortcutAction::TogglePaneReadOnly },
{ NewWindowKey, ShortcutAction::NewWindow },
{ IdentifyWindowKey, ShortcutAction::IdentifyWindow },
{ IdentifyWindowsKey, ShortcutAction::IdentifyWindows },
};

Expand Down Expand Up @@ -324,6 +326,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
{ ShortcutAction::FindMatch, L"" }, // Intentionally omitted, must be generated by GenerateName
{ ShortcutAction::TogglePaneReadOnly, RS_(L"TogglePaneReadOnlyCommandKey") },
{ ShortcutAction::NewWindow, RS_(L"NewWindowCommandKey") },
{ ShortcutAction::IdentifyWindow, RS_(L"IdentifyWindowCommandKey") },
{ ShortcutAction::IdentifyWindows, RS_(L"IdentifyWindowsCommandKey") },
};
}();
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsModel/KeyMapping.idl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace Microsoft.Terminal.Settings.Model
TogglePaneReadOnly,
FindMatch,
NewWindow,
IdentifyWindow,
IdentifyWindows
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@
<data name="NewWindowCommandKey" xml:space="preserve">
<value>New window</value>
</data>
<data name="IdentifyWindowCommandKey" xml:space="preserve">
<value>Identify window</value>
</data>
<data name="IdentifyWindowsCommandKey" xml:space="preserve">
<value>Identify windows</value>
</data>
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsModel/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@
{ "command": "openTabRenamer" },
{ "command": "commandPalette", "keys":"ctrl+shift+p" },

{ "command": "identifyWindow" },

// Tab Management
// "command": "closeTab" is unbound by default.
// The closeTab command closes a tab without confirmation, even if it has multiple panes.
Expand Down
8 changes: 5 additions & 3 deletions tools/GenerateHeaderForJson.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ Write-Output "// THIS IS AN AUTO-GENERATED FILE" | Out-File -FilePath $OutPath -
Write-Output "// Generated from " | Out-File -FilePath $OutPath -Encoding ASCII -Append -NoNewline
$fullPath = Resolve-Path -Path $JsonFile
Write-Output $fullPath.Path | Out-File -FilePath $OutPath -Encoding ASCII -Append
Write-Output "constexpr std::string_view $($VariableName){ R`"(" | Out-File -FilePath $OutPath -Encoding ASCII -Append -NoNewline
Write-Output $jsonData | Out-File -FilePath $OutPath -Encoding ASCII -Append
Write-Output ")`" };" | Out-File -FilePath $OutPath -Encoding ASCII -Append
Write-Output "constexpr std::string_view $($VariableName){ " | Out-File -FilePath $OutPath -Encoding ASCII -Append -NoNewline
$jsonData | foreach {
Write-Output "R`"($_`n)`"" | Out-File -FilePath $OutPath -Encoding ASCII -Append
}
Write-Output "};" | Out-File -FilePath $OutPath -Encoding ASCII -Append

1 comment on commit 1f0dceb

@github-actions

This comment was marked as outdated.

Please sign in to comment.