Skip to content

Commit 7a05a7c

Browse files
committed
create NavConstants.h to deduplicate code; spellcheck
1 parent c370efb commit 7a05a7c

File tree

5 files changed

+44
-59
lines changed

5 files changed

+44
-59
lines changed

src/cascadia/TerminalSettingsEditor/MainPage.cpp

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
#include "LaunchViewModel.h"
2222
#include "NewTabMenuViewModel.h"
2323
#include "NewTabMenu.h"
24+
#include "NavConstants.h"
2425
#include "..\types\inc\utils.hpp"
2526
#include <..\WinRTUtils\inc\Utils.h>
2627

2728
#include <dwmapi.h>
2829
#include <fmt/compile.h>
29-
#include <til/static_map.h>
3030

3131
namespace winrt
3232
{
@@ -42,34 +42,6 @@ using namespace winrt::Windows::System;
4242
using namespace winrt::Windows::UI::Xaml::Controls;
4343
using namespace winrt::Windows::Foundation::Collections;
4444

45-
static constexpr std::wstring_view openJsonTag{ L"OpenJson_Nav" };
46-
static constexpr std::wstring_view launchTag{ L"Launch_Nav" };
47-
static constexpr std::wstring_view interactionTag{ L"Interaction_Nav" };
48-
static constexpr std::wstring_view renderingTag{ L"Rendering_Nav" };
49-
static constexpr std::wstring_view compatibilityTag{ L"Compatibility_Nav" };
50-
static constexpr std::wstring_view actionsTag{ L"Actions_Nav" };
51-
static constexpr std::wstring_view newTabMenuTag{ L"NewTabMenu_Nav" };
52-
static constexpr std::wstring_view extensionsTag{ L"Extensions_Nav" };
53-
static constexpr std::wstring_view globalProfileTag{ L"GlobalProfile_Nav" };
54-
static constexpr std::wstring_view addProfileTag{ L"AddProfile" };
55-
static constexpr std::wstring_view colorSchemesTag{ L"ColorSchemes_Nav" };
56-
static constexpr std::wstring_view globalAppearanceTag{ L"GlobalAppearance_Nav" };
57-
58-
static constexpr til::static_map NavTagIconMap{
59-
std::pair{ launchTag, L"\xE7B5" }, /* Set Lock Screen */
60-
std::pair{ interactionTag, L"\xE7C9" }, /* Touch Pointer */
61-
std::pair{ globalAppearanceTag, L"\xE771" }, /* Personalize */
62-
std::pair{ colorSchemesTag, L"\xE790" }, /* Color */
63-
std::pair{ renderingTag, L"\xE7F8" }, /* Device Laptop No Pic */
64-
std::pair{ compatibilityTag, L"\xEC7A" }, /* Developer Tools */
65-
std::pair{ actionsTag, L"\xE765" }, /* Keyboard Classic */
66-
std::pair{ newTabMenuTag, L"\xE71D" }, /* All Apps */
67-
std::pair{ extensionsTag, L"\xEA86" }, /* Puzzle */
68-
std::pair{ globalProfileTag, L"\xE81E" }, /* Map Layers */
69-
std::pair{ addProfileTag, L"\xE710" }, /* Add */
70-
std::pair{ openJsonTag, L"\xE713" }, /* Settings */
71-
};
72-
7345
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
7446
{
7547
static WUX::Controls::FontIcon _fontIconForNavTag(const std::wstring_view navTag)

src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
</ClInclude>
9191
<ClInclude Include="pch.h" />
9292
<ClInclude Include="SearchIndex.h" />
93+
<ClInclude Include="NavConstants.h" />
9394
<ClInclude Include="MainPage.h">
9495
<DependentUpon>MainPage.xaml</DependentUpon>
9596
</ClInclude>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
#pragma once
5+
6+
#include <til/static_map.h>
7+
8+
// Navigation tags used to identify pages in the Settings UI NavigationView.
9+
// These tags are stored as the Tag property on NavigationViewItems.
10+
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
11+
{
12+
inline constexpr std::wstring_view openJsonTag{ L"OpenJson_Nav" };
13+
inline constexpr std::wstring_view launchTag{ L"Launch_Nav" };
14+
inline constexpr std::wstring_view interactionTag{ L"Interaction_Nav" };
15+
inline constexpr std::wstring_view renderingTag{ L"Rendering_Nav" };
16+
inline constexpr std::wstring_view compatibilityTag{ L"Compatibility_Nav" };
17+
inline constexpr std::wstring_view actionsTag{ L"Actions_Nav" };
18+
inline constexpr std::wstring_view newTabMenuTag{ L"NewTabMenu_Nav" };
19+
inline constexpr std::wstring_view extensionsTag{ L"Extensions_Nav" };
20+
inline constexpr std::wstring_view globalProfileTag{ L"GlobalProfile_Nav" };
21+
inline constexpr std::wstring_view addProfileTag{ L"AddProfile" };
22+
inline constexpr std::wstring_view colorSchemesTag{ L"ColorSchemes_Nav" };
23+
inline constexpr std::wstring_view globalAppearanceTag{ L"GlobalAppearance_Nav" };
24+
25+
// Map from navigation tags to Segoe MDL2 Assets icon glyphs
26+
inline constexpr til::static_map NavTagIconMap{
27+
std::pair{ launchTag, L"\xE7B5" }, /* Set Lock Screen */
28+
std::pair{ interactionTag, L"\xE7C9" }, /* Touch Pointer */
29+
std::pair{ globalAppearanceTag, L"\xE771" }, /* Personalize */
30+
std::pair{ colorSchemesTag, L"\xE790" }, /* Color */
31+
std::pair{ renderingTag, L"\xE7F8" }, /* Device Laptop No Pic */
32+
std::pair{ compatibilityTag, L"\xEC7A" }, /* Developer Tools */
33+
std::pair{ actionsTag, L"\xE765" }, /* Keyboard Classic */
34+
std::pair{ newTabMenuTag, L"\xE71D" }, /* All Apps */
35+
std::pair{ extensionsTag, L"\xEA86" }, /* Puzzle */
36+
std::pair{ globalProfileTag, L"\xE81E" }, /* Map Layers */
37+
std::pair{ addProfileTag, L"\xE710" }, /* Add */
38+
std::pair{ openJsonTag, L"\xE713" }, /* Settings */
39+
};
40+
}

src/cascadia/TerminalSettingsEditor/SearchIndex.cpp

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,10 @@
55
#include "SearchIndex.h"
66
#include "FilteredSearchResult.g.cpp"
77
#include "SearchResultTemplateSelector.g.cpp"
8+
#include "NavConstants.h"
89

910
#include <winrt/Windows.ApplicationModel.Resources.Core.h>
1011
#include <ScopedResourceLoader.h>
11-
#include <til/static_map.h>
12-
13-
static constexpr std::wstring_view openJsonTag{ L"OpenJson_Nav" };
14-
static constexpr std::wstring_view launchTag{ L"Launch_Nav" };
15-
static constexpr std::wstring_view interactionTag{ L"Interaction_Nav" };
16-
static constexpr std::wstring_view renderingTag{ L"Rendering_Nav" };
17-
static constexpr std::wstring_view compatibilityTag{ L"Compatibility_Nav" };
18-
static constexpr std::wstring_view actionsTag{ L"Actions_Nav" };
19-
static constexpr std::wstring_view newTabMenuTag{ L"NewTabMenu_Nav" };
20-
static constexpr std::wstring_view extensionsTag{ L"Extensions_Nav" };
21-
static constexpr std::wstring_view globalProfileTag{ L"GlobalProfile_Nav" };
22-
static constexpr std::wstring_view addProfileTag{ L"AddProfile" };
23-
static constexpr std::wstring_view colorSchemesTag{ L"ColorSchemes_Nav" };
24-
static constexpr std::wstring_view globalAppearanceTag{ L"GlobalAppearance_Nav" };
25-
26-
static constexpr til::static_map NavTagIconMap{
27-
std::pair{ launchTag, L"\xE7B5" }, /* Set Lock Screen */
28-
std::pair{ interactionTag, L"\xE7C9" }, /* Touch Pointer */
29-
std::pair{ globalAppearanceTag, L"\xE771" }, /* Personalize */
30-
std::pair{ colorSchemesTag, L"\xE790" }, /* Color */
31-
std::pair{ renderingTag, L"\xE7F8" }, /* Device Laptop No Pic */
32-
std::pair{ compatibilityTag, L"\xEC7A" }, /* Developer Tools */
33-
std::pair{ actionsTag, L"\xE765" }, /* Keyboard Classic */
34-
std::pair{ newTabMenuTag, L"\xE71D" }, /* All Apps */
35-
std::pair{ extensionsTag, L"\xEA86" }, /* Puzzle */
36-
std::pair{ globalProfileTag, L"\xE81E" }, /* Map Layers */
37-
std::pair{ addProfileTag, L"\xE710" }, /* Add */
38-
std::pair{ openJsonTag, L"\xE713" }, /* Settings */
39-
};
4012

4113
// Weight multipliers for search result scoring.
4214
// Higher values prioritize certain types of matches over others.

src/cascadia/TerminalSettingsEditor/SearchIndex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
9393
{
9494
IndexData& operator=(const IndexData& other) = default;
9595

96-
// Basic index data loaded from GeneratedSettingsIndex.g.h and wrapped as LocalizedIndexEntrys.
96+
// Basic index data loaded from GeneratedSettingsIndex.g.h and wrapped as LocalizedIndexEntry objects.
9797
// Non-main indices are duplicated at runtime when searching for runtime objects.
9898
std::vector<LocalizedIndexEntry> mainIndex;
9999
std::vector<LocalizedIndexEntry> profileIndex;

0 commit comments

Comments
 (0)