Skip to content

Add reflection to the ActionArgs in the settings model #18915

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

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d973836
settings model reflection
PankajBhojwani May 14, 2025
ce8b31b
use x-macro here instead
PankajBhojwani May 14, 2025
72e9b64
format
PankajBhojwani May 15, 2025
9618831
first nits
PankajBhojwani May 16, 2025
6557d17
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani May 29, 2025
d62ede4
init as nullptr
PankajBhojwani May 29, 2025
18830be
change this back
PankajBhojwani May 29, 2025
035b341
static actionargfactory class
PankajBhojwani May 30, 2025
80924f2
rename and separate interface
PankajBhojwani May 30, 2025
46b036b
folder path, only capitalize first letter
PankajBhojwani May 30, 2025
b0ba0df
deduplicate resource strings
PankajBhojwani Jun 2, 2025
e2b2d46
new tab menu updates with id changes
PankajBhojwani Jun 2, 2025
cdb9599
name fix
PankajBhojwani Jun 2, 2025
0227969
undef the correct thing
PankajBhojwani Jun 3, 2025
0cb802e
format
PankajBhojwani Jun 3, 2025
a611189
move to action map
PankajBhojwani Jun 13, 2025
67a1b4e
alphabetical
PankajBhojwani Jun 13, 2025
54681b4
localized arg names
PankajBhojwani Jun 20, 2025
10b8475
rename
PankajBhojwani Jun 20, 2025
2f4a0c9
Arg_desc
PankajBhojwani Jun 23, 2025
da0a7a0
conflict
PankajBhojwani Aug 12, 2025
c5dd430
const vectors, rename to typeHint
PankajBhojwani Aug 13, 2025
2b1ffd4
__COUNTER__, lazy init static arg descriptors
PankajBhojwani Aug 14, 2025
ccfb4bd
format
PankajBhojwani Aug 14, 2025
06c051b
+1
PankajBhojwani Aug 15, 2025
19fb26d
split pane args fix
PankajBhojwani Aug 15, 2025
981a01e
don't need this anymore
PankajBhojwani Aug 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 1 addition & 107 deletions src/cascadia/TerminalSettingsModel/ActionAndArgs.cpp
Original file line number Diff line number Diff line change
@@ -342,107 +342,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation

winrt::hstring ActionAndArgs::GenerateName(const winrt::Windows::ApplicationModel::Resources::Core::ResourceContext& context) const
{
// Sentinel used to indicate this command must ALWAYS be generated by GenerateName
static constexpr wil::zwstring_view MustGenerate{};
// Use a magic static to initialize this map, because we won't be able
// to load the resources at _init_, only at runtime.
static const auto GeneratedActionNames = []() {
return std::unordered_map<ShortcutAction, wil::zwstring_view>{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW this should've used a til::static_map or some equivalent of it.

{ ShortcutAction::AdjustFontSize, USES_RESOURCE(L"AdjustFontSizeCommandKey") },
{ ShortcutAction::CloseOtherPanes, USES_RESOURCE(L"CloseOtherPanesCommandKey") },
{ ShortcutAction::CloseOtherTabs, MustGenerate },
{ ShortcutAction::ClosePane, USES_RESOURCE(L"ClosePaneCommandKey") },
{ ShortcutAction::CloseTab, MustGenerate },
{ ShortcutAction::CloseTabsAfter, MustGenerate },
{ ShortcutAction::CloseWindow, USES_RESOURCE(L"CloseWindowCommandKey") },
{ ShortcutAction::CopyText, USES_RESOURCE(L"CopyTextCommandKey") },
{ ShortcutAction::DuplicateTab, USES_RESOURCE(L"DuplicateTabCommandKey") },
{ ShortcutAction::ExecuteCommandline, USES_RESOURCE(L"ExecuteCommandlineCommandKey") },
{ ShortcutAction::Find, USES_RESOURCE(L"FindCommandKey") },
{ ShortcutAction::Invalid, MustGenerate },
{ ShortcutAction::MoveFocus, USES_RESOURCE(L"MoveFocusCommandKey") },
{ ShortcutAction::MovePane, USES_RESOURCE(L"MovePaneCommandKey") },
{ ShortcutAction::SwapPane, USES_RESOURCE(L"SwapPaneCommandKey") },
{ ShortcutAction::NewTab, USES_RESOURCE(L"NewTabCommandKey") },
{ ShortcutAction::NextTab, USES_RESOURCE(L"NextTabCommandKey") },
{ ShortcutAction::OpenNewTabDropdown, USES_RESOURCE(L"OpenNewTabDropdownCommandKey") },
{ ShortcutAction::OpenSettings, USES_RESOURCE(L"OpenSettingsUICommandKey") },
{ ShortcutAction::OpenTabColorPicker, USES_RESOURCE(L"OpenTabColorPickerCommandKey") },
{ ShortcutAction::PasteText, USES_RESOURCE(L"PasteTextCommandKey") },
{ ShortcutAction::PrevTab, USES_RESOURCE(L"PrevTabCommandKey") },
{ ShortcutAction::RenameTab, USES_RESOURCE(L"ResetTabNameCommandKey") },
{ ShortcutAction::OpenTabRenamer, USES_RESOURCE(L"OpenTabRenamerCommandKey") },
{ ShortcutAction::ResetFontSize, USES_RESOURCE(L"ResetFontSizeCommandKey") },
{ ShortcutAction::ResizePane, USES_RESOURCE(L"ResizePaneCommandKey") },
{ ShortcutAction::ScrollDown, USES_RESOURCE(L"ScrollDownCommandKey") },
{ ShortcutAction::ScrollDownPage, USES_RESOURCE(L"ScrollDownPageCommandKey") },
{ ShortcutAction::ScrollUp, USES_RESOURCE(L"ScrollUpCommandKey") },
{ ShortcutAction::ScrollUpPage, USES_RESOURCE(L"ScrollUpPageCommandKey") },
{ ShortcutAction::ScrollToTop, USES_RESOURCE(L"ScrollToTopCommandKey") },
{ ShortcutAction::ScrollToBottom, USES_RESOURCE(L"ScrollToBottomCommandKey") },
{ ShortcutAction::ScrollToMark, USES_RESOURCE(L"ScrollToPreviousMarkCommandKey") },
{ ShortcutAction::AddMark, USES_RESOURCE(L"AddMarkCommandKey") },
{ ShortcutAction::ClearMark, USES_RESOURCE(L"ClearMarkCommandKey") },
{ ShortcutAction::ClearAllMarks, USES_RESOURCE(L"ClearAllMarksCommandKey") },
{ ShortcutAction::SendInput, MustGenerate },
{ ShortcutAction::SetColorScheme, MustGenerate },
{ ShortcutAction::SetTabColor, USES_RESOURCE(L"ResetTabColorCommandKey") },
{ ShortcutAction::SplitPane, USES_RESOURCE(L"SplitPaneCommandKey") },
{ ShortcutAction::SwitchToTab, USES_RESOURCE(L"SwitchToTabCommandKey") },
{ ShortcutAction::TabSearch, USES_RESOURCE(L"TabSearchCommandKey") },
{ ShortcutAction::ToggleAlwaysOnTop, USES_RESOURCE(L"ToggleAlwaysOnTopCommandKey") },
{ ShortcutAction::ToggleCommandPalette, MustGenerate },
{ ShortcutAction::SaveSnippet, MustGenerate },
{ ShortcutAction::Suggestions, MustGenerate },
{ ShortcutAction::ToggleFocusMode, USES_RESOURCE(L"ToggleFocusModeCommandKey") },
{ ShortcutAction::SetFocusMode, MustGenerate },
{ ShortcutAction::ToggleFullscreen, USES_RESOURCE(L"ToggleFullscreenCommandKey") },
{ ShortcutAction::SetFullScreen, MustGenerate },
{ ShortcutAction::SetMaximized, MustGenerate },
{ ShortcutAction::TogglePaneZoom, USES_RESOURCE(L"TogglePaneZoomCommandKey") },
{ ShortcutAction::ToggleSplitOrientation, USES_RESOURCE(L"ToggleSplitOrientationCommandKey") },
{ ShortcutAction::ToggleShaderEffects, USES_RESOURCE(L"ToggleShaderEffectsCommandKey") },
{ ShortcutAction::MoveTab, MustGenerate },
{ ShortcutAction::BreakIntoDebugger, USES_RESOURCE(L"BreakIntoDebuggerCommandKey") },
{ ShortcutAction::FindMatch, MustGenerate },
{ ShortcutAction::TogglePaneReadOnly, USES_RESOURCE(L"TogglePaneReadOnlyCommandKey") },
{ ShortcutAction::EnablePaneReadOnly, USES_RESOURCE(L"EnablePaneReadOnlyCommandKey") },
{ ShortcutAction::DisablePaneReadOnly, USES_RESOURCE(L"DisablePaneReadOnlyCommandKey") },
{ ShortcutAction::NewWindow, USES_RESOURCE(L"NewWindowCommandKey") },
{ ShortcutAction::IdentifyWindow, USES_RESOURCE(L"IdentifyWindowCommandKey") },
{ ShortcutAction::IdentifyWindows, USES_RESOURCE(L"IdentifyWindowsCommandKey") },
{ ShortcutAction::RenameWindow, USES_RESOURCE(L"ResetWindowNameCommandKey") },
{ ShortcutAction::OpenWindowRenamer, USES_RESOURCE(L"OpenWindowRenamerCommandKey") },
{ ShortcutAction::DisplayWorkingDirectory, USES_RESOURCE(L"DisplayWorkingDirectoryCommandKey") },
{ ShortcutAction::GlobalSummon, MustGenerate },
{ ShortcutAction::SearchForText, MustGenerate },
{ ShortcutAction::QuakeMode, USES_RESOURCE(L"QuakeModeCommandKey") },
{ ShortcutAction::FocusPane, MustGenerate },
{ ShortcutAction::OpenSystemMenu, USES_RESOURCE(L"OpenSystemMenuCommandKey") },
{ ShortcutAction::ExportBuffer, MustGenerate },
{ ShortcutAction::ClearBuffer, MustGenerate },
{ ShortcutAction::MultipleActions, MustGenerate },
{ ShortcutAction::Quit, USES_RESOURCE(L"QuitCommandKey") },
{ ShortcutAction::AdjustOpacity, MustGenerate },
{ ShortcutAction::RestoreLastClosed, USES_RESOURCE(L"RestoreLastClosedCommandKey") },
{ ShortcutAction::SelectCommand, MustGenerate },
{ ShortcutAction::SelectOutput, MustGenerate },
{ ShortcutAction::SelectAll, USES_RESOURCE(L"SelectAllCommandKey") },
{ ShortcutAction::MarkMode, USES_RESOURCE(L"MarkModeCommandKey") },
{ ShortcutAction::ToggleBlockSelection, USES_RESOURCE(L"ToggleBlockSelectionCommandKey") },
{ ShortcutAction::SwitchSelectionEndpoint, USES_RESOURCE(L"SwitchSelectionEndpointCommandKey") },
{ ShortcutAction::ColorSelection, MustGenerate },
{ ShortcutAction::ShowContextMenu, USES_RESOURCE(L"ShowContextMenuCommandKey") },
{ ShortcutAction::ExpandSelectionToWord, USES_RESOURCE(L"ExpandSelectionToWordCommandKey") },
{ ShortcutAction::RestartConnection, USES_RESOURCE(L"RestartConnectionKey") },
{ ShortcutAction::ToggleBroadcastInput, USES_RESOURCE(L"ToggleBroadcastInputCommandKey") },
{ ShortcutAction::OpenScratchpad, USES_RESOURCE(L"OpenScratchpadKey") },
{ ShortcutAction::OpenAbout, USES_RESOURCE(L"OpenAboutCommandKey") },
{ ShortcutAction::QuickFix, USES_RESOURCE(L"QuickFixCommandKey") },
{ ShortcutAction::OpenCWD, USES_RESOURCE(L"OpenCWDCommandKey") },
};
}();

if (_Args)
{
auto nameFromArgs = _Args.GenerateName(context);
@@ -452,12 +351,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
}
}

const auto found = GeneratedActionNames.find(_Action);
if (found != GeneratedActionNames.end() && !found->second.empty())
{
return GetLibraryResourceLoader().ResourceMap().GetValue(found->second, context).ValueAsString();
}
return winrt::hstring{};
return ActionArgFactory::GetNameForAction(_Action, context);
}

winrt::hstring ActionAndArgs::GenerateName() const
Loading
Oops, something went wrong.
Loading
Oops, something went wrong.