mirror of
https://github.com/microsoft/terminal.git
synced 2026-04-05 21:59:47 +00:00
Polish GenerateSettingsIndex.ps1 and propagate changes (#19907)
## Summary of the Pull Request Cleans up GenerateSettingsIndex.ps1 by addressing the feedback Dustin left in #19519 ## Validation Steps Performed ✅ SUI search works
This commit is contained in:
1
.github/actions/spelling/allow/allow.txt
vendored
1
.github/actions/spelling/allow/allow.txt
vendored
@@ -67,6 +67,7 @@ servicebus
|
||||
slnt
|
||||
stakeholders
|
||||
subpage
|
||||
subpages
|
||||
sustainability
|
||||
sxn
|
||||
Tencent
|
||||
|
||||
@@ -1192,7 +1192,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
const auto& indexEntry{ chosenResult->SearchIndexEntry() };
|
||||
const auto& navigationArg{ chosenResult->NavigationArg() };
|
||||
const auto& subpage{ indexEntry.Entry->SubPage };
|
||||
const auto& elementToFocus{ indexEntry.Entry->ElementName };
|
||||
const hstring elementToFocus{ indexEntry.Entry->ElementName };
|
||||
_Navigate(navigationArg, subpage, elementToFocus);
|
||||
SettingsSearchBox().Text(L"");
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
std::array<std::pair<std::optional<winrt::hstring>, int>, 2> LocalizedIndexEntry::GetSearchableFields() const
|
||||
{
|
||||
// Profile Defaults entries (DisplayTextUid starts with "Profile_") get a higher weight
|
||||
const auto weight = til::starts_with(std::wstring_view{ Entry->DisplayTextUid }, L"Profile_") ? WeightProfileDefaults : WeightDisplayTextLocalized;
|
||||
return { { { std::optional<winrt::hstring>{ Entry->DisplayTextLocalized }, weight },
|
||||
const auto weight = til::starts_with(std::wstring_view{ Entry->ResourceName }, L"Profile_") ? WeightProfileDefaults : WeightDisplayTextLocalized;
|
||||
return { { { std::optional<winrt::hstring>{ DisplayTextLocalized }, weight },
|
||||
{ DisplayTextNeutral, WeightDisplayTextNeutral } } };
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
runtimeObjContext = RS_(L"Nav_Actions/Content");
|
||||
}
|
||||
|
||||
if (const auto& displayText = searchIndexEntry->Entry->DisplayTextLocalized; !displayText.empty())
|
||||
if (const auto& displayText = searchIndexEntry->DisplayTextLocalized; !displayText.empty())
|
||||
{
|
||||
// Full index entry (for settings within runtime objects)
|
||||
// - primaryText: <displayText>
|
||||
@@ -121,7 +121,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
return *_overrideLabel;
|
||||
}
|
||||
return _SearchIndexEntry->Entry->DisplayTextLocalized;
|
||||
return _SearchIndexEntry->DisplayTextLocalized;
|
||||
}
|
||||
|
||||
bool FilteredSearchResult::IsNoResultsPlaceholder() const
|
||||
@@ -135,9 +135,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
return _NavigationArgOverride;
|
||||
}
|
||||
else if (_SearchIndexEntry)
|
||||
else if (_SearchIndexEntry && !_SearchIndexEntry->Entry->NavigationArgTag.empty())
|
||||
{
|
||||
return _SearchIndexEntry->Entry->NavigationArg;
|
||||
return box_value(hstring{ _SearchIndexEntry->Entry->NavigationArgTag });
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -253,9 +253,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
LocalizedIndexEntry localizedEntry;
|
||||
localizedEntry.Entry = &entry;
|
||||
localizedEntry.DisplayTextLocalized = GetLibraryResourceString(entry.ResourceName);
|
||||
if (shouldIncludeLanguageNeutralResources)
|
||||
{
|
||||
localizedEntry.DisplayTextNeutral = EnglishOnlyResourceLoader().GetLocalizedString(entry.DisplayTextUid);
|
||||
localizedEntry.DisplayTextNeutral = EnglishOnlyResourceLoader().GetLocalizedString(entry.ResourceName);
|
||||
}
|
||||
localizedIndex.emplace_back(std::move(localizedEntry));
|
||||
}
|
||||
|
||||
@@ -15,9 +15,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
const ScopedResourceLoader& EnglishOnlyResourceLoader() noexcept;
|
||||
|
||||
// Wrapper for IndexEntry objects.
|
||||
// Adds neutral locale, if necessary.
|
||||
// Holds localized display text from entry's ResourceName
|
||||
struct LocalizedIndexEntry
|
||||
{
|
||||
winrt::hstring DisplayTextLocalized;
|
||||
std::optional<winrt::hstring> DisplayTextNeutral = std::nullopt;
|
||||
const IndexEntry* Entry = nullptr;
|
||||
|
||||
|
||||
@@ -12,390 +12,284 @@ Directory to place generated C++ files.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$false)][string]$SourceDir,
|
||||
[Parameter(Mandatory=$false)][string]$OutputDir
|
||||
[Parameter(Mandatory=$false)][string]$SourceDir = "$PSScriptRoot\..\src\cascadia\TerminalSettingsEditor\",
|
||||
[Parameter(Mandatory=$false)][string]$OutputDir = "$PSScriptRoot\..\src\cascadia\TerminalSettingsEditor\Generated Files\"
|
||||
)
|
||||
|
||||
# Prohibited UIDs (exact match, case-insensitive by default)
|
||||
$ProhibitedUids = @(
|
||||
'Extensions_Scope',
|
||||
'Profile_MissingFontFaces',
|
||||
'Profile_ProportionalFontFaces',
|
||||
'ColorScheme_InboxSchemeDuplicate',
|
||||
'ColorScheme_ColorsHeader',
|
||||
'ColorScheme_Rename'
|
||||
"Extensions_Scope",
|
||||
"Profile_MissingFontFaces",
|
||||
"Profile_ProportionalFontFaces",
|
||||
"ColorScheme_InboxSchemeDuplicate",
|
||||
"ColorScheme_ColorsHeader",
|
||||
"ColorScheme_Rename"
|
||||
)
|
||||
|
||||
# Prohibited XAML files
|
||||
# Prohibited XAML files (already limited to Page root elements)
|
||||
$ProhibitedXamlFiles = @(
|
||||
'CommonResources.xaml',
|
||||
'KeyChordListener.xaml',
|
||||
'NullableColorPicker.xaml',
|
||||
'SettingContainerStyle.xaml',
|
||||
'AISettings.xaml',
|
||||
'Profiles_Base_Orphaned.xaml'
|
||||
"AISettings.xaml",
|
||||
"Profiles_Base_Orphaned.xaml",
|
||||
"EditAction.xaml",
|
||||
"MainPage.xaml"
|
||||
)
|
||||
|
||||
# Grouped metadata for each page class
|
||||
$ClassMap = @{
|
||||
"Microsoft::Terminal::Settings::Editor::Launch" = @{
|
||||
ResourceName = "Nav_Launch/Content"
|
||||
NavigationParam = "Launch_Nav"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
}
|
||||
"Microsoft::Terminal::Settings::Editor::Interaction" = @{
|
||||
ResourceName = "Nav_Interaction/Content"
|
||||
NavigationParam = "Interaction_Nav"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
}
|
||||
"Microsoft::Terminal::Settings::Editor::GlobalAppearance" = @{
|
||||
ResourceName = "Nav_Appearance/Content"
|
||||
NavigationParam = "GlobalAppearance_Nav"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
}
|
||||
"Microsoft::Terminal::Settings::Editor::ColorSchemes" = @{
|
||||
ResourceName = "Nav_ColorSchemes/Content"
|
||||
NavigationParam = "ColorSchemes_Nav"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
}
|
||||
"Microsoft::Terminal::Settings::Editor::Rendering" = @{
|
||||
ResourceName = "Nav_Rendering/Content"
|
||||
NavigationParam = "Rendering_Nav"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
}
|
||||
"Microsoft::Terminal::Settings::Editor::Compatibility" = @{
|
||||
ResourceName = "Nav_Compatibility/Content"
|
||||
NavigationParam = "Compatibility_Nav"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
}
|
||||
"Microsoft::Terminal::Settings::Editor::Actions" = @{
|
||||
ResourceName = "Nav_Actions/Content"
|
||||
NavigationParam = "Actions_Nav"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
}
|
||||
"Microsoft::Terminal::Settings::Editor::NewTabMenu" = @{
|
||||
ResourceName = "Nav_NewTabMenu/Content" # [Folders] Replaced with folder name
|
||||
NavigationParam = "NewTabMenu_Nav" # [Folders] Replaced with folder VM
|
||||
SubPage = "BreadcrumbSubPage::None" # [Folders] Replaced with BreadcrumbSubPage::NewTabMenu_Folder
|
||||
}
|
||||
"Microsoft::Terminal::Settings::Editor::Extensions" = @{
|
||||
ResourceName = "Nav_Extensions/Content" # [Extension] Replaced with extension name
|
||||
NavigationParam = "Extensions_Nav" # [Extension] Replaced with extension VM
|
||||
SubPage = "BreadcrumbSubPage::None" # [Extension] Replaced with BreadcrumbSubPage::Extensions_Extension
|
||||
}
|
||||
"Microsoft::Terminal::Settings::Editor::Profiles_Base" = @{
|
||||
ResourceName = "Nav_ProfileDefaults/Content"
|
||||
NavigationParam = "GlobalProfile_Nav"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
}
|
||||
"Microsoft::Terminal::Settings::Editor::Profiles_Appearance" = @{
|
||||
ResourceName = "Nav_ProfileDefaults/Content"
|
||||
NavigationParam = "GlobalProfile_Nav"
|
||||
SubPage = "BreadcrumbSubPage::Profile_Appearance"
|
||||
}
|
||||
"Microsoft::Terminal::Settings::Editor::Profiles_Terminal" = @{
|
||||
ResourceName = "Nav_ProfileDefaults/Content"
|
||||
NavigationParam = "GlobalProfile_Nav"
|
||||
SubPage = "BreadcrumbSubPage::Profile_Terminal"
|
||||
}
|
||||
"Microsoft::Terminal::Settings::Editor::Profiles_Advanced" = @{
|
||||
ResourceName = "Nav_ProfileDefaults/Content"
|
||||
NavigationParam = "GlobalProfile_Nav"
|
||||
SubPage = "BreadcrumbSubPage::Profile_Advanced"
|
||||
}
|
||||
"Microsoft::Terminal::Settings::Editor::AddProfile" = @{
|
||||
ResourceName = "Nav_AddNewProfile/Content"
|
||||
NavigationParam = "AddProfile"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
}
|
||||
}
|
||||
|
||||
function IsProfileSubPage($pageClass)
|
||||
{
|
||||
return $pageClass -match "Editor::Profiles_Appearance" -or
|
||||
$pageClass -match "Editor::Profiles_Terminal" -or
|
||||
$pageClass -match "Editor::Profiles_Advanced"
|
||||
}
|
||||
|
||||
if (-not (Test-Path $SourceDir)) { throw "SourceDir not found: $SourceDir" }
|
||||
if (-not (Test-Path $OutputDir)) { New-Item -ItemType Directory -Path $OutputDir | Out-Null }
|
||||
|
||||
$resourceKeys = ([xml](Get-Content "$($SourceDir)\Resources\en-US\Resources.resw")).root.data.name
|
||||
$entries = @()
|
||||
|
||||
Get-ChildItem -Path $SourceDir -Recurse -Filter *.xaml | ForEach-Object {
|
||||
foreach ($xamlFile in Get-ChildItem -Path $SourceDir -Filter *.xaml)
|
||||
{
|
||||
# Skip whole file if prohibited
|
||||
$filename = $_.Name
|
||||
$filename = $xamlFile.Name
|
||||
if ($ProhibitedXamlFiles -contains $filename)
|
||||
{
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
$text = Get-Content -Raw -LiteralPath $_.FullName
|
||||
# Load XAML and namespace manager
|
||||
[xml]$xml = Get-Content -LiteralPath $xamlFile.FullName
|
||||
$xm = New-Object System.Xml.XmlNamespaceManager($xml.NameTable)
|
||||
$xm.AddNamespace("local", "using:Microsoft.Terminal.Settings.Editor")
|
||||
$xm.AddNamespace("x", "http://schemas.microsoft.com/winfx/2006/xaml")
|
||||
|
||||
if ($xml.DocumentElement.LocalName -ne "Page" -and $filename -ne "Appearances.xaml")
|
||||
{
|
||||
# Only allow xaml files for Page elements (or Appearances.xaml)
|
||||
continue
|
||||
}
|
||||
|
||||
# Extract Page x:Class
|
||||
$pageClass = $null
|
||||
if ($text -match '<Page\b[^>]*\bx:Class="([^"]+)"')
|
||||
{
|
||||
$pageClass = $matches[1]
|
||||
}
|
||||
elseif ($filename -eq 'Appearances.xaml')
|
||||
{
|
||||
# Appearances.xaml is a UserControl that is hosted in Profiles_Appearance.xaml
|
||||
$pageClass = 'Microsoft::Terminal::Settings::Editor::Profiles_Appearance'
|
||||
}
|
||||
else
|
||||
{
|
||||
return
|
||||
}
|
||||
# Appearances.xaml: UserControl hosted in Profiles_Appearance.xaml
|
||||
$pageClass = $filename -eq "Appearances.xaml" ?
|
||||
"Microsoft::Terminal::Settings::Editor::Profiles_Appearance" :
|
||||
$xml.DocumentElement.SelectSingleNode("@x:Class", $xm).Value
|
||||
|
||||
# Convert XAML namespace dots to C++ scope operators
|
||||
$pageClass = ($pageClass -replace '\.', '::')
|
||||
|
||||
# Deduce BreadcrumbSubPage
|
||||
# Special cases:
|
||||
# - NewTabMenu: defer to UID, see NavigationParam section below
|
||||
# - Extensions: defer to UID, see NavigationParam section below
|
||||
$subPage = 'BreadcrumbSubPage::'
|
||||
if ($pageClass -match 'Editor::Profiles_Appearance')
|
||||
$pageClass = ($pageClass -replace "\.", "::")
|
||||
if ($ClassMap.ContainsKey(($pageClass)) -and -not (IsProfileSubPage $pageClass))
|
||||
{
|
||||
$subPage += 'Profile_Appearance'
|
||||
$entries += [pscustomobject]@{
|
||||
ResourceName = $ClassMap[$pageClass].ResourceName
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = $ClassMap[$pageClass].NavigationParam
|
||||
SubPage = $ClassMap[$pageClass].SubPage
|
||||
ElementName = $null # No specific element to navigate to for the page itself
|
||||
File = $filename
|
||||
}
|
||||
}
|
||||
elseif ($pageClass -match 'Editor::Profiles_Terminal')
|
||||
elseif ($pageClass -notmatch "Editor::EditColorScheme" -and -not (IsProfileSubPage $pageClass))
|
||||
{
|
||||
$subPage += 'Profile_Terminal'
|
||||
}
|
||||
elseif ($pageClass -match 'Editor::Profiles_Advanced')
|
||||
{
|
||||
$subPage += 'Profile_Advanced'
|
||||
}
|
||||
elseif ($pageClass -match 'Editor::EditColorScheme')
|
||||
{
|
||||
$subPage += 'ColorSchemes_Edit'
|
||||
}
|
||||
else
|
||||
{
|
||||
$subPage += 'None'
|
||||
# Special case: EditColorScheme is only valid if a color scheme is associated,
|
||||
# so don't register it in ClassMap and don't skip over it here.
|
||||
Write-Warning "No class map entry for page class $pageClass (file: $filename). Skipping automatic index generation for this page."
|
||||
continue
|
||||
}
|
||||
|
||||
# Register top-level pages
|
||||
if ($filename -eq 'Launch.xaml')
|
||||
# Manually register special entries
|
||||
if ($filename -eq "ColorSchemes.xaml")
|
||||
{
|
||||
# "add new" button
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"Nav_Launch/Content`""
|
||||
DisplayTextLocalized = "RS_(L`"Nav_Launch/Content`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = "winrt::box_value(hstring{L`"Launch_Nav`"})"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
ElementName = 'L""'
|
||||
File = $filename
|
||||
ResourceName = "ColorScheme_AddNewButton/Text"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = $ClassMap[$pageClass].NavigationParam
|
||||
SubPage = $ClassMap[$pageClass].SubPage
|
||||
ElementName = "AddNewButton"
|
||||
File = $filename
|
||||
}
|
||||
}
|
||||
elseif ($filename -eq 'Interaction.xaml')
|
||||
elseif ($filename -eq "AddProfile.xaml")
|
||||
{
|
||||
# "add new" button
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"Nav_Interaction/Content`""
|
||||
DisplayTextLocalized = "RS_(L`"Nav_Interaction/Content`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = "winrt::box_value(hstring{L`"Interaction_Nav`"})"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
ElementName = 'L""'
|
||||
File = $filename
|
||||
}
|
||||
}
|
||||
elseif ($filename -eq 'GlobalAppearance.xaml')
|
||||
{
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"Nav_Appearance/Content`""
|
||||
DisplayTextLocalized = "RS_(L`"Nav_Appearance/Content`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = "winrt::box_value(hstring{L`"GlobalAppearance_Nav`"})"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
ElementName = 'L""'
|
||||
File = $filename
|
||||
}
|
||||
}
|
||||
elseif ($filename -eq 'ColorSchemes.xaml')
|
||||
{
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"Nav_ColorSchemes/Content`""
|
||||
DisplayTextLocalized = "RS_(L`"Nav_ColorSchemes/Content`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = "winrt::box_value(hstring{L`"ColorSchemes_Nav`"})"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
ElementName = 'L""'
|
||||
File = $filename
|
||||
}
|
||||
|
||||
# Manually register the "add new" button
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"ColorScheme_AddNewButton/Text`""
|
||||
DisplayTextLocalized = 'RS_(L"ColorScheme_AddNewButton/Text")'
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = "winrt::box_value(hstring{L`"ColorSchemes_Nav`"})"
|
||||
SubPage = 'BreadcrumbSubPage::None'
|
||||
ElementName = 'L"AddNewButton"'
|
||||
File = $filename
|
||||
}
|
||||
|
||||
}
|
||||
elseif ($filename -eq 'Rendering.xaml')
|
||||
{
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"Nav_Rendering/Content`""
|
||||
DisplayTextLocalized = "RS_(L`"Nav_Rendering/Content`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = "winrt::box_value(hstring{L`"Rendering_Nav`"})"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
ElementName = 'L""'
|
||||
File = $filename
|
||||
}
|
||||
}
|
||||
elseif ($filename -eq 'Compatibility.xaml')
|
||||
{
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"Nav_Compatibility/Content`""
|
||||
DisplayTextLocalized = "RS_(L`"Nav_Compatibility/Content`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = "winrt::box_value(hstring{L`"Compatibility_Nav`"})"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
ElementName = 'L""'
|
||||
File = $filename
|
||||
}
|
||||
}
|
||||
elseif ($filename -eq 'Actions.xaml')
|
||||
{
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"Nav_Actions/Content`""
|
||||
DisplayTextLocalized = "RS_(L`"Nav_Actions/Content`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = "winrt::box_value(hstring{L`"Actions_Nav`"})"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
ElementName = 'L""'
|
||||
File = $filename
|
||||
}
|
||||
}
|
||||
elseif ($filename -eq 'NewTabMenu.xaml')
|
||||
{
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"Nav_NewTabMenu/Content`""
|
||||
DisplayTextLocalized = "RS_(L`"Nav_NewTabMenu/Content`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = "winrt::box_value(hstring{L`"NewTabMenu_Nav`"})"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
ElementName = 'L""'
|
||||
File = $filename
|
||||
}
|
||||
}
|
||||
elseif ($filename -eq 'Extensions.xaml')
|
||||
{
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"Nav_Extensions/Content`""
|
||||
DisplayTextLocalized = "RS_(L`"Nav_Extensions/Content`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = "winrt::box_value(hstring{L`"Extensions_Nav`"})"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
ElementName = 'L""'
|
||||
File = $filename
|
||||
}
|
||||
}
|
||||
elseif ($filename -eq 'Profiles_Base.xaml')
|
||||
{
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"Nav_ProfileDefaults/Content`""
|
||||
DisplayTextLocalized = "RS_(L`"Nav_ProfileDefaults/Content`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = "winrt::box_value(hstring{L`"GlobalProfile_Nav`"})"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
ElementName = 'L""'
|
||||
File = $filename
|
||||
}
|
||||
}
|
||||
elseif ($filename -eq 'AddProfile.xaml')
|
||||
{
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"Nav_AddNewProfile/Content`""
|
||||
DisplayTextLocalized = "RS_(L`"Nav_AddNewProfile/Content`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = "winrt::box_value(hstring{L`"AddProfile`"})"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
ElementName = 'L""'
|
||||
File = $filename
|
||||
}
|
||||
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"AddProfile_AddNewTextBlock/Text`""
|
||||
DisplayTextLocalized = "RS_(L`"AddProfile_AddNewTextBlock/Text`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = "winrt::box_value(hstring{L`"AddProfile`"})"
|
||||
SubPage = "BreadcrumbSubPage::None"
|
||||
ElementName = 'L"AddNewButton"'
|
||||
File = $filename
|
||||
ResourceName = "AddProfile_AddNewTextBlock/Text"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = $ClassMap[$pageClass].NavigationParam
|
||||
SubPage = $ClassMap[$pageClass].SubPage
|
||||
ElementName = "AddNewButton"
|
||||
File = $filename
|
||||
}
|
||||
}
|
||||
|
||||
# Find all local:SettingContainer start tags
|
||||
$pattern = '<local:SettingContainer\b([^>/]*)(/?>)'
|
||||
$matchesAll = [System.Text.RegularExpressions.Regex]::Matches($text, $pattern, 'IgnoreCase')
|
||||
|
||||
foreach ($m in $matchesAll)
|
||||
# Iterate over all local:SettingContainer nodes
|
||||
foreach ($settingContainer in $xml.SelectNodes("//local:SettingContainer", $xm))
|
||||
{
|
||||
$attrBlock = $m.Groups[1].Value
|
||||
|
||||
# Extract Uid
|
||||
if ($attrBlock -match '\bx:Uid="([^"]+)"')
|
||||
if ($null -eq $settingContainer.Uid)
|
||||
{
|
||||
$uid = $matches[1]
|
||||
|
||||
# Skip entry if UID prohibited
|
||||
if ($ProhibitedUids -contains $uid)
|
||||
{
|
||||
continue
|
||||
}
|
||||
Write-Warning "No x:Uid found for a SettingContainer in file $filename. Skipping entry."
|
||||
continue
|
||||
}
|
||||
else
|
||||
elseif ($ProhibitedUids -contains $settingContainer.Uid)
|
||||
{
|
||||
continue
|
||||
}
|
||||
|
||||
# Extract Name
|
||||
if ($attrBlock -match '\bx:Name="([^"]+)"')
|
||||
# Extract Name (prefer x:Name over Name)
|
||||
$name = $null -ne $settingContainer.Name ? $settingContainer.Name : ""
|
||||
if ($filename -eq "Appearances.xaml")
|
||||
{
|
||||
$name = $matches[1]
|
||||
}
|
||||
elseif ($attrBlock -match '\bName="([^"]+)"')
|
||||
{
|
||||
$name = $matches[1]
|
||||
}
|
||||
else
|
||||
{
|
||||
$name = ""
|
||||
# Profile.Appearance settings need a special prefix for the ElementName.
|
||||
# This allows us to bring the element into view at runtime.
|
||||
$name = "App." + $name
|
||||
}
|
||||
|
||||
# Profile.Appearance settings need a special prefix for the ElementName.
|
||||
# This allows us to bring the element into view at runtime.
|
||||
if ($filename -eq 'Appearances.xaml')
|
||||
{
|
||||
$name = 'App.' + $name
|
||||
}
|
||||
|
||||
# Deduce NavigationParam
|
||||
# Deduce NavigationParam and SubPage
|
||||
# includeInBuildIndex: include the entry in the build-time index (no special param at runtime)
|
||||
# includeInPartialIndex: include the entry in the partial index, where the NavigationParam is the view model at runtime (i.e. profile vs profile defaults)
|
||||
$includeInBuildIndex = $true
|
||||
$includeInPartialIndex = $false
|
||||
$navigationParam = 'nullptr'
|
||||
if ($pageClass -match 'Editor::Launch')
|
||||
$navigationParam = $ClassMap[$pageClass].NavigationParam
|
||||
$subPage = $ClassMap[$pageClass].SubPage ?? "BreadcrumbSubPage::None"
|
||||
if ($pageClass -match "Editor::NewTabMenu")
|
||||
{
|
||||
$navigationParam = 'Launch_Nav'
|
||||
}
|
||||
elseif ($pageClass -match 'Editor::Interaction')
|
||||
{
|
||||
$navigationParam = 'Interaction_Nav'
|
||||
}
|
||||
elseif ($pageClass -match 'Editor::Rendering')
|
||||
{
|
||||
$navigationParam = 'Rendering_Nav'
|
||||
}
|
||||
elseif ($pageClass -match 'Editor::Compatibility')
|
||||
{
|
||||
$navigationParam = 'Compatibility_Nav'
|
||||
}
|
||||
elseif ($pageClass -match 'Editor::Actions')
|
||||
{
|
||||
$navigationParam = 'Actions_Nav'
|
||||
}
|
||||
elseif ($pageClass -match 'Editor::NewTabMenu')
|
||||
{
|
||||
if ($uid -match 'NewTabMenu_CurrentFolder')
|
||||
if ($settingContainer.Uid -match "NewTabMenu_CurrentFolder")
|
||||
{
|
||||
$navigationParam = 'nullptr'
|
||||
$subPage = 'BreadcrumbSubPage::NewTabMenu_Folder'
|
||||
$navigationParam = $null # VM param at runtime
|
||||
$subPage = "BreadcrumbSubPage::NewTabMenu_Folder"
|
||||
$includeInBuildIndex = $false
|
||||
$includeInPartialIndex = $true
|
||||
}
|
||||
else
|
||||
{
|
||||
$navigationParam = 'NewTabMenu_Nav'
|
||||
$subPage = 'BreadcrumbSubPage::None'
|
||||
$includeInPartialIndex = $true
|
||||
}
|
||||
}
|
||||
elseif ($pageClass -match 'Editor::Extensions')
|
||||
elseif ($pageClass -match "Editor::Profiles_Base" -or (IsProfileSubPage $pageClass))
|
||||
{
|
||||
$navigationParam = 'Extensions_Nav'
|
||||
$subPage = 'BreadcrumbSubPage::None'
|
||||
}
|
||||
elseif ($pageClass -match 'Editor::Profiles_Base' -or
|
||||
$pageClass -match 'Editor::Profiles_Appearance' -or
|
||||
$pageClass -match 'Editor::Profiles_Terminal' -or
|
||||
$pageClass -match 'Editor::Profiles_Advanced')
|
||||
{
|
||||
$navigationParam = 'GlobalProfile_Nav'
|
||||
$includeInBuildIndex = !($name -eq "Name" -or $name -eq "Commandline")
|
||||
$includeInPartialIndex = $true
|
||||
}
|
||||
elseif ($pageClass -match 'Editor::EditColorScheme')
|
||||
elseif ($pageClass -match "Editor::EditColorScheme")
|
||||
{
|
||||
# populate with color scheme name at runtime
|
||||
$navigationParam = 'nullptr'
|
||||
}
|
||||
elseif ($pageClass -match 'Editor::GlobalAppearance')
|
||||
{
|
||||
$navigationParam = 'GlobalAppearance_Nav'
|
||||
}
|
||||
elseif ($pageClass -match 'Editor::AddProfile')
|
||||
{
|
||||
$navigationParam = 'AddProfile'
|
||||
$subPage = "BreadcrumbSubPage::ColorSchemes_Edit"
|
||||
$includeInBuildIndex = $false
|
||||
$includeInPartialIndex = $true
|
||||
}
|
||||
|
||||
if ($includeInBuildIndex)
|
||||
{
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"$($uid)/Header`""
|
||||
DisplayTextLocalized = "RS_(L`"$($uid)/Header`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = $navigationParam -eq "nullptr" ? $navigationParam : "winrt::box_value(hstring{L`"$($navigationParam)`"})"
|
||||
SubPage = $subPage
|
||||
ElementName = "L`"$($name)`""
|
||||
File = $filename
|
||||
ResourceName = "$($settingContainer.Uid)/Header"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = $navigationParam
|
||||
SubPage = $subPage
|
||||
ElementName = $name
|
||||
File = $filename
|
||||
}
|
||||
}
|
||||
|
||||
if ($includeInPartialIndex)
|
||||
{
|
||||
$entries += [pscustomobject]@{
|
||||
DisplayTextUid = "L`"$($uid)/Header`""
|
||||
DisplayTextLocalized = "RS_(L`"$($uid)/Header`")"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = 'nullptr' # VM param at runtime
|
||||
SubPage = $navigationParam -eq 'NewTabMenu_Nav' ? 'BreadcrumbSubPage::NewTabMenu_Folder' : $subPage
|
||||
ElementName = "L`"$($name)`""
|
||||
File = $filename
|
||||
ResourceName = "$($settingContainer.Uid)/Header"
|
||||
ParentPage = $pageClass
|
||||
NavigationParam = $null # VM param at runtime
|
||||
SubPage = $pageClass -match "Editor::NewTabMenu" ? "BreadcrumbSubPage::NewTabMenu_Folder" : $subPage
|
||||
ElementName = $name
|
||||
File = $filename
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Ensure there aren't any duplicate entries
|
||||
$entries = $entries | Sort-Object DisplayTextLocalized, ParentPage, NavigationParam, SubPage, ElementName, File -Unique
|
||||
function FormatEntry($e)
|
||||
{
|
||||
$formattedResourceName = 'USES_RESOURCE(L"{0}")' -f $e.ResourceName
|
||||
$formattedNavigationParam = 'L"{0}"' -f $e.NavigationParam # null Navigation param resolves to empty string
|
||||
$formattedElementName = 'L"{0}"' -f $e.ElementName
|
||||
|
||||
return " IndexEntry{{ {0}, {1}, {2}, {3} }}, // {4}" -f ($formattedResourceName, $formattedNavigationParam, $e.SubPage, $formattedElementName, $e.File)
|
||||
}
|
||||
|
||||
function FormatEntries($es) {
|
||||
return ($es | ForEach-Object { FormatEntry $_ }) -join "`r`n"
|
||||
}
|
||||
|
||||
# Sort and remove duplicates
|
||||
$entries = $entries | Sort-Object ResourceName, ParentPage, NavigationParam, SubPage, ElementName, File -Unique
|
||||
|
||||
$buildTimeEntries = @()
|
||||
$profileEntries = @()
|
||||
@@ -403,38 +297,33 @@ $schemeEntries = @()
|
||||
$ntmEntries = @()
|
||||
foreach ($e in $entries)
|
||||
{
|
||||
$formattedEntry = " IndexEntry{ $($e.DisplayTextUid), $($e.DisplayTextLocalized), $($e.NavigationParam), $($e.SubPage), $($e.ElementName) }, // $($e.File)"
|
||||
|
||||
if ($e.NavigationParam -eq 'nullptr' -and
|
||||
($e.ParentPage -match 'Profiles_Base' -or
|
||||
$e.ParentPage -match 'Profiles_Appearance' -or
|
||||
$e.ParentPage -match 'Profiles_Terminal' -or
|
||||
$e.ParentPage -match 'Profiles_Advanced'))
|
||||
if ($null -eq $e.NavigationParam -and $e.ParentPage -match "Profiles_")
|
||||
{
|
||||
$profileEntries += $formattedEntry
|
||||
$profileEntries += $e
|
||||
}
|
||||
elseif ($e.SubPage -eq 'BreadcrumbSubPage::ColorSchemes_Edit')
|
||||
elseif ($e.SubPage -eq "BreadcrumbSubPage::ColorSchemes_Edit")
|
||||
{
|
||||
$schemeEntries += $formattedEntry
|
||||
$schemeEntries += $e
|
||||
}
|
||||
elseif ($e.SubPage -eq 'BreadcrumbSubPage::NewTabMenu_Folder')
|
||||
elseif ($e.SubPage -eq "BreadcrumbSubPage::NewTabMenu_Folder")
|
||||
{
|
||||
$ntmEntries += $formattedEntry
|
||||
$ntmEntries += $e
|
||||
}
|
||||
else
|
||||
{
|
||||
$buildTimeEntries += $formattedEntry
|
||||
$buildTimeEntries += $e
|
||||
}
|
||||
}
|
||||
|
||||
$headerPath = Join-Path $OutputDir 'GeneratedSettingsIndex.g.h'
|
||||
$cppPath = Join-Path $OutputDir 'GeneratedSettingsIndex.g.cpp'
|
||||
$headerPath = Join-Path $OutputDir "GeneratedSettingsIndex.g.h"
|
||||
$cppPath = Join-Path $OutputDir "GeneratedSettingsIndex.g.cpp"
|
||||
|
||||
$header = @"
|
||||
/*++
|
||||
Copyright (c) Microsoft Corporation
|
||||
Licensed under the MIT license.
|
||||
--*/
|
||||
// This file is automatically generated by tools\GenerateSettingsIndex.ps1. Changes to this file may be overwritten.
|
||||
#pragma once
|
||||
#include <winrt/Windows.UI.Xaml.Interop.h>
|
||||
|
||||
@@ -442,20 +331,20 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
struct IndexEntry
|
||||
{
|
||||
// x:Uid of the SettingContainer's Header (i.e. "Globals_DefaultProfile/Header")
|
||||
hstring DisplayTextUid;
|
||||
|
||||
// Localized display text shown in the SettingContainer (i.e. RS_(L"Globals_DefaultProfile/Header"))
|
||||
hstring DisplayTextLocalized;
|
||||
|
||||
// Navigation argument (i.e. winrt::box_value(hstring) or nullptr)
|
||||
// Use nullptr as placeholder for runtime navigation with a view model object
|
||||
winrt::Windows::Foundation::IInspectable NavigationArg;
|
||||
// Resource name of the SettingContainer's Header (i.e. "Globals_DefaultProfile/Header")
|
||||
// NOTE: wrapped in USES_RESOURCE() to take advantage of compile-time resource name validation in ResourceLoader
|
||||
wil::zwstring_view ResourceName;
|
||||
|
||||
// Navigation argument
|
||||
// - the tag used to identify the page to navigate to (i.e. "Launch_Nav")
|
||||
// - empty if the NavigationArg is meant to be a view model object at runtime (i.e. profile, ntm folder, etc.)
|
||||
wil::zwstring_view NavigationArgTag;
|
||||
|
||||
// SubPage to navigate to for pages with multiple subpages (i.e. Profiles, New Tab Menu)
|
||||
BreadcrumbSubPage SubPage;
|
||||
|
||||
// x:Name of the SettingContainer to navigate to on the page (i.e. "DefaultProfile")
|
||||
hstring ElementName;
|
||||
wil::zwstring_view ElementName;
|
||||
};
|
||||
|
||||
const std::array<IndexEntry, $($buildTimeEntries.Count)>& LoadBuildTimeIndex();
|
||||
@@ -474,77 +363,86 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
$cpp = @"
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
// This file is automatically generated by tools\GenerateSettingsIndex.ps1. Changes to this file may be overwritten.
|
||||
|
||||
#include "pch.h"
|
||||
#include <winrt/Microsoft.Terminal.Settings.Editor.h>
|
||||
#include "GeneratedSettingsIndex.g.h"
|
||||
#include <LibraryResources.h>
|
||||
|
||||
// In Debug builds, USES_RESOURCE() expands to a lambda (for resource validation),
|
||||
// which prevents constexpr evaluation. In Release it's a no-op identity macro.
|
||||
#ifdef _DEBUG
|
||||
#define STATIC_INDEX_QUALIFIER static const
|
||||
#else
|
||||
#define STATIC_INDEX_QUALIFIER static constexpr
|
||||
#endif
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
const std::array<IndexEntry, $($buildTimeEntries.Count)>& LoadBuildTimeIndex()
|
||||
{
|
||||
static std::array<IndexEntry, $($buildTimeEntries.Count)> entries =
|
||||
STATIC_INDEX_QUALIFIER std::array entries =
|
||||
{
|
||||
$( ($buildTimeEntries -join "`r`n") )
|
||||
$(FormatEntries $buildTimeEntries)
|
||||
};
|
||||
return entries;
|
||||
}
|
||||
|
||||
const std::array<IndexEntry, $($profileEntries.Count)>& LoadProfileIndex()
|
||||
{
|
||||
static std::array<IndexEntry, $($profileEntries.Count)> entries =
|
||||
STATIC_INDEX_QUALIFIER std::array entries =
|
||||
{
|
||||
$( ($profileEntries -join "`r`n") )
|
||||
$(FormatEntries $profileEntries)
|
||||
};
|
||||
return entries;
|
||||
}
|
||||
|
||||
const std::array<IndexEntry, $($ntmEntries.Count)>& LoadNTMFolderIndex()
|
||||
{
|
||||
static std::array<IndexEntry, $($ntmEntries.Count)> entries =
|
||||
STATIC_INDEX_QUALIFIER std::array entries =
|
||||
{
|
||||
$( ($ntmEntries -join "`r`n") )
|
||||
$(FormatEntries $ntmEntries)
|
||||
};
|
||||
return entries;
|
||||
}
|
||||
|
||||
const std::array<IndexEntry, $($schemeEntries.Count)>& LoadColorSchemeIndex()
|
||||
{
|
||||
static std::array<IndexEntry, $($schemeEntries.Count)> entries =
|
||||
STATIC_INDEX_QUALIFIER std::array entries =
|
||||
{
|
||||
$( ($schemeEntries -join "`r`n") )
|
||||
$(FormatEntries $schemeEntries)
|
||||
};
|
||||
return entries;
|
||||
}
|
||||
|
||||
const IndexEntry& PartialProfileIndexEntry()
|
||||
{
|
||||
static IndexEntry entry{ L"", L"", nullptr, BreadcrumbSubPage::None, L"" };
|
||||
static constexpr IndexEntry entry{ .SubPage = BreadcrumbSubPage::None };
|
||||
return entry;
|
||||
}
|
||||
|
||||
const IndexEntry& PartialNTMFolderIndexEntry()
|
||||
{
|
||||
static IndexEntry entry{ L"", L"", nullptr, BreadcrumbSubPage::NewTabMenu_Folder, L"" };
|
||||
static constexpr IndexEntry entry{ .SubPage = BreadcrumbSubPage::NewTabMenu_Folder };
|
||||
return entry;
|
||||
}
|
||||
|
||||
const IndexEntry& PartialColorSchemeIndexEntry()
|
||||
{
|
||||
static IndexEntry entry{ L"", L"", nullptr, BreadcrumbSubPage::ColorSchemes_Edit, L"" };
|
||||
static constexpr IndexEntry entry{ .SubPage = BreadcrumbSubPage::ColorSchemes_Edit };
|
||||
return entry;
|
||||
}
|
||||
|
||||
const IndexEntry& PartialExtensionIndexEntry()
|
||||
{
|
||||
static IndexEntry entry{ L"", L"", nullptr, BreadcrumbSubPage::Extensions_Extension, L"" };
|
||||
static constexpr IndexEntry entry{ .SubPage = BreadcrumbSubPage::Extensions_Extension };
|
||||
return entry;
|
||||
}
|
||||
|
||||
const IndexEntry& PartialActionIndexEntry()
|
||||
{
|
||||
static IndexEntry entry{ L"", L"", nullptr, BreadcrumbSubPage::Actions_Edit, L"" };
|
||||
static constexpr IndexEntry entry{ .SubPage = BreadcrumbSubPage::Actions_Edit };
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user