diff --git a/src/cascadia/LocalTests_TerminalApp/ColorSchemeTests.cpp b/src/cascadia/LocalTests_TerminalApp/ColorSchemeTests.cpp index ab56263cad0..e59d022f526 100644 --- a/src/cascadia/LocalTests_TerminalApp/ColorSchemeTests.cpp +++ b/src/cascadia/LocalTests_TerminalApp/ColorSchemeTests.cpp @@ -195,7 +195,7 @@ namespace TerminalAppLocalTests CascadiaSettings settings; - VERIFY_ARE_EQUAL(0u, settings._globals.GetColorSchemes().size()); + VERIFY_ARE_EQUAL(0u, settings._globals->GetColorSchemes().Size()); VERIFY_IS_NULL(settings._FindMatchingColorScheme(scheme0Json)); VERIFY_IS_NULL(settings._FindMatchingColorScheme(scheme1Json)); VERIFY_IS_NULL(settings._FindMatchingColorScheme(scheme2Json)); @@ -203,15 +203,15 @@ namespace TerminalAppLocalTests settings._LayerOrCreateColorScheme(scheme0Json); { - for (auto& kv : settings._globals._colorSchemes) + for (auto kv : settings._globals->GetColorSchemes()) { Log::Comment(NoThrowString().Format( - L"kv:%s->%s", kv.first.data(), kv.second.Name().data())); + L"kv:%s->%s", kv.Key().data(), kv.Value().Name().data())); } - VERIFY_ARE_EQUAL(1u, settings._globals.GetColorSchemes().size()); + VERIFY_ARE_EQUAL(1u, settings._globals->GetColorSchemes().Size()); - VERIFY_IS_TRUE(settings._globals._colorSchemes.find(L"scheme0") != settings._globals._colorSchemes.end()); - auto scheme0Proj = settings._globals._colorSchemes.find(L"scheme0")->second; + VERIFY_IS_TRUE(settings._globals->GetColorSchemes().HasKey(L"scheme0")); + auto scheme0Proj = settings._globals->GetColorSchemes().Lookup(L"scheme0"); auto scheme0 = winrt::get_self(scheme0Proj); VERIFY_IS_NOT_NULL(settings._FindMatchingColorScheme(scheme0Json)); @@ -225,13 +225,13 @@ namespace TerminalAppLocalTests settings._LayerOrCreateColorScheme(scheme1Json); { - VERIFY_ARE_EQUAL(2u, settings._globals.GetColorSchemes().size()); + VERIFY_ARE_EQUAL(2u, settings._globals->GetColorSchemes().Size()); - VERIFY_IS_TRUE(settings._globals._colorSchemes.find(L"scheme0") != settings._globals._colorSchemes.end()); - auto scheme0Proj = settings._globals._colorSchemes.find(L"scheme0")->second; + VERIFY_IS_TRUE(settings._globals->GetColorSchemes().HasKey(L"scheme0")); + auto scheme0Proj = settings._globals->GetColorSchemes().Lookup(L"scheme0"); auto scheme0 = winrt::get_self(scheme0Proj); - VERIFY_IS_TRUE(settings._globals._colorSchemes.find(L"scheme1") != settings._globals._colorSchemes.end()); - auto scheme1Proj = settings._globals._colorSchemes.find(L"scheme1")->second; + VERIFY_IS_TRUE(settings._globals->GetColorSchemes().HasKey(L"scheme1")); + auto scheme1Proj = settings._globals->GetColorSchemes().Lookup(L"scheme1"); auto scheme1 = winrt::get_self(scheme1Proj); VERIFY_IS_NOT_NULL(settings._FindMatchingColorScheme(scheme0Json)); @@ -246,13 +246,13 @@ namespace TerminalAppLocalTests settings._LayerOrCreateColorScheme(scheme2Json); { - VERIFY_ARE_EQUAL(2u, settings._globals.GetColorSchemes().size()); + VERIFY_ARE_EQUAL(2u, settings._globals->GetColorSchemes().Size()); - VERIFY_IS_TRUE(settings._globals._colorSchemes.find(L"scheme0") != settings._globals._colorSchemes.end()); - auto scheme0Proj = settings._globals._colorSchemes.find(L"scheme0")->second; + VERIFY_IS_TRUE(settings._globals->GetColorSchemes().HasKey(L"scheme0")); + auto scheme0Proj = settings._globals->GetColorSchemes().Lookup(L"scheme0"); auto scheme0 = winrt::get_self(scheme0Proj); - VERIFY_IS_TRUE(settings._globals._colorSchemes.find(L"scheme1") != settings._globals._colorSchemes.end()); - auto scheme1Proj = settings._globals._colorSchemes.find(L"scheme1")->second; + VERIFY_IS_TRUE(settings._globals->GetColorSchemes().HasKey(L"scheme1")); + auto scheme1Proj = settings._globals->GetColorSchemes().Lookup(L"scheme1"); auto scheme1 = winrt::get_self(scheme1Proj); VERIFY_IS_NOT_NULL(settings._FindMatchingColorScheme(scheme0Json)); @@ -267,16 +267,16 @@ namespace TerminalAppLocalTests settings._LayerOrCreateColorScheme(scheme3Json); { - VERIFY_ARE_EQUAL(3u, settings._globals.GetColorSchemes().size()); + VERIFY_ARE_EQUAL(3u, settings._globals->GetColorSchemes().Size()); - VERIFY_IS_TRUE(settings._globals._colorSchemes.find(L"scheme0") != settings._globals._colorSchemes.end()); - auto scheme0Proj = settings._globals._colorSchemes.find(L"scheme0")->second; + VERIFY_IS_TRUE(settings._globals->GetColorSchemes().HasKey(L"scheme0")); + auto scheme0Proj = settings._globals->GetColorSchemes().Lookup(L"scheme0"); auto scheme0 = winrt::get_self(scheme0Proj); - VERIFY_IS_TRUE(settings._globals._colorSchemes.find(L"scheme1") != settings._globals._colorSchemes.end()); - auto scheme1Proj = settings._globals._colorSchemes.find(L"scheme1")->second; + VERIFY_IS_TRUE(settings._globals->GetColorSchemes().HasKey(L"scheme1")); + auto scheme1Proj = settings._globals->GetColorSchemes().Lookup(L"scheme1"); auto scheme1 = winrt::get_self(scheme1Proj); - VERIFY_IS_TRUE(settings._globals._colorSchemes.find(L"") != settings._globals._colorSchemes.end()); - auto scheme2Proj = settings._globals._colorSchemes.find(L"")->second; + VERIFY_IS_TRUE(settings._globals->GetColorSchemes().HasKey(L"")); + auto scheme2Proj = settings._globals->GetColorSchemes().Lookup(L""); auto scheme2 = winrt::get_self(scheme2Proj); VERIFY_IS_NOT_NULL(settings._FindMatchingColorScheme(scheme0Json)); diff --git a/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp b/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp index e1dad5b8905..91c45987ce7 100644 --- a/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp +++ b/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp @@ -106,7 +106,7 @@ namespace TerminalAppLocalTests } private: - void _logCommandNames(winrt::Windows::Foundation::Collections::IMap& commands, const int indentation = 1) + void _logCommandNames(winrt::Windows::Foundation::Collections::IMapView commands, const int indentation = 1) { if (indentation == 1) { @@ -125,7 +125,7 @@ namespace TerminalAppLocalTests cmdImpl.copy_from(winrt::get_self(nameAndCommand.Value())); if (cmdImpl->HasNestedCommands()) { - _logCommandNames(cmdImpl->_subcommands, indentation + 2); + _logCommandNames(cmdImpl->_subcommands.GetView(), indentation + 2); } } } @@ -274,7 +274,7 @@ namespace TerminalAppLocalTests settings->_ValidateDefaultProfileExists(); VERIFY_ARE_EQUAL(static_cast(0), settings->_warnings.size()); VERIFY_ARE_EQUAL(static_cast(2), settings->_profiles.size()); - VERIFY_ARE_EQUAL(winrt::guid{ settings->_globals.DefaultProfile() }, settings->_profiles.at(0).Guid()); + VERIFY_ARE_EQUAL(settings->_globals->DefaultProfile(), settings->_profiles.at(0).Guid()); } { // Case 2: Bad settings @@ -288,7 +288,7 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::MissingDefaultProfile, settings->_warnings.at(0)); VERIFY_ARE_EQUAL(static_cast(2), settings->_profiles.size()); - VERIFY_ARE_EQUAL(winrt::guid{ settings->_globals.DefaultProfile() }, settings->_profiles.at(0).Guid()); + VERIFY_ARE_EQUAL(settings->_globals->DefaultProfile(), settings->_profiles.at(0).Guid()); } { // Case 2: Bad settings @@ -302,7 +302,7 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::MissingDefaultProfile, settings->_warnings.at(0)); VERIFY_ARE_EQUAL(static_cast(2), settings->_profiles.size()); - VERIFY_ARE_EQUAL(winrt::guid{ settings->_globals.DefaultProfile() }, settings->_profiles.at(0).Guid()); + VERIFY_ARE_EQUAL(settings->_globals->DefaultProfile(), settings->_profiles.at(0).Guid()); } { // Case 4: Good settings, default profile is a string @@ -314,7 +314,7 @@ namespace TerminalAppLocalTests settings->_ValidateDefaultProfileExists(); VERIFY_ARE_EQUAL(static_cast(0), settings->_warnings.size()); VERIFY_ARE_EQUAL(static_cast(2), settings->_profiles.size()); - VERIFY_ARE_EQUAL(winrt::guid{ settings->_globals.DefaultProfile() }, settings->_profiles.at(1).Guid()); + VERIFY_ARE_EQUAL(settings->_globals->DefaultProfile(), settings->_profiles.at(1).Guid()); } } @@ -381,19 +381,19 @@ namespace TerminalAppLocalTests } ] })" }; - Profile profile0 = winrt::make(winrt::guid{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-4444-49a3-80bd-e8fdd045185c}") }); + Profile profile0 = winrt::make(::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-4444-49a3-80bd-e8fdd045185c}")); profile0.Name(L"profile0"); - Profile profile1 = winrt::make(winrt::guid{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-5555-49a3-80bd-e8fdd045185c}") }); + Profile profile1 = winrt::make(::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-5555-49a3-80bd-e8fdd045185c}")); profile1.Name(L"profile1"); - Profile profile2 = winrt::make(winrt::guid{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-4444-49a3-80bd-e8fdd045185c}") }); + Profile profile2 = winrt::make(::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-4444-49a3-80bd-e8fdd045185c}")); profile2.Name(L"profile2"); - Profile profile3 = winrt::make(winrt::guid{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-4444-49a3-80bd-e8fdd045185c}") }); + Profile profile3 = winrt::make(::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-4444-49a3-80bd-e8fdd045185c}")); profile3.Name(L"profile3"); - Profile profile4 = winrt::make(winrt::guid{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-6666-49a3-80bd-e8fdd045185c}") }); + Profile profile4 = winrt::make(::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-6666-49a3-80bd-e8fdd045185c}")); profile4.Name(L"profile4"); - Profile profile5 = winrt::make(winrt::guid{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-5555-49a3-80bd-e8fdd045185c}") }); + Profile profile5 = winrt::make(::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-5555-49a3-80bd-e8fdd045185c}")); profile5.Name(L"profile5"); - Profile profile6 = winrt::make(winrt::guid{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-7777-49a3-80bd-e8fdd045185c}") }); + Profile profile6 = winrt::make(::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-7777-49a3-80bd-e8fdd045185c}")); profile6.Name(L"profile6"); { @@ -474,9 +474,9 @@ namespace TerminalAppLocalTests } ] })" }; - Profile profile4 = winrt::make(winrt::guid{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-4444-49a3-80bd-e8fdd045185c}") }); + Profile profile4 = winrt::make(::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-4444-49a3-80bd-e8fdd045185c}")); profile4.Name(L"profile4"); - Profile profile5 = winrt::make(winrt::guid{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-4444-49a3-80bd-e8fdd045185c}") }); + Profile profile5 = winrt::make(::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-4444-49a3-80bd-e8fdd045185c}")); profile5.Name(L"profile5"); // Case 2: Bad settings @@ -496,7 +496,7 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::UnknownColorScheme, settings->_warnings.at(2)); VERIFY_ARE_EQUAL(3u, settings->_profiles.size()); - VERIFY_ARE_EQUAL(winrt::guid{ settings->_globals.DefaultProfile() }, settings->_profiles.at(0).Guid()); + VERIFY_ARE_EQUAL(settings->_globals->DefaultProfile(), settings->_profiles.at(0).Guid()); VERIFY_IS_TRUE(settings->_profiles.at(0).HasGuid()); VERIFY_IS_TRUE(settings->_profiles.at(1).HasGuid()); VERIFY_IS_TRUE(settings->_profiles.at(2).HasGuid()); @@ -522,16 +522,16 @@ namespace TerminalAppLocalTests CascadiaSettings settings; settings.LayerJson(settings0Json); - VERIFY_ARE_EQUAL(true, settings._globals._AlwaysShowTabs); - VERIFY_ARE_EQUAL(120, settings._globals._InitialCols); - VERIFY_ARE_EQUAL(30, settings._globals._InitialRows); - VERIFY_ARE_EQUAL(true, settings._globals._ShowTabsInTitlebar); + VERIFY_ARE_EQUAL(true, settings._globals->AlwaysShowTabs()); + VERIFY_ARE_EQUAL(120, settings._globals->InitialCols()); + VERIFY_ARE_EQUAL(30, settings._globals->InitialRows()); + VERIFY_ARE_EQUAL(true, settings._globals->ShowTabsInTitlebar()); settings.LayerJson(settings1Json); - VERIFY_ARE_EQUAL(true, settings._globals._AlwaysShowTabs); - VERIFY_ARE_EQUAL(240, settings._globals._InitialCols); - VERIFY_ARE_EQUAL(60, settings._globals._InitialRows); - VERIFY_ARE_EQUAL(false, settings._globals._ShowTabsInTitlebar); + VERIFY_ARE_EQUAL(true, settings._globals->AlwaysShowTabs()); + VERIFY_ARE_EQUAL(240, settings._globals->InitialCols()); + VERIFY_ARE_EQUAL(60, settings._globals->InitialRows()); + VERIFY_ARE_EQUAL(false, settings._globals->ShowTabsInTitlebar()); } void SettingsTests::ValidateProfileOrdering() @@ -1330,7 +1330,7 @@ namespace TerminalAppLocalTests settings.LayerJson(settings._userSettings); VERIFY_ARE_EQUAL(3u, settings._profiles.size()); - VERIFY_ARE_EQUAL(2u, settings._globals._colorSchemes.size()); + VERIFY_ARE_EQUAL(2u, settings._globals->GetColorSchemes().Size()); VERIFY_ARE_EQUAL(L"schemeOne", settings._profiles.at(0).ColorSchemeName()); VERIFY_ARE_EQUAL(L"InvalidSchemeName", settings._profiles.at(1).ColorSchemeName()); @@ -1342,7 +1342,7 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::UnknownColorScheme, settings._warnings.at(0)); VERIFY_ARE_EQUAL(3u, settings._profiles.size()); - VERIFY_ARE_EQUAL(2u, settings._globals._colorSchemes.size()); + VERIFY_ARE_EQUAL(2u, settings._globals->GetColorSchemes().Size()); VERIFY_ARE_EQUAL(L"schemeOne", settings._profiles.at(0).ColorSchemeName()); VERIFY_ARE_EQUAL(L"Campbell", settings._profiles.at(1).ColorSchemeName()); @@ -1379,11 +1379,11 @@ namespace TerminalAppLocalTests auto name3{ L"ThisProfileShouldNotThrow" }; auto badName{ L"DoesNotExist" }; - winrt::guid guid0{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-5555-49a3-80bd-e8fdd045185c}") }; - winrt::guid guid1{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-6666-49a3-80bd-e8fdd045185c}") }; - winrt::guid guid2{ ::Microsoft::Console::Utils::GuidFromString(L"{2C4DE342-38B7-51CF-B940-2309A097F518}") }; - winrt::guid fakeGuid{ ::Microsoft::Console::Utils::GuidFromString(L"{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}") }; - std::optional badGuid{}; + const winrt::guid guid0{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-5555-49a3-80bd-e8fdd045185c}") }; + const winrt::guid guid1{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-6666-49a3-80bd-e8fdd045185c}") }; + const winrt::guid guid2{ ::Microsoft::Console::Utils::GuidFromString(L"{2C4DE342-38B7-51CF-B940-2309A097F518}") }; + const winrt::guid fakeGuid{ ::Microsoft::Console::Utils::GuidFromString(L"{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}") }; + const std::optional badGuid{}; VerifyParseSucceeded(settings0String); @@ -1450,7 +1450,7 @@ namespace TerminalAppLocalTests settings.LayerJson(settings._userSettings); VERIFY_IS_FALSE(settings._profiles.empty()); - GlobalAppSettings globalSettings{}; + auto globalSettings{ winrt::make() }; const auto profileImpl = winrt::get_self(settings._profiles[0]); auto terminalSettings = profileImpl->CreateTerminalSettings(globalSettings.GetColorSchemes()); VERIFY_ARE_EQUAL(expectedPath, terminalSettings.BackgroundImage()); @@ -1554,7 +1554,7 @@ namespace TerminalAppLocalTests VERIFY_IS_FALSE(settings._userDefaultProfileSettings == Json::Value::null); settings.LayerJson(settings._userSettings); - VERIFY_ARE_EQUAL(guid1String, settings._globals._unparsedDefaultProfile); + VERIFY_ARE_EQUAL(guid1String, settings._globals->UnparsedDefaultProfile()); VERIFY_ARE_EQUAL(2u, settings._profiles.size()); VERIFY_ARE_EQUAL(2345, settings._profiles.at(0).HistorySize()); @@ -1612,7 +1612,7 @@ namespace TerminalAppLocalTests settings.LayerJson(settings._userSettings); - VERIFY_ARE_EQUAL(guid1String, settings._globals._unparsedDefaultProfile); + VERIFY_ARE_EQUAL(guid1String, settings._globals->UnparsedDefaultProfile()); VERIFY_ARE_EQUAL(4u, settings._profiles.size()); VERIFY_ARE_EQUAL(guid1, settings._profiles.at(2).Guid()); @@ -1629,9 +1629,9 @@ namespace TerminalAppLocalTests // settings in defaultSettings should apply _on top_ of settings from // dynamic profiles. - winrt::guid guid1{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-1111-49a3-80bd-e8fdd045185c}") }; - winrt::guid guid2{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-2222-49a3-80bd-e8fdd045185c}") }; - winrt::guid guid3{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-3333-49a3-80bd-e8fdd045185c}") }; + const winrt::guid guid1{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-1111-49a3-80bd-e8fdd045185c}") }; + const winrt::guid guid2{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-2222-49a3-80bd-e8fdd045185c}") }; + const winrt::guid guid3{ ::Microsoft::Console::Utils::GuidFromString(L"{6239a42c-3333-49a3-80bd-e8fdd045185c}") }; const std::string userProfiles{ R"( { @@ -1794,12 +1794,13 @@ namespace TerminalAppLocalTests settings.LayerJson(settings._userSettings); settings._ValidateSettings(); - auto appKeyBindings = settings._globals._keybindings; + auto appKeyBindingsProj = settings._globals->GetKeybindings(); VERIFY_ARE_EQUAL(3u, settings.GetProfiles().size()); const auto profile2Guid = settings._profiles.at(2).Guid(); VERIFY_ARE_NOT_EQUAL(winrt::guid{}, profile2Guid); + const auto appKeyBindings = winrt::get_self(appKeyBindingsProj); VERIFY_ARE_EQUAL(12u, appKeyBindings->_keyShortcuts.size()); { @@ -2176,7 +2177,7 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(2u, settings->_warnings.size()); VERIFY_ARE_EQUAL(2u, settings->_profiles.size()); - VERIFY_ARE_EQUAL(winrt::guid{ settings->_globals.DefaultProfile() }, settings->_profiles.at(0).Guid()); + VERIFY_ARE_EQUAL(settings->_globals->DefaultProfile(), settings->_profiles.at(0).Guid()); try { const auto [guid, termSettings] = settings->BuildSettings(nullptr); @@ -2241,14 +2242,14 @@ namespace TerminalAppLocalTests settings.LayerJson(settings._userSettings); VERIFY_ARE_EQUAL(6u, settings._profiles.size()); - VERIFY_ARE_EQUAL(2u, settings._globals._colorSchemes.size()); + VERIFY_ARE_EQUAL(2u, settings._globals->GetColorSchemes().Size()); - auto terminalSettings0 = winrt::get_self(settings._profiles[0])->CreateTerminalSettings(settings._globals._colorSchemes); - auto terminalSettings1 = winrt::get_self(settings._profiles[1])->CreateTerminalSettings(settings._globals._colorSchemes); - auto terminalSettings2 = winrt::get_self(settings._profiles[2])->CreateTerminalSettings(settings._globals._colorSchemes); - auto terminalSettings3 = winrt::get_self(settings._profiles[3])->CreateTerminalSettings(settings._globals._colorSchemes); - auto terminalSettings4 = winrt::get_self(settings._profiles[4])->CreateTerminalSettings(settings._globals._colorSchemes); - auto terminalSettings5 = winrt::get_self(settings._profiles[5])->CreateTerminalSettings(settings._globals._colorSchemes); + auto terminalSettings0 = winrt::get_self(settings._profiles[0])->CreateTerminalSettings(settings._globals->GetColorSchemes()); + auto terminalSettings1 = winrt::get_self(settings._profiles[1])->CreateTerminalSettings(settings._globals->GetColorSchemes()); + auto terminalSettings2 = winrt::get_self(settings._profiles[2])->CreateTerminalSettings(settings._globals->GetColorSchemes()); + auto terminalSettings3 = winrt::get_self(settings._profiles[3])->CreateTerminalSettings(settings._globals->GetColorSchemes()); + auto terminalSettings4 = winrt::get_self(settings._profiles[4])->CreateTerminalSettings(settings._globals->GetColorSchemes()); + auto terminalSettings5 = winrt::get_self(settings._profiles[5])->CreateTerminalSettings(settings._globals->GetColorSchemes()); VERIFY_ARE_EQUAL(ARGB(0, 0x12, 0x34, 0x56), terminalSettings0.CursorColor()); // from color scheme VERIFY_ARE_EQUAL(DEFAULT_CURSOR_COLOR, terminalSettings1.CursorColor()); // default @@ -2283,12 +2284,12 @@ namespace TerminalAppLocalTests const auto settingsObject = VerifyParseSucceeded(badSettings); auto settings = CascadiaSettings::FromJson(settingsObject); - VERIFY_ARE_EQUAL(0u, settings->_globals._keybindings->_keyShortcuts.size()); + VERIFY_ARE_EQUAL(0u, settings->_globals->_keybindings->_keyShortcuts.size()); - VERIFY_ARE_EQUAL(3u, settings->_globals._keybindingsWarnings.size()); - VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::TooManyKeysForChord, settings->_globals._keybindingsWarnings.at(0)); - VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::MissingRequiredParameter, settings->_globals._keybindingsWarnings.at(1)); - VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::MissingRequiredParameter, settings->_globals._keybindingsWarnings.at(2)); + VERIFY_ARE_EQUAL(3u, settings->_globals->_keybindingsWarnings.size()); + VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::TooManyKeysForChord, settings->_globals->_keybindingsWarnings.at(0)); + VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::MissingRequiredParameter, settings->_globals->_keybindingsWarnings.at(1)); + VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::MissingRequiredParameter, settings->_globals->_keybindingsWarnings.at(2)); settings->_ValidateKeybindings(); @@ -2325,17 +2326,17 @@ namespace TerminalAppLocalTests auto settings = CascadiaSettings::FromJson(settingsObject); - VERIFY_ARE_EQUAL(0u, settings->_globals._keybindings->_keyShortcuts.size()); + VERIFY_ARE_EQUAL(0u, settings->_globals->_keybindings->_keyShortcuts.size()); - for (const auto& warning : settings->_globals._keybindingsWarnings) + for (const auto& warning : settings->_globals->_keybindingsWarnings) { Log::Comment(NoThrowString().Format( L"warning:%d", warning)); } - VERIFY_ARE_EQUAL(3u, settings->_globals._keybindingsWarnings.size()); - VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::MissingRequiredParameter, settings->_globals._keybindingsWarnings.at(0)); - VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::MissingRequiredParameter, settings->_globals._keybindingsWarnings.at(1)); - VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::MissingRequiredParameter, settings->_globals._keybindingsWarnings.at(2)); + VERIFY_ARE_EQUAL(3u, settings->_globals->_keybindingsWarnings.size()); + VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::MissingRequiredParameter, settings->_globals->_keybindingsWarnings.at(0)); + VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::MissingRequiredParameter, settings->_globals->_keybindingsWarnings.at(1)); + VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::MissingRequiredParameter, settings->_globals->_keybindingsWarnings.at(2)); settings->_ValidateKeybindings(); @@ -2465,13 +2466,13 @@ namespace TerminalAppLocalTests const auto profile2Guid = settings._profiles.at(2).Guid(); VERIFY_ARE_NOT_EQUAL(winrt::guid{}, profile2Guid); - auto appKeyBindings = settings._globals._keybindings; + auto appKeyBindings = winrt::get_self(settings._globals->GetKeybindings()); VERIFY_ARE_EQUAL(5u, appKeyBindings->_keyShortcuts.size()); // A/D, B, C, E will be in the list of commands, for 4 total. // * A and D share the same name, so they'll only generate a single action. // * F's name is set manually to `null` - auto commands = settings._globals.GetCommands(); + auto commands = settings._globals->GetCommands(); VERIFY_ARE_EQUAL(4u, commands.Size()); { @@ -2665,7 +2666,7 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(3u, settings.GetProfiles().size()); - auto& commands = settings._globals.GetCommands(); + auto commands = settings._globals->GetCommands(); VERIFY_ARE_EQUAL(1u, commands.Size()); { @@ -2686,8 +2687,8 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(L"${profile.name}", realArgs.TerminalArgs().Profile()); } - auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands.GetView(), settings.GetProfiles(), settings._globals.GetColorSchemes()); - _logCommandNames(expandedCommands); + auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings.GetProfiles(), settings._globals->GetColorSchemes()); + _logCommandNames(expandedCommands.GetView()); VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(3u, expandedCommands.Size()); @@ -2795,7 +2796,7 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(3u, settings.GetProfiles().size()); - auto& commands = settings._globals.GetCommands(); + auto commands = settings._globals->GetCommands(); VERIFY_ARE_EQUAL(1u, commands.Size()); { @@ -2816,8 +2817,8 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(L"${profile.name}", realArgs.TerminalArgs().Profile()); } - auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands.GetView(), settings.GetProfiles(), settings._globals.GetColorSchemes()); - _logCommandNames(expandedCommands); + auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings.GetProfiles(), settings._globals->GetColorSchemes()); + _logCommandNames(expandedCommands.GetView()); VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(3u, expandedCommands.Size()); @@ -2927,7 +2928,7 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(3u, settings.GetProfiles().size()); - auto& commands = settings._globals.GetCommands(); + auto commands = settings._globals->GetCommands(); VERIFY_ARE_EQUAL(1u, commands.Size()); { @@ -2949,8 +2950,8 @@ namespace TerminalAppLocalTests } settings._ValidateSettings(); - auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands.GetView(), settings.GetProfiles(), settings._globals.GetColorSchemes()); - _logCommandNames(expandedCommands); + auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings.GetProfiles(), settings._globals->GetColorSchemes()); + _logCommandNames(expandedCommands.GetView()); VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(3u, expandedCommands.Size()); @@ -3068,10 +3069,10 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(3u, settings.GetProfiles().size()); - auto& commands = settings._globals.GetCommands(); + auto commands = settings._globals->GetCommands(); settings._ValidateSettings(); - auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands.GetView(), settings.GetProfiles(), settings._globals.GetColorSchemes()); - _logCommandNames(expandedCommands); + auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings.GetProfiles(), settings._globals->GetColorSchemes()); + _logCommandNames(expandedCommands.GetView()); VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(1u, expandedCommands.Size()); @@ -3176,10 +3177,10 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(3u, settings.GetProfiles().size()); - auto& commands = settings._globals.GetCommands(); + auto commands = settings._globals->GetCommands(); settings._ValidateSettings(); - auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands.GetView(), settings.GetProfiles(), settings._globals.GetColorSchemes()); - _logCommandNames(expandedCommands); + auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings.GetProfiles(), settings._globals->GetColorSchemes()); + _logCommandNames(expandedCommands.GetView()); VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(1u, expandedCommands.Size()); @@ -3315,10 +3316,10 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(3u, settings.GetProfiles().size()); - auto& commands = settings._globals.GetCommands(); + auto commands = settings._globals->GetCommands(); settings._ValidateSettings(); - auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands.GetView(), settings.GetProfiles(), settings._globals.GetColorSchemes()); - _logCommandNames(expandedCommands); + auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings.GetProfiles(), settings._globals->GetColorSchemes()); + _logCommandNames(expandedCommands.GetView()); VERIFY_ARE_EQUAL(0u, settings._warnings.size()); @@ -3337,7 +3338,7 @@ namespace TerminalAppLocalTests VERIFY_IS_TRUE(commandImpl->HasNestedCommands()); VERIFY_ARE_EQUAL(3u, commandImpl->_subcommands.Size()); - _logCommandNames(commandImpl->_subcommands); + _logCommandNames(commandImpl->_subcommands.GetView()); { winrt::hstring childCommandName{ fmt::format(L"Split pane, profile: {}", name) }; auto childCommandProj = commandImpl->_subcommands.Lookup(childCommandName); @@ -3468,10 +3469,10 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(3u, settings.GetProfiles().size()); - auto& commands = settings._globals.GetCommands(); + auto commands = settings._globals->GetCommands(); settings._ValidateSettings(); - auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands.GetView(), settings.GetProfiles(), settings._globals.GetColorSchemes()); - _logCommandNames(expandedCommands); + auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings.GetProfiles(), settings._globals->GetColorSchemes()); + _logCommandNames(expandedCommands.GetView()); VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(1u, expandedCommands.Size()); @@ -3581,10 +3582,10 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(3u, settings.GetProfiles().size()); - auto& commands = settings._globals.GetCommands(); + auto commands = settings._globals->GetCommands(); settings._ValidateSettings(); - auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands.GetView(), settings.GetProfiles(), settings._globals.GetColorSchemes()); - _logCommandNames(expandedCommands); + auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings.GetProfiles(), settings._globals->GetColorSchemes()); + _logCommandNames(expandedCommands.GetView()); VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(1u, expandedCommands.Size()); @@ -3613,7 +3614,7 @@ namespace TerminalAppLocalTests VERIFY_IS_TRUE(commandImpl->HasNestedCommands()); VERIFY_ARE_EQUAL(3u, commandImpl->_subcommands.Size()); - _logCommandNames(commandImpl->_subcommands); + _logCommandNames(commandImpl->_subcommands.GetView()); { winrt::hstring childCommandName{ fmt::format(L"Split pane, profile: {}", name) }; auto childCommandProj = commandImpl->_subcommands.Lookup(childCommandName); @@ -3742,7 +3743,7 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(3u, settings.GetProfiles().size()); - auto& commands = settings._globals.GetCommands(); + auto commands = settings._globals->GetCommands(); settings._ValidateSettings(); _logCommandNames(commands); @@ -3819,7 +3820,7 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(3u, settings.GetProfiles().size()); - auto& commands = settings._globals.GetCommands(); + auto commands = settings._globals->GetCommands(); settings._ValidateSettings(); _logCommandNames(commands); @@ -3902,7 +3903,7 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(3u, settings.GetProfiles().size()); - auto& commands = settings._globals.GetCommands(); + auto commands = settings._globals->GetCommands(); settings._ValidateSettings(); _logCommandNames(commands); @@ -3998,7 +3999,7 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(3u, settings.GetProfiles().size()); - auto& commands = settings._globals.GetCommands(); + auto commands = settings._globals->GetCommands(); VERIFY_ARE_EQUAL(1u, commands.Size()); { @@ -4019,8 +4020,8 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(L"${scheme.name}", realArgs.TerminalArgs().Profile()); } - auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands.GetView(), settings.GetProfiles(), settings._globals.GetColorSchemes()); - _logCommandNames(expandedCommands); + auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings.GetProfiles(), settings._globals->GetColorSchemes()); + _logCommandNames(expandedCommands.GetView()); VERIFY_ARE_EQUAL(0u, settings._warnings.size()); VERIFY_ARE_EQUAL(3u, expandedCommands.Size()); diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index d7adb4f2456..2a02e80dd13 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -561,7 +561,7 @@ namespace winrt::TerminalApp::implementation // - defaultInitialY: the system default y coordinate value // Return Value: // - a point containing the requested initial position in pixels. - winrt::Windows::Foundation::Point AppLogic::GetLaunchInitialPositions(int32_t defaultInitialX, int32_t defaultInitialY) + TerminalApp::InitialPosition AppLogic::GetInitialPosition(int64_t defaultInitialX, int64_t defaultInitialY) { if (!_loadedInitialSettings) { @@ -570,12 +570,10 @@ namespace winrt::TerminalApp::implementation } const auto initialPosition{ _settings->GlobalSettings().InitialPosition() }; - winrt::Windows::Foundation::Point point{ - /* X */ gsl::narrow_cast(initialPosition.x.value_or(defaultInitialX)), - /* Y */ gsl::narrow_cast(initialPosition.y.value_or(defaultInitialY)) + return { + initialPosition.X ? initialPosition.X.Value() : defaultInitialX, + initialPosition.Y ? initialPosition.Y.Value() : defaultInitialY }; - - return point; } winrt::Windows::UI::Xaml::ElementTheme AppLogic::GetRequestedTheme() diff --git a/src/cascadia/TerminalApp/AppLogic.h b/src/cascadia/TerminalApp/AppLogic.h index c0c75952b1a..a5e811a886b 100644 --- a/src/cascadia/TerminalApp/AppLogic.h +++ b/src/cascadia/TerminalApp/AppLogic.h @@ -38,7 +38,7 @@ namespace winrt::TerminalApp::implementation bool AlwaysOnTop() const; Windows::Foundation::Size GetLaunchDimensions(uint32_t dpi); - winrt::Windows::Foundation::Point GetLaunchInitialPositions(int32_t defaultInitialX, int32_t defaultInitialY); + TerminalApp::InitialPosition GetInitialPosition(int64_t defaultInitialX, int64_t defaultInitialY); winrt::Windows::UI::Xaml::ElementTheme GetRequestedTheme(); LaunchMode GetLaunchMode(); bool GetShowTabsInTitlebar(); diff --git a/src/cascadia/TerminalApp/AppLogic.idl b/src/cascadia/TerminalApp/AppLogic.idl index 73b77b54413..838b40e1a67 100644 --- a/src/cascadia/TerminalApp/AppLogic.idl +++ b/src/cascadia/TerminalApp/AppLogic.idl @@ -7,6 +7,12 @@ import "IDirectKeyListener.idl"; namespace TerminalApp { + struct InitialPosition + { + Int64 X; + Int64 Y; + }; + enum LaunchMode { DefaultMode, @@ -47,7 +53,7 @@ namespace TerminalApp Windows.Foundation.Size GetLaunchDimensions(UInt32 dpi); - Windows.Foundation.Point GetLaunchInitialPositions(Int32 defaultInitialX, Int32 defaultInitialY); + InitialPosition GetInitialPosition(Int64 defaultInitialX, Int64 defaultInitialY); Windows.UI.Xaml.ElementTheme GetRequestedTheme(); LaunchMode GetLaunchMode(); Boolean GetShowTabsInTitlebar(); diff --git a/src/cascadia/TerminalApp/CascadiaSettings.cpp b/src/cascadia/TerminalApp/CascadiaSettings.cpp index 4eda47ada1b..73bcc0e903c 100644 --- a/src/cascadia/TerminalApp/CascadiaSettings.cpp +++ b/src/cascadia/TerminalApp/CascadiaSettings.cpp @@ -52,7 +52,8 @@ CascadiaSettings::CascadiaSettings() : // generators. Set this to `false` for unit testing. // Arguments: // - addDynamicProfiles: if true, we'll add the built-in DPGs. -CascadiaSettings::CascadiaSettings(const bool addDynamicProfiles) +CascadiaSettings::CascadiaSettings(const bool addDynamicProfiles) : + _globals{ winrt::make_self() } { if (addDynamicProfiles) { @@ -106,7 +107,7 @@ gsl::span CascadiaSettings::GetProfiles() const noexcept // - the globally configured keybindings AppKeyBindings CascadiaSettings::GetKeybindings() const noexcept { - return _globals.GetKeybindings(); + return _globals->GetKeybindings(); } // Method Description: @@ -115,9 +116,9 @@ AppKeyBindings CascadiaSettings::GetKeybindings() const noexcept // - // Return Value: // - a reference to our global settings -GlobalAppSettings& CascadiaSettings::GlobalSettings() +winrt::TerminalApp::GlobalAppSettings CascadiaSettings::GlobalSettings() { - return _globals; + return *_globals; } // Method Description: @@ -227,9 +228,9 @@ void CascadiaSettings::_ValidateProfilesHaveGuid() void CascadiaSettings::_ResolveDefaultProfile() { const auto unparsedDefaultProfile{ GlobalSettings().UnparsedDefaultProfile() }; - if (unparsedDefaultProfile) + if (!unparsedDefaultProfile.empty()) { - auto maybeParsedDefaultProfile{ _GetProfileGuidByName(*unparsedDefaultProfile) }; + auto maybeParsedDefaultProfile{ _GetProfileGuidByName(unparsedDefaultProfile) }; auto defaultProfileGuid{ til::coalesce_value(maybeParsedDefaultProfile, winrt::guid{}) }; GlobalSettings().DefaultProfile(defaultProfileGuid); } @@ -404,15 +405,11 @@ void CascadiaSettings::_ValidateAllSchemesExist() bool foundInvalidScheme = false; for (auto& profile : _profiles) { - auto schemeName = profile.ColorSchemeName(); - if (!schemeName.empty()) + const auto schemeName = profile.ColorSchemeName(); + if (!_globals->GetColorSchemes().HasKey(schemeName)) { - const auto found = _globals.GetColorSchemes().find(schemeName.c_str()); - if (found == _globals.GetColorSchemes().end()) - { - profile.ColorSchemeName({ L"Campbell" }); - foundInvalidScheme = true; - } + profile.ColorSchemeName({ L"Campbell" }); + foundInvalidScheme = true; } } @@ -536,10 +533,10 @@ TerminalSettings CascadiaSettings::BuildSettings(winrt::guid profileGuid) const THROW_HR_IF_NULL(E_INVALIDARG, profile); const auto profileImpl = winrt::get_self(profile); - TerminalSettings result = profileImpl->CreateTerminalSettings(_globals.GetColorSchemes()); + TerminalSettings result = profileImpl->CreateTerminalSettings(_globals->GetColorSchemes()); // Place our appropriate global settings into the Terminal Settings - _globals.ApplyToSettings(result); + _globals->ApplyToSettings(result); return result; } @@ -573,7 +570,7 @@ winrt::guid CascadiaSettings::_GetProfileForArgs(const NewTerminalArgs& newTermi profileByName = _GetProfileGuidByName(newTerminalArgs.Profile()); } - return til::coalesce_value(profileByName, profileByIndex, _globals.DefaultProfile()); + return til::coalesce_value(profileByName, profileByIndex, _globals->DefaultProfile()); } // Method Description: @@ -661,7 +658,7 @@ std::optional CascadiaSettings::_GetProfileGuidByIndex(std::optiona // - void CascadiaSettings::_ValidateKeybindings() { - auto keybindingWarnings = _globals.GetKeybindingsWarnings(); + auto keybindingWarnings = _globals->GetKeybindingsWarnings(); if (!keybindingWarnings.empty()) { @@ -746,16 +743,8 @@ const ColorScheme CascadiaSettings::GetColorSchemeForProfile(const winrt::guid p { return nullptr; } - const std::wstring schemeName{ profile.ColorSchemeName() }; - auto scheme = _globals.GetColorSchemes().find(schemeName); - if (scheme != _globals.GetColorSchemes().end()) - { - return scheme->second; - } - else - { - return nullptr; - } + const auto schemeName = profile.ColorSchemeName(); + return _globals->GetColorSchemes().TryLookup(schemeName); } // Method Description: @@ -768,13 +757,10 @@ const ColorScheme CascadiaSettings::GetColorSchemeForProfile(const winrt::guid p // Return Value: // - true iff we found a matching scheme for the name schemeName bool CascadiaSettings::ApplyColorScheme(winrt::Microsoft::Terminal::TerminalControl::IControlSettings& settings, - std::wstring_view schemeName) + winrt::hstring schemeName) { - std::wstring name{ schemeName }; - auto schemeAndName = _globals.GetColorSchemes().find(name); - if (schemeAndName != _globals.GetColorSchemes().end()) + if (auto scheme{ _globals->GetColorSchemes().TryLookup(schemeName) }) { - const auto& scheme = schemeAndName->second; scheme.ApplyScheme(settings); return true; } diff --git a/src/cascadia/TerminalApp/CascadiaSettings.h b/src/cascadia/TerminalApp/CascadiaSettings.h index a64be8c364a..b2c0d3d87c6 100644 --- a/src/cascadia/TerminalApp/CascadiaSettings.h +++ b/src/cascadia/TerminalApp/CascadiaSettings.h @@ -67,7 +67,7 @@ class TerminalApp::CascadiaSettings final std::tuple BuildSettings(const winrt::TerminalApp::NewTerminalArgs& newTerminalArgs) const; winrt::TerminalApp::TerminalSettings BuildSettings(winrt::guid profileGuid) const; - GlobalAppSettings& GlobalSettings(); + winrt::TerminalApp::GlobalAppSettings GlobalSettings(); gsl::span GetProfiles() const noexcept; @@ -84,10 +84,10 @@ class TerminalApp::CascadiaSettings final std::vector& GetWarnings(); - bool ApplyColorScheme(winrt::Microsoft::Terminal::TerminalControl::IControlSettings& settings, std::wstring_view schemeName); + bool ApplyColorScheme(winrt::Microsoft::Terminal::TerminalControl::IControlSettings& settings, winrt::hstring schemeName); private: - GlobalAppSettings _globals; + winrt::com_ptr _globals; std::vector _profiles; std::vector _warnings; diff --git a/src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp b/src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp index fe68f476602..06dc5e55bd9 100644 --- a/src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp +++ b/src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp @@ -560,7 +560,7 @@ std::unique_ptr CascadiaSettings::FromJson(const Json::Value& // void CascadiaSettings::LayerJson(const Json::Value& json) { - _globals.LayerJson(json); + _globals->LayerJson(json); if (auto schemes{ json[SchemesKey.data()] }) { @@ -709,7 +709,7 @@ void CascadiaSettings::_LayerOrCreateColorScheme(const Json::Value& schemeJson) else { const auto scheme = implementation::ColorScheme::FromJson(schemeJson); - _globals.AddColorScheme(*scheme); + _globals->AddColorScheme(*scheme); } } @@ -728,11 +728,9 @@ winrt::com_ptr CascadiaSettings::_FindMatchingColor { if (auto schemeName = implementation::ColorScheme::GetNameFromJson(schemeJson)) { - auto& schemes = _globals.GetColorSchemes(); - auto iterator = schemes.find(*schemeName); - if (iterator != schemes.end()) + if (auto scheme{ _globals->GetColorSchemes().TryLookup(*schemeName) }) { - return winrt::get_self(iterator->second)->get_strong(); + return winrt::get_self(scheme)->get_strong(); } } return nullptr; diff --git a/src/cascadia/TerminalApp/Command.h b/src/cascadia/TerminalApp/Command.h index c98f968c6b0..6f3d374c1d1 100644 --- a/src/cascadia/TerminalApp/Command.h +++ b/src/cascadia/TerminalApp/Command.h @@ -60,7 +60,7 @@ namespace winrt::TerminalApp::implementation OBSERVABLE_GETSET_PROPERTY(winrt::hstring, KeyChordText, _PropertyChangedHandlers); OBSERVABLE_GETSET_PROPERTY(winrt::Windows::UI::Xaml::Controls::IconSource, IconSource, _PropertyChangedHandlers, nullptr); - GETSET_PROPERTY(::TerminalApp::ExpandCommandType, IterateOn, ::TerminalApp::ExpandCommandType::None); + GETSET_PROPERTY(ExpandCommandType, IterateOn, ExpandCommandType::None); private: Json::Value _originalJson; diff --git a/src/cascadia/TerminalApp/GlobalAppSettings.cpp b/src/cascadia/TerminalApp/GlobalAppSettings.cpp index 4cbba508b1f..7507e83bdc6 100644 --- a/src/cascadia/TerminalApp/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalApp/GlobalAppSettings.cpp @@ -9,8 +9,10 @@ #include "JsonUtils.h" #include "TerminalSettingsSerializationHelpers.h" +#include "GlobalAppSettings.g.cpp" + using namespace TerminalApp; -using namespace winrt::TerminalApp; +using namespace winrt::TerminalApp::implementation; using namespace winrt::Windows::UI::Xaml; using namespace ::Microsoft::Console; using namespace winrt::Microsoft::UI::Xaml::Controls; @@ -51,52 +53,40 @@ static constexpr bool debugFeaturesDefault{ false }; #endif GlobalAppSettings::GlobalAppSettings() : - _keybindings{ winrt::make_self() }, + _keybindings{ winrt::make_self() }, _keybindingsWarnings{}, - _colorSchemes{}, - _unparsedDefaultProfile{ std::nullopt }, + _unparsedDefaultProfile{}, _defaultProfile{}, - _InitialRows{ DEFAULT_ROWS }, - _InitialCols{ DEFAULT_COLS }, - _WordDelimiters{ DEFAULT_WORD_DELIMITERS }, _DebugFeaturesEnabled{ debugFeaturesDefault } { _commands = winrt::single_threaded_map(); + _colorSchemes = winrt::single_threaded_map(); } -GlobalAppSettings::~GlobalAppSettings() -{ -} - -std::unordered_map& GlobalAppSettings::GetColorSchemes() noexcept -{ - return _colorSchemes; -} - -const std::unordered_map& GlobalAppSettings::GetColorSchemes() const noexcept +winrt::Windows::Foundation::Collections::IMapView GlobalAppSettings::GetColorSchemes() noexcept { - return _colorSchemes; + return _colorSchemes.GetView(); } -void GlobalAppSettings::DefaultProfile(const GUID defaultProfile) noexcept +void GlobalAppSettings::DefaultProfile(const winrt::guid& defaultProfile) noexcept { - _unparsedDefaultProfile.reset(); + _unparsedDefaultProfile.clear(); _defaultProfile = defaultProfile; } -GUID GlobalAppSettings::DefaultProfile() const +winrt::guid GlobalAppSettings::DefaultProfile() const { // If we have an unresolved default profile, we should likely explode. - THROW_HR_IF(E_INVALIDARG, _unparsedDefaultProfile.has_value()); + THROW_HR_IF(E_INVALIDARG, !_unparsedDefaultProfile.empty()); return _defaultProfile; } -std::optional GlobalAppSettings::UnparsedDefaultProfile() const +winrt::hstring GlobalAppSettings::UnparsedDefaultProfile() const { return _unparsedDefaultProfile; } -AppKeyBindings GlobalAppSettings::GetKeybindings() const noexcept +winrt::TerminalApp::AppKeyBindings GlobalAppSettings::GetKeybindings() const noexcept { return *_keybindings; } @@ -107,7 +97,7 @@ AppKeyBindings GlobalAppSettings::GetKeybindings() const noexcept // - settings: a TerminalSettings object to add global property values to. // Return Value: // - -void GlobalAppSettings::ApplyToSettings(TerminalSettings& settings) const noexcept +void GlobalAppSettings::ApplyToSettings(const TerminalApp::TerminalSettings& settings) const noexcept { settings.KeyBindings(GetKeybindings()); settings.InitialRows(_InitialRows); @@ -126,10 +116,10 @@ void GlobalAppSettings::ApplyToSettings(TerminalSettings& settings) const noexce // - json: an object which should be a serialization of a GlobalAppSettings object. // Return Value: // - a new GlobalAppSettings instance created from the values in `json` -GlobalAppSettings GlobalAppSettings::FromJson(const Json::Value& json) +winrt::com_ptr GlobalAppSettings::FromJson(const Json::Value& json) { - GlobalAppSettings result; - result.LayerJson(json); + auto result = winrt::make_self(); + result->LayerJson(json); return result; } @@ -214,10 +204,9 @@ void GlobalAppSettings::LayerJson(const Json::Value& json) // - scheme: the color scheme to add // Return Value: // - -void GlobalAppSettings::AddColorScheme(ColorScheme scheme) +void GlobalAppSettings::AddColorScheme(const winrt::TerminalApp::ColorScheme& scheme) { - std::wstring name{ scheme.Name() }; - _colorSchemes[name] = std::move(scheme); + _colorSchemes.Insert(scheme.Name(), scheme); } // Method Description: @@ -234,12 +223,7 @@ std::vector GlobalAppSettings::GetKeybindings return _keybindingsWarnings; } -const winrt::Windows::Foundation::Collections::IMap& GlobalAppSettings::GetCommands() const noexcept -{ - return _commands; -} - -winrt::Windows::Foundation::Collections::IMap& GlobalAppSettings::GetCommands() noexcept +winrt::Windows::Foundation::Collections::IMapView GlobalAppSettings::GetCommands() noexcept { - return _commands; + return _commands.GetView(); } diff --git a/src/cascadia/TerminalApp/GlobalAppSettings.h b/src/cascadia/TerminalApp/GlobalAppSettings.h index d78d15a8e34..82d385a9434 100644 --- a/src/cascadia/TerminalApp/GlobalAppSettings.h +++ b/src/cascadia/TerminalApp/GlobalAppSettings.h @@ -14,11 +14,12 @@ Author(s): --*/ #pragma once + +#include "GlobalAppSettings.g.h" + #include "AppKeyBindings.h" #include "Command.h" -#include "SettingsTypes.h" - -#include "ColorScheme.g.h" +#include "ColorScheme.h" // fwdecl unittest classes namespace TerminalAppLocalTests @@ -27,73 +28,68 @@ namespace TerminalAppLocalTests class ColorSchemeTests; }; -namespace TerminalApp +namespace winrt::TerminalApp::implementation { - class GlobalAppSettings; -}; - -class TerminalApp::GlobalAppSettings final -{ -public: - GlobalAppSettings(); - ~GlobalAppSettings(); - - std::unordered_map& GetColorSchemes() noexcept; - const std::unordered_map& GetColorSchemes() const noexcept; - void AddColorScheme(winrt::TerminalApp::ColorScheme scheme); - - winrt::TerminalApp::AppKeyBindings GetKeybindings() const noexcept; - - static GlobalAppSettings FromJson(const Json::Value& json); - void LayerJson(const Json::Value& json); - - void ApplyToSettings(winrt::TerminalApp::TerminalSettings& settings) const noexcept; - - std::vector GetKeybindingsWarnings() const; - - const winrt::Windows::Foundation::Collections::IMap& GetCommands() const noexcept; - winrt::Windows::Foundation::Collections::IMap& GetCommands() noexcept; - - // These are implemented manually to handle the string/GUID exchange - // by higher layers in the app. - void DefaultProfile(const GUID defaultProfile) noexcept; - GUID DefaultProfile() const; - std::optional UnparsedDefaultProfile() const; - - GETSET_PROPERTY(int32_t, InitialRows); // default value set in constructor - GETSET_PROPERTY(int32_t, InitialCols); // default value set in constructor - GETSET_PROPERTY(bool, AlwaysShowTabs, true); - GETSET_PROPERTY(bool, ShowTitleInTitlebar, true); - GETSET_PROPERTY(bool, ConfirmCloseAllTabs, true); - GETSET_PROPERTY(winrt::Windows::UI::Xaml::ElementTheme, Theme, winrt::Windows::UI::Xaml::ElementTheme::Default); - GETSET_PROPERTY(winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal); - GETSET_PROPERTY(bool, ShowTabsInTitlebar, true); - GETSET_PROPERTY(std::wstring, WordDelimiters); // default value set in constructor - GETSET_PROPERTY(bool, CopyOnSelect, false); - GETSET_PROPERTY(winrt::Microsoft::Terminal::TerminalControl::CopyFormat, CopyFormatting, 0); - GETSET_PROPERTY(bool, WarnAboutLargePaste, true); - GETSET_PROPERTY(bool, WarnAboutMultiLinePaste, true); - GETSET_PROPERTY(LaunchPosition, InitialPosition); - GETSET_PROPERTY(winrt::TerminalApp::LaunchMode, LaunchMode, winrt::TerminalApp::LaunchMode::DefaultMode); - GETSET_PROPERTY(bool, SnapToGridOnResize, true); - GETSET_PROPERTY(bool, ForceFullRepaintRendering, false); - GETSET_PROPERTY(bool, SoftwareRendering, false); - GETSET_PROPERTY(bool, ForceVTInput, false); - GETSET_PROPERTY(bool, DebugFeaturesEnabled); // default value set in constructor - GETSET_PROPERTY(bool, StartOnUserLogin, false); - GETSET_PROPERTY(bool, AlwaysOnTop, false); - GETSET_PROPERTY(bool, UseTabSwitcher, true); - -private: - std::optional _unparsedDefaultProfile; - GUID _defaultProfile; - - winrt::com_ptr _keybindings; - std::vector<::TerminalApp::SettingsLoadWarnings> _keybindingsWarnings; - - std::unordered_map _colorSchemes; - winrt::Windows::Foundation::Collections::IMap _commands; - - friend class TerminalAppLocalTests::SettingsTests; - friend class TerminalAppLocalTests::ColorSchemeTests; -}; + struct GlobalAppSettings : GlobalAppSettingsT + { + public: + GlobalAppSettings(); + + Windows::Foundation::Collections::IMapView GetColorSchemes() noexcept; + void AddColorScheme(const TerminalApp::ColorScheme& scheme); + + TerminalApp::AppKeyBindings GetKeybindings() const noexcept; + + static com_ptr FromJson(const Json::Value& json); + void LayerJson(const Json::Value& json); + + void ApplyToSettings(const TerminalApp::TerminalSettings& settings) const noexcept; + + std::vector<::TerminalApp::SettingsLoadWarnings> GetKeybindingsWarnings() const; + + Windows::Foundation::Collections::IMapView GetCommands() noexcept; + + // These are implemented manually to handle the string/GUID exchange + // by higher layers in the app. + void DefaultProfile(const guid& defaultProfile) noexcept; + guid DefaultProfile() const; + hstring UnparsedDefaultProfile() const; + + GETSET_PROPERTY(int32_t, InitialRows, DEFAULT_ROWS); + GETSET_PROPERTY(int32_t, InitialCols, DEFAULT_COLS); + GETSET_PROPERTY(bool, AlwaysShowTabs, true); + GETSET_PROPERTY(bool, ShowTitleInTitlebar, true); + GETSET_PROPERTY(bool, ConfirmCloseAllTabs, true); + GETSET_PROPERTY(winrt::Windows::UI::Xaml::ElementTheme, Theme, winrt::Windows::UI::Xaml::ElementTheme::Default); + GETSET_PROPERTY(winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal); + GETSET_PROPERTY(bool, ShowTabsInTitlebar, true); + GETSET_PROPERTY(hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS); + GETSET_PROPERTY(bool, CopyOnSelect, false); + GETSET_PROPERTY(winrt::Microsoft::Terminal::TerminalControl::CopyFormat, CopyFormatting, 0); + GETSET_PROPERTY(bool, WarnAboutLargePaste, true); + GETSET_PROPERTY(bool, WarnAboutMultiLinePaste, true); + GETSET_PROPERTY(winrt::TerminalApp::LaunchPosition, InitialPosition, nullptr, nullptr); + GETSET_PROPERTY(winrt::TerminalApp::LaunchMode, LaunchMode, winrt::TerminalApp::LaunchMode::DefaultMode); + GETSET_PROPERTY(bool, SnapToGridOnResize, true); + GETSET_PROPERTY(bool, ForceFullRepaintRendering, false); + GETSET_PROPERTY(bool, SoftwareRendering, false); + GETSET_PROPERTY(bool, ForceVTInput, false); + GETSET_PROPERTY(bool, DebugFeaturesEnabled); // default value set in constructor + GETSET_PROPERTY(bool, StartOnUserLogin, false); + GETSET_PROPERTY(bool, AlwaysOnTop, false); + GETSET_PROPERTY(bool, UseTabSwitcher, true); + + private: + hstring _unparsedDefaultProfile; + guid _defaultProfile; + + com_ptr _keybindings; + std::vector<::TerminalApp::SettingsLoadWarnings> _keybindingsWarnings; + + Windows::Foundation::Collections::IMap _colorSchemes; + Windows::Foundation::Collections::IMap _commands; + + friend class TerminalAppLocalTests::SettingsTests; + friend class TerminalAppLocalTests::ColorSchemeTests; + }; +} diff --git a/src/cascadia/TerminalApp/GlobalAppSettings.idl b/src/cascadia/TerminalApp/GlobalAppSettings.idl new file mode 100644 index 00000000000..6b0de0440ab --- /dev/null +++ b/src/cascadia/TerminalApp/GlobalAppSettings.idl @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import "AppLogic.idl"; +import "ColorScheme.idl"; +import "AppKeybindings.idl"; +import "Command.idl"; +import "TerminalSettings.idl"; + +namespace TerminalApp +{ + // MIDL 3 allows for structs to hold nullable types + // Though IReference is a WinRT object, MIDL 3 + // handles all of the ownership logic for us. + // Docs: https://docs.microsoft.com/en-us/uwp/midl-3/intro#types + struct LaunchPosition + { + Windows.Foundation.IReference X; + Windows.Foundation.IReference Y; + }; + + [default_interface] runtimeclass GlobalAppSettings { + Guid DefaultProfile; + String UnparsedDefaultProfile(); + + Int32 InitialRows; + Int32 InitialCols; + Boolean AlwaysShowTabs; + Boolean ShowTitleInTitlebar; + Boolean ConfirmCloseAllTabs; + Windows.UI.Xaml.ElementTheme Theme; + Microsoft.UI.Xaml.Controls.TabViewWidthMode TabWidthMode; + Boolean ShowTabsInTitlebar; + String WordDelimiters; + Boolean CopyOnSelect; + Microsoft.Terminal.TerminalControl.CopyFormat CopyFormatting; + Boolean WarnAboutLargePaste; + Boolean WarnAboutMultiLinePaste; + LaunchPosition InitialPosition; + LaunchMode LaunchMode; + Boolean SnapToGridOnResize; + Boolean ForceFullRepaintRendering; + Boolean SoftwareRendering; + Boolean ForceVTInput; + Boolean DebugFeaturesEnabled; + Boolean StartOnUserLogin; + Boolean AlwaysOnTop; + Boolean UseTabSwitcher; + + Windows.Foundation.Collections.IMapView GetColorSchemes(); + void AddColorScheme(ColorScheme scheme); + + AppKeyBindings GetKeybindings(); + + Windows.Foundation.Collections.IMapView GetCommands(); + + void ApplyToSettings(TerminalSettings settings); + } +} diff --git a/src/cascadia/TerminalApp/Profile.cpp b/src/cascadia/TerminalApp/Profile.cpp index 5a594171e68..c515c4cd414 100644 --- a/src/cascadia/TerminalApp/Profile.cpp +++ b/src/cascadia/TerminalApp/Profile.cpp @@ -75,9 +75,9 @@ Profile::Profile(guid guid) : // - schemes: a list of schemes to look for our color scheme in, if we have one. // Return Value: // - a new TerminalSettings object with our settings in it. -winrt::TerminalApp::TerminalSettings Profile::CreateTerminalSettings(const std::unordered_map& schemes) const +winrt::TerminalApp::TerminalSettings Profile::CreateTerminalSettings(const Collections::IMapView& schemes) const { - winrt::TerminalApp::TerminalSettings terminalSettings{}; + auto terminalSettings = winrt::make(); // Fill in the Terminal Setting's CoreSettings from the profile terminalSettings.HistorySize(_HistorySize); @@ -115,10 +115,9 @@ winrt::TerminalApp::TerminalSettings Profile::CreateTerminalSettings(const std:: if (!_ColorSchemeName.empty()) { - const auto found = schemes.find(_ColorSchemeName.c_str()); - if (found != schemes.end()) + if (const auto found{ schemes.TryLookup(_ColorSchemeName) }) { - found->second.ApplyScheme(terminalSettings); + found.ApplyScheme(terminalSettings); } } if (_Foreground) @@ -516,7 +515,7 @@ winrt::guid Profile::Guid() const return *_Guid; } -void Profile::Guid(winrt::guid guid) noexcept +void Profile::Guid(const winrt::guid& guid) noexcept { _Guid = guid; } @@ -531,7 +530,7 @@ winrt::guid Profile::ConnectionType() const noexcept return *_ConnectionType; } -void Profile::ConnectionType(winrt::guid conType) noexcept +void Profile::ConnectionType(const winrt::guid& conType) noexcept { _ConnectionType = conType; } diff --git a/src/cascadia/TerminalApp/Profile.h b/src/cascadia/TerminalApp/Profile.h index 823eaae42fa..8286043c725 100644 --- a/src/cascadia/TerminalApp/Profile.h +++ b/src/cascadia/TerminalApp/Profile.h @@ -16,7 +16,7 @@ Author(s): #pragma once #include "Profile.g.h" -#include "ColorScheme.g.h" +#include "TerminalSettings.h" #include "../inc/cppwinrt_utils.h" #include "JsonUtils.h" @@ -46,7 +46,7 @@ namespace winrt::TerminalApp::implementation Profile(); Profile(guid guid); - TerminalApp::TerminalSettings CreateTerminalSettings(const std::unordered_map& schemes) const; + TerminalApp::TerminalSettings CreateTerminalSettings(const Windows::Foundation::Collections::IMapView& schemes) const; Json::Value GenerateStub() const; static com_ptr FromJson(const Json::Value& json); @@ -61,11 +61,11 @@ namespace winrt::TerminalApp::implementation bool HasGuid() const noexcept; winrt::guid Guid() const; - void Guid(winrt::guid guid) noexcept; + void Guid(const winrt::guid& guid) noexcept; bool HasConnectionType() const noexcept; winrt::guid ConnectionType() const noexcept; - void ConnectionType(winrt::guid conType) noexcept; + void ConnectionType(const winrt::guid& conType) noexcept; // BackgroundImageAlignment is 1 setting saved as 2 separate values const Windows::UI::Xaml::HorizontalAlignment BackgroundImageHorizontalAlignment() const noexcept; diff --git a/src/cascadia/TerminalApp/SettingsTypes.h b/src/cascadia/TerminalApp/SettingsTypes.h index 946b1951cba..0fc1fa0bb6a 100644 --- a/src/cascadia/TerminalApp/SettingsTypes.h +++ b/src/cascadia/TerminalApp/SettingsTypes.h @@ -11,14 +11,8 @@ Module Name: #pragma once -namespace TerminalApp +namespace winrt::TerminalApp { - struct LaunchPosition - { - std::optional x; - std::optional y; - }; - enum class ExpandCommandType : uint32_t { None = 0, diff --git a/src/cascadia/TerminalApp/TerminalAppLib.vcxproj b/src/cascadia/TerminalApp/TerminalAppLib.vcxproj index a562ed31e30..f4a0ee3c25e 100644 --- a/src/cascadia/TerminalApp/TerminalAppLib.vcxproj +++ b/src/cascadia/TerminalApp/TerminalAppLib.vcxproj @@ -107,7 +107,9 @@ ColorScheme.idl - + + GlobalAppSettings.idl + Profile.idl @@ -188,7 +190,9 @@ ColorScheme.idl - + + GlobalAppSettings.idl + Profile.idl @@ -281,6 +285,7 @@ + diff --git a/src/cascadia/TerminalApp/TerminalAppLib.vcxproj.filters b/src/cascadia/TerminalApp/TerminalAppLib.vcxproj.filters index 3a2e600fd71..347c2e138cd 100644 --- a/src/cascadia/TerminalApp/TerminalAppLib.vcxproj.filters +++ b/src/cascadia/TerminalApp/TerminalAppLib.vcxproj.filters @@ -154,6 +154,9 @@ settings + + settings + diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 5c62c5ade3e..0023ccd285f 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -2070,16 +2070,16 @@ namespace winrt::TerminalApp::implementation // - IMap TerminalPage::_ExpandCommands(IMapView commandsToExpand, gsl::span profiles, - const std::unordered_map& schemes) + IMapView schemes) { std::vector<::TerminalApp::SettingsLoadWarnings> warnings; std::vector sortedSchemes; - sortedSchemes.reserve(schemes.size()); + sortedSchemes.reserve(schemes.Size()); for (const auto& nameAndScheme : schemes) { - sortedSchemes.push_back(nameAndScheme.second); + sortedSchemes.push_back(nameAndScheme.Value()); } std::sort(sortedSchemes.begin(), sortedSchemes.end(), @@ -2108,7 +2108,7 @@ namespace winrt::TerminalApp::implementation // - void TerminalPage::_UpdateCommandsForPalette() { - IMap copyOfCommands = _ExpandCommands(_settings->GlobalSettings().GetCommands().GetView(), + IMap copyOfCommands = _ExpandCommands(_settings->GlobalSettings().GetCommands(), _settings->GetProfiles(), _settings->GlobalSettings().GetColorSchemes()); diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h index b30682ada54..00f18a4cc1c 100644 --- a/src/cascadia/TerminalApp/TerminalPage.h +++ b/src/cascadia/TerminalApp/TerminalPage.h @@ -138,7 +138,7 @@ namespace winrt::TerminalApp::implementation void _UpdateCommandsForPalette(); static winrt::Windows::Foundation::Collections::IMap _ExpandCommands(Windows::Foundation::Collections::IMapView commandsToExpand, gsl::span profiles, - const std::unordered_map& schemes); + Windows::Foundation::Collections::IMapView schemes); void _DuplicateTabViewItem(); void _RemoveTabViewItem(const Microsoft::UI::Xaml::Controls::TabViewItem& tabViewItem); diff --git a/src/cascadia/TerminalApp/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalApp/TerminalSettingsSerializationHelpers.h index deb7856063a..47e2c681025 100644 --- a/src/cascadia/TerminalApp/TerminalSettingsSerializationHelpers.h +++ b/src/cascadia/TerminalApp/TerminalSettingsSerializationHelpers.h @@ -184,7 +184,7 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode) }; }; -JSON_ENUM_MAPPER(::TerminalApp::ExpandCommandType) +JSON_ENUM_MAPPER(winrt::TerminalApp::ExpandCommandType) { JSON_MAPPINGS(2) = { pair_type{ "profiles", ValueType::Profiles }, @@ -226,11 +226,11 @@ JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::TerminalControl::CopyFormat) // (abc, 100): if a value is not valid, we treat it as default // (100, 100, 100): we only read the first two values, this is equivalent to (100, 100) template<> -struct ::TerminalApp::JsonUtils::ConversionTrait<::TerminalApp::LaunchPosition> +struct ::TerminalApp::JsonUtils::ConversionTrait<::winrt::TerminalApp::LaunchPosition> { - ::TerminalApp::LaunchPosition FromJson(const Json::Value& json) + ::winrt::TerminalApp::LaunchPosition FromJson(const Json::Value& json) { - ::TerminalApp::LaunchPosition ret; + ::winrt::TerminalApp::LaunchPosition ret; std::string initialPosition{ json.asString() }; static constexpr char singleCharDelim = ','; std::stringstream tokenStream(initialPosition); @@ -244,15 +244,15 @@ struct ::TerminalApp::JsonUtils::ConversionTrait<::TerminalApp::LaunchPosition> { try { - int32_t position = std::stoi(token); + int64_t position = std::stol(token); if (initialPosIndex == 0) { - ret.x.emplace(position); + ret.X = position; } if (initialPosIndex == 1) { - ret.y.emplace(position); + ret.Y = position; } } catch (...) diff --git a/src/cascadia/WindowsTerminal/AppHost.cpp b/src/cascadia/WindowsTerminal/AppHost.cpp index 0ae788956a5..d7896b6aa32 100644 --- a/src/cascadia/WindowsTerminal/AppHost.cpp +++ b/src/cascadia/WindowsTerminal/AppHost.cpp @@ -241,9 +241,9 @@ void AppHost::_HandleCreateWindow(const HWND hwnd, RECT proposedRect, winrt::Ter launchMode = _logic.GetLaunchMode(); // Acquire the actual initial position - winrt::Windows::Foundation::Point initialPosition = _logic.GetLaunchInitialPositions(proposedRect.left, proposedRect.top); - proposedRect.left = gsl::narrow_cast(initialPosition.X); - proposedRect.top = gsl::narrow_cast(initialPosition.Y); + auto initialPos = _logic.GetInitialPosition(proposedRect.left, proposedRect.top); + proposedRect.left = static_cast(initialPos.X); + proposedRect.top = static_cast(initialPos.Y); long adjustedHeight = 0; long adjustedWidth = 0;