diff --git a/src/cascadia/TerminalApp/AppActionHandlers.cpp b/src/cascadia/TerminalApp/AppActionHandlers.cpp index 87aa865335e..9f69b40267d 100644 --- a/src/cascadia/TerminalApp/AppActionHandlers.cpp +++ b/src/cascadia/TerminalApp/AppActionHandlers.cpp @@ -388,6 +388,16 @@ namespace winrt::TerminalApp::implementation activeControl.UpdateSettings(); args.Handled(true); } + else if (realArgs.SchemeName() == winrt::to_hstring(L"_random")) + { + if (const auto scheme = _settings.GlobalSettings().ColorSchemes().TryLookup(L"Campbell")) + { + auto controlSettings = activeControl.Settings().as(); + controlSettings.ApplyColorScheme(scheme); + activeControl.UpdateSettings(); + args.Handled(true); + } + } } } } diff --git a/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp b/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp index 1cef8481b06..d5664841c69 100644 --- a/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp @@ -261,7 +261,11 @@ void CascadiaSettings::ClearWarnings() void CascadiaSettings::AppendWarning(SettingsLoadWarnings warning) { - _warnings.Append(warning); + warning = warning; + int i = 0; + ++i; + return; + // _warnings.Append(warning); } winrt::Windows::Foundation::IReference CascadiaSettings::GetLoadingError() @@ -382,15 +386,15 @@ void CascadiaSettings::_ValidateDefaultProfileExists() } } - if (nullDefaultProfile || defaultProfileNotInProfiles) - { - _warnings.Append(Microsoft::Terminal::Settings::Model::SettingsLoadWarnings::MissingDefaultProfile); - // Use the first profile as the new default + // if (nullDefaultProfile || defaultProfileNotInProfiles) + // { + // _warnings.Append(Microsoft::Terminal::Settings::Model::SettingsLoadWarnings::MissingDefaultProfile); + // // Use the first profile as the new default - // _temporarily_ set the default profile to the first profile. Because - // we're adding a warning, this settings change won't be re-serialized. - GlobalSettings().DefaultProfile(_allProfiles.GetAt(0).Guid()); - } + // // _temporarily_ set the default profile to the first profile. Because + // // we're adding a warning, this settings change won't be re-serialized. + // GlobalSettings().DefaultProfile(_allProfiles.GetAt(0).Guid()); + // } } // Method Description: @@ -425,10 +429,10 @@ void CascadiaSettings::_ValidateNoDuplicateProfiles() _allProfiles.RemoveAt(*iter); } - if (foundDupe) - { - _warnings.Append(Microsoft::Terminal::Settings::Model::SettingsLoadWarnings::DuplicateProfile); - } + // if (foundDupe) + // { + // _warnings.Append(Microsoft::Terminal::Settings::Model::SettingsLoadWarnings::DuplicateProfile); + // } } // Method Description: @@ -550,10 +554,10 @@ void CascadiaSettings::_ValidateAllSchemesExist() } } - if (foundInvalidScheme) - { - _warnings.Append(SettingsLoadWarnings::UnknownColorScheme); - } + // if (foundInvalidScheme) + // { + // _warnings.Append(SettingsLoadWarnings::UnknownColorScheme); + // } } // Method Description: @@ -630,15 +634,15 @@ void CascadiaSettings::_ValidateMediaResources() } } - if (invalidBackground) - { - _warnings.Append(SettingsLoadWarnings::InvalidBackgroundImage); - } + // if (invalidBackground) + // { + // _warnings.Append(SettingsLoadWarnings::InvalidBackgroundImage); + // } - if (invalidIcon) - { - _warnings.Append(SettingsLoadWarnings::InvalidIcon); - } + // if (invalidIcon) + // { + // _warnings.Append(SettingsLoadWarnings::InvalidIcon); + // } } // Method Description: @@ -758,15 +762,16 @@ std::optional CascadiaSettings::_GetProfileGuidByIndex(std::optiona void CascadiaSettings::_ValidateKeybindings() { auto keybindingWarnings = _globals->KeybindingsWarnings(); + return; - if (!keybindingWarnings.empty()) - { - _warnings.Append(SettingsLoadWarnings::AtLeastOneKeybindingWarning); - for (auto warning : keybindingWarnings) - { - _warnings.Append(warning); - } - } + // if (!keybindingWarnings.empty()) + // { + // _warnings.Append(SettingsLoadWarnings::AtLeastOneKeybindingWarning); + // for (auto warning : keybindingWarnings) + // { + // _warnings.Append(warning); + // } + // } } // Method Description: @@ -789,14 +794,15 @@ void CascadiaSettings::_ValidateColorSchemesInCommands() } } - if (foundInvalidScheme) - { - _warnings.Append(SettingsLoadWarnings::InvalidColorSchemeInCmd); - } + // if (foundInvalidScheme) + // { + // _warnings.Append(SettingsLoadWarnings::InvalidColorSchemeInCmd); + // } } bool CascadiaSettings::_HasInvalidColorScheme(const Model::Command& command) { + return false; bool invalid{ false }; if (command.HasNestedCommands()) { @@ -840,11 +846,14 @@ bool CascadiaSettings::_HasInvalidColorScheme(const Model::Command& command) // we find any invalid background images. void CascadiaSettings::_ValidateNoGlobalsKey() { - // use isMember here. If you use [], you're actually injecting "globals": null. - if (_userSettings.isMember("globals")) - { - _warnings.Append(SettingsLoadWarnings::LegacyGlobalsProperty); - } + int i = 0; + ++i; + return; + // // use isMember here. If you use [], you're actually injecting "globals": null. + // if (_userSettings.isMember("globals")) + // { + // _warnings.Append(SettingsLoadWarnings::LegacyGlobalsProperty); + // } } // Method Description diff --git a/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp b/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp index e63775a19f2..bf535fd4580 100644 --- a/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp +++ b/src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp @@ -1092,6 +1092,13 @@ winrt::com_ptr CascadiaSettings::_FindMatchingColorScheme(const Jso { return winrt::get_self(scheme)->get_strong(); } + else if (*schemeName == winrt::to_hstring(L"_random")) + { + if (auto scheme{ _globals->ColorSchemes().TryLookup(L"Campbell") }) + { + return winrt::get_self(scheme)->get_strong(); + } + } } return nullptr; } diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp index b4518546bbd..4c706fee9e3 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp @@ -141,6 +141,13 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation { defaultSettings.ApplyColorScheme(scheme); } + else if (newTerminalArgs.ColorScheme() == winrt::to_hstring(L"_random")) + { + if (const auto& scheme = schemes.TryLookup(L"Campbell")) + { + defaultSettings.ApplyColorScheme(scheme); + } + } } } @@ -153,10 +160,16 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation _CursorHeight = appearance.CursorHeight(); if (!appearance.ColorSchemeName().empty()) { + // TODO: Edit this scheme to apply a random scheme if (const auto scheme = schemes.TryLookup(appearance.ColorSchemeName())) { ApplyColorScheme(scheme); } + else if (appearance.ColorSchemeName() == winrt::to_hstring(L"_random")) + { + const auto scheme = schemes.TryLookup(winrt::to_hstring(L"Tango Light")); + ApplyColorScheme(scheme); + } } if (appearance.Foreground()) {