mirror of
https://github.com/microsoft/terminal.git
synced 2026-02-08 05:37:27 +00:00
Amazingly, persist the selected scheme across saves/navigations
This commit is contained in:
@@ -73,6 +73,23 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
auto entry = winrt::make<ColorTableEntry>(i, Windows::UI::Color{ 0, 0, 0, 0 });
|
||||
_CurrentColorTable.Append(entry);
|
||||
}
|
||||
|
||||
std::wstring lastNameFromNav{ _State.LastSelectedScheme().c_str() };
|
||||
std::wstring lastName{ _lastSchemeName.c_str() };
|
||||
std::wstring currentName{ CurrentColorScheme() ? CurrentColorScheme().Name().c_str() : L"" };
|
||||
lastName;
|
||||
currentName;
|
||||
lastNameFromNav;
|
||||
|
||||
auto it = std::find_if(begin(_ColorSchemeList),
|
||||
end(_ColorSchemeList),
|
||||
[&lastNameFromNav](const auto& scheme) { return scheme.Name() == lastNameFromNav; });
|
||||
|
||||
if (it != end(_ColorSchemeList))
|
||||
{
|
||||
auto scheme = *it;
|
||||
ColorSchemeComboBox().SelectedItem(scheme);
|
||||
}
|
||||
}
|
||||
|
||||
// Function Description:
|
||||
@@ -90,6 +107,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
CurrentColorScheme(colorScheme);
|
||||
_UpdateColorTable(colorScheme);
|
||||
|
||||
_lastSchemeName = colorScheme.Name();
|
||||
_State.LastSelectedScheme(colorScheme.Name());
|
||||
|
||||
// Set the text disclaimer for the text box
|
||||
hstring disclaimer{};
|
||||
const std::wstring schemeName{ colorScheme.Name() };
|
||||
@@ -120,6 +140,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
_ColorSchemeList.Append(pair.Value());
|
||||
}
|
||||
|
||||
if (_lastSchemeName == L"" && _ColorSchemeList.Size() > 0)
|
||||
{
|
||||
_lastSchemeName = _ColorSchemeList.GetAt(0).Name();
|
||||
}
|
||||
}
|
||||
|
||||
// Function Description:
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
_Globals{ settings } {}
|
||||
|
||||
GETSET_PROPERTY(Model::GlobalAppSettings, Globals, nullptr);
|
||||
GETSET_PROPERTY(winrt::hstring, LastSelectedScheme, L"");
|
||||
};
|
||||
|
||||
struct ColorSchemes : ColorSchemesT<ColorSchemes>
|
||||
@@ -49,6 +50,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
void _UpdateColorTable(const winrt::Microsoft::Terminal::Settings::Model::ColorScheme& colorScheme);
|
||||
void _UpdateColorSchemeList();
|
||||
void _RenameCurrentScheme(hstring newName);
|
||||
|
||||
winrt::hstring _lastSchemeName;
|
||||
};
|
||||
|
||||
struct ColorTableEntry : ColorTableEntryT<ColorTableEntry>
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||
runtimeclass ColorSchemesPageNavigationState
|
||||
{
|
||||
Microsoft.Terminal.Settings.Model.GlobalAppSettings Globals;
|
||||
String LastSelectedScheme;
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass ColorSchemes : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged
|
||||
|
||||
@@ -49,6 +49,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
InitializeComponent();
|
||||
|
||||
_InitializeProfilesList();
|
||||
|
||||
_colorSchemesNavState = winrt::make<ColorSchemesPageNavigationState>(_settingsClone.GlobalSettings());
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -94,6 +96,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
}
|
||||
_InitializeProfilesList();
|
||||
|
||||
_colorSchemesNavState.Globals(_settingsClone.GlobalSettings());
|
||||
|
||||
_RefreshCurrentPage();
|
||||
}
|
||||
|
||||
@@ -225,7 +229,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
}
|
||||
else if (clickedItemTag == colorSchemesTag)
|
||||
{
|
||||
contentFrame().Navigate(xaml_typename<Editor::ColorSchemes>(), winrt::make<ColorSchemesPageNavigationState>(_settingsClone.GlobalSettings()));
|
||||
// contentFrame().Navigate(xaml_typename<Editor::ColorSchemes>(), winrt::make<ColorSchemesPageNavigationState>(_settingsClone.GlobalSettings()));
|
||||
contentFrame().Navigate(xaml_typename<Editor::ColorSchemes>(), _colorSchemesNavState);
|
||||
}
|
||||
else if (clickedItemTag == globalAppearanceTag)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "MainPage.g.h"
|
||||
#include "Utils.h"
|
||||
#include "Utils.h"
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
@@ -41,6 +42,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
void _Navigate(hstring clickedItemTag);
|
||||
void _Navigate(const Editor::ProfileViewModel& profile);
|
||||
void _RefreshCurrentPage();
|
||||
|
||||
ColorSchemesPageNavigationState _colorSchemesNavState{ nullptr };
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user