mirror of
https://github.com/microsoft/terminal.git
synced 2026-07-08 18:16:28 +00:00
Improve clear mechanism
This commit is contained in:
@@ -813,73 +813,20 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
|
||||
void ProfileViewModel::ResetSettings()
|
||||
{
|
||||
// Clear all profile-level settings (not Guid/ConnectionType which are permanent)
|
||||
// NOTE: When adding a new OBSERVABLE_PROJECTED_SETTING to ProfileViewModel,
|
||||
// also add the corresponding ClearX() call here.
|
||||
ClearName();
|
||||
ClearSource();
|
||||
ClearHidden();
|
||||
ClearIcon();
|
||||
ClearCloseOnExit();
|
||||
ClearTabTitle();
|
||||
ClearTabColor();
|
||||
ClearSuppressApplicationTitle();
|
||||
ClearScrollState();
|
||||
ClearPadding();
|
||||
ClearCommandline();
|
||||
ClearStartingDirectory();
|
||||
// Clear every projected profile setting. Each Clear##name() notifies the bound
|
||||
// properties and cascades to derived previews via our PropertyChanged handler.
|
||||
#define PROFILE_VIEW_MODEL_CLEAR_SETTING(target, name) Clear##name();
|
||||
PROFILE_VIEW_MODEL_PROJECTED_SETTINGS(PROFILE_VIEW_MODEL_CLEAR_SETTING)
|
||||
#undef PROFILE_VIEW_MODEL_CLEAR_SETTING
|
||||
_lastStartingDirectoryPath.clear();
|
||||
ClearAntialiasingMode();
|
||||
ClearOpacity();
|
||||
ClearUseAcrylic();
|
||||
ClearHistorySize();
|
||||
ClearSnapOnInput();
|
||||
ClearAltGrAliasing();
|
||||
ClearBellStyle();
|
||||
ClearBellSound();
|
||||
ClearElevate();
|
||||
ClearReloadEnvironmentVariables();
|
||||
ClearRightClickContextMenu();
|
||||
ClearShowMarks();
|
||||
ClearAutoMarkPrompts();
|
||||
ClearRepositionCursorWithMouse();
|
||||
ClearForceVTInput();
|
||||
ClearAllowKittyKeyboardMode();
|
||||
ClearAllowVtChecksumReport();
|
||||
ClearAllowVtClipboardWrite();
|
||||
ClearAnswerbackMessage();
|
||||
ClearRainbowSuggestions();
|
||||
ClearPathTranslationStyle();
|
||||
ClearDragDropDelimiter();
|
||||
|
||||
// Clear appearance settings on the underlying models.
|
||||
const auto defaultAppearance = _profile.DefaultAppearance();
|
||||
defaultAppearance.ClearDarkColorSchemeName();
|
||||
defaultAppearance.ClearLightColorSchemeName();
|
||||
defaultAppearance.ClearRetroTerminalEffect();
|
||||
defaultAppearance.ClearCursorShape();
|
||||
defaultAppearance.ClearCursorHeight();
|
||||
defaultAppearance.ClearBackgroundImagePath();
|
||||
defaultAppearance.ClearBackgroundImageOpacity();
|
||||
defaultAppearance.ClearBackgroundImageStretchMode();
|
||||
defaultAppearance.ClearBackgroundImageAlignment();
|
||||
defaultAppearance.ClearIntenseTextStyle();
|
||||
defaultAppearance.ClearAdjustIndistinguishableColors();
|
||||
defaultAppearance.ClearForeground();
|
||||
defaultAppearance.ClearBackground();
|
||||
defaultAppearance.ClearSelectionBackground();
|
||||
defaultAppearance.ClearCursorColor();
|
||||
// Not exposed to SUI
|
||||
_profile.ClearEnvironmentVariables();
|
||||
_profile.ClearAllowKeypadMode();
|
||||
|
||||
const auto fontConfig = _profile.FontInfo();
|
||||
fontConfig.ClearFontFace();
|
||||
fontConfig.ClearFontSize();
|
||||
fontConfig.ClearCellHeight();
|
||||
fontConfig.ClearCellWidth();
|
||||
fontConfig.ClearFontWeight();
|
||||
fontConfig.ClearEnableBuiltinGlyphs();
|
||||
fontConfig.ClearEnableColorGlyphs();
|
||||
fontConfig.ClearFontAxes();
|
||||
fontConfig.ClearFontFeatures();
|
||||
// Clear complex child objects
|
||||
_profile.DefaultAppearance().ClearAllSettings();
|
||||
_profile.FontInfo().ClearAllSettings();
|
||||
|
||||
if (HasUnfocusedAppearance())
|
||||
{
|
||||
|
||||
@@ -114,41 +114,50 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_profile, Guid);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_profile, ConnectionType);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, Name);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, Source);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, Hidden);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, Icon);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, CloseOnExit);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, TabTitle);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, TabColor);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, SuppressApplicationTitle);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, ScrollState);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, Padding);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, Commandline);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, StartingDirectory);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AntialiasingMode);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile.DefaultAppearance(), Opacity);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile.DefaultAppearance(), UseAcrylic);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, HistorySize);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, SnapOnInput);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AltGrAliasing);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, BellStyle);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, BellSound);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, Elevate);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, ReloadEnvironmentVariables);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, RightClickContextMenu);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, ShowMarks);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AutoMarkPrompts);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, RepositionCursorWithMouse);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, ForceVTInput);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AllowKittyKeyboardMode);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AllowVtChecksumReport);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AllowVtClipboardWrite);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AllowOscNotifications);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AnswerbackMessage);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, RainbowSuggestions);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, PathTranslationStyle);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, DragDropDelimiter);
|
||||
|
||||
// The clearable settings this view model projects from the underlying profile model.
|
||||
// This is the single source of truth for both the declarations below and the
|
||||
// ClearX() calls in ResetSettings()
|
||||
#define PROFILE_VIEW_MODEL_PROJECTED_SETTINGS(X) \
|
||||
X(_profile, Name) \
|
||||
X(_profile, Source) \
|
||||
X(_profile, Hidden) \
|
||||
X(_profile, Icon) \
|
||||
X(_profile, CloseOnExit) \
|
||||
X(_profile, TabTitle) \
|
||||
X(_profile, TabColor) \
|
||||
X(_profile, SuppressApplicationTitle) \
|
||||
X(_profile, ScrollState) \
|
||||
X(_profile, Padding) \
|
||||
X(_profile, Commandline) \
|
||||
X(_profile, StartingDirectory) \
|
||||
X(_profile, AntialiasingMode) \
|
||||
X(_profile.DefaultAppearance(), Opacity) \
|
||||
X(_profile.DefaultAppearance(), UseAcrylic) \
|
||||
X(_profile, HistorySize) \
|
||||
X(_profile, SnapOnInput) \
|
||||
X(_profile, AltGrAliasing) \
|
||||
X(_profile, BellStyle) \
|
||||
X(_profile, BellSound) \
|
||||
X(_profile, Elevate) \
|
||||
X(_profile, ReloadEnvironmentVariables) \
|
||||
X(_profile, RightClickContextMenu) \
|
||||
X(_profile, ShowMarks) \
|
||||
X(_profile, AutoMarkPrompts) \
|
||||
X(_profile, RepositionCursorWithMouse) \
|
||||
X(_profile, ForceVTInput) \
|
||||
X(_profile, AllowKittyKeyboardMode) \
|
||||
X(_profile, AllowVtChecksumReport) \
|
||||
X(_profile, AllowVtClipboardWrite) \
|
||||
X(_profile, AllowOscNotifications) \
|
||||
X(_profile, AnswerbackMessage) \
|
||||
X(_profile, RainbowSuggestions) \
|
||||
X(_profile, PathTranslationStyle) \
|
||||
X(_profile, DragDropDelimiter)
|
||||
|
||||
#define PROFILE_VIEW_MODEL_DECLARE_SETTING(target, name) OBSERVABLE_PROJECTED_SETTING(target, name);
|
||||
PROFILE_VIEW_MODEL_PROJECTED_SETTINGS(PROFILE_VIEW_MODEL_DECLARE_SETTING)
|
||||
#undef PROFILE_VIEW_MODEL_DECLARE_SETTING
|
||||
|
||||
WINRT_PROPERTY(bool, IsBaseLayer, false);
|
||||
WINRT_PROPERTY(bool, FocusDeleteButton, false);
|
||||
|
||||
@@ -138,6 +138,23 @@ winrt::Microsoft::Terminal::Settings::Model::Profile AppearanceConfig::SourcePro
|
||||
return _sourceProfile.get();
|
||||
}
|
||||
|
||||
void AppearanceConfig::ClearAllSettings()
|
||||
{
|
||||
#define APPEARANCE_SETTINGS_CLEAR(type, name, jsonKey, ...) \
|
||||
Clear##name();
|
||||
MTSM_APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_CLEAR)
|
||||
#undef APPEARANCE_SETTINGS_CLEAR
|
||||
|
||||
// The following settings aren't part of MTSM_APPEARANCE_SETTINGS, so clear them explicitly.
|
||||
ClearForeground();
|
||||
ClearBackground();
|
||||
ClearSelectionBackground();
|
||||
ClearCursorColor();
|
||||
ClearOpacity();
|
||||
ClearDarkColorSchemeName();
|
||||
ClearLightColorSchemeName();
|
||||
}
|
||||
|
||||
std::tuple<winrt::hstring, Model::OriginTag> AppearanceConfig::_getSourceProfileBasePathAndOrigin() const
|
||||
{
|
||||
winrt::hstring sourceBasePath{};
|
||||
|
||||
@@ -36,6 +36,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
|
||||
Model::Profile SourceProfile();
|
||||
|
||||
void ClearAllSettings();
|
||||
|
||||
void ResolveMediaResources(const Model::MediaResourceResolver& resolver);
|
||||
|
||||
INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, Foreground, nullptr);
|
||||
|
||||
@@ -110,6 +110,14 @@ winrt::Microsoft::Terminal::Settings::Model::Profile FontConfig::SourceProfile()
|
||||
return _sourceProfile.get();
|
||||
}
|
||||
|
||||
void FontConfig::ClearAllSettings()
|
||||
{
|
||||
#define FONT_SETTINGS_CLEAR(type, name, jsonKey, ...) \
|
||||
Clear##name();
|
||||
MTSM_FONT_SETTINGS(FONT_SETTINGS_CLEAR)
|
||||
#undef FONT_SETTINGS_CLEAR
|
||||
}
|
||||
|
||||
void FontConfig::_logSettingSet(const std::string_view& setting)
|
||||
{
|
||||
if (setting == "axes" && _FontAxes.has_value())
|
||||
|
||||
@@ -39,6 +39,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
|
||||
Model::Profile SourceProfile();
|
||||
|
||||
void ClearAllSettings();
|
||||
|
||||
#define FONT_SETTINGS_INITIALIZE(type, name, jsonKey, ...) \
|
||||
INHERITABLE_SETTING(Model::FontConfig, type, name, ##__VA_ARGS__)
|
||||
MTSM_FONT_SETTINGS(FONT_SETTINGS_INITIALIZE)
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
[default_interface] runtimeclass FontConfig {
|
||||
Microsoft.Terminal.Settings.Model.Profile SourceProfile { get; };
|
||||
|
||||
void ClearAllSettings();
|
||||
|
||||
INHERITABLE_FONT_SETTING(String, FontFace);
|
||||
INHERITABLE_FONT_SETTING(Single, FontSize);
|
||||
INHERITABLE_FONT_SETTING(Windows.UI.Text.FontWeight, FontWeight);
|
||||
|
||||
@@ -33,6 +33,8 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
{
|
||||
Microsoft.Terminal.Settings.Model.Profile SourceProfile { get; };
|
||||
|
||||
void ClearAllSettings();
|
||||
|
||||
INHERITABLE_APPEARANCE_SETTING(String, DarkColorSchemeName);
|
||||
INHERITABLE_APPEARANCE_SETTING(String, LightColorSchemeName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user