Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace some of our macros to reduce confusion, increase success #9376

Merged
merged 6 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 44 additions & 44 deletions src/cascadia/TerminalApp/TerminalSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@ namespace winrt::TerminalApp::implementation
void ColorTable(std::array<uint32_t, 16> colors);
std::array<uint32_t, 16> ColorTable();

GETSET_SETTING(TerminalApp::TerminalSettings, uint32_t, DefaultForeground, DEFAULT_FOREGROUND_WITH_ALPHA);
GETSET_SETTING(TerminalApp::TerminalSettings, uint32_t, DefaultBackground, DEFAULT_BACKGROUND_WITH_ALPHA);
GETSET_SETTING(TerminalApp::TerminalSettings, uint32_t, SelectionBackground, DEFAULT_FOREGROUND);
GETSET_SETTING(TerminalApp::TerminalSettings, int32_t, HistorySize, DEFAULT_HISTORY_SIZE);
GETSET_SETTING(TerminalApp::TerminalSettings, int32_t, InitialRows, 30);
GETSET_SETTING(TerminalApp::TerminalSettings, int32_t, InitialCols, 80);

GETSET_SETTING(TerminalApp::TerminalSettings, bool, SnapOnInput, true);
GETSET_SETTING(TerminalApp::TerminalSettings, bool, AltGrAliasing, true);
GETSET_SETTING(TerminalApp::TerminalSettings, uint32_t, CursorColor, DEFAULT_CURSOR_COLOR);
GETSET_SETTING(TerminalApp::TerminalSettings, Microsoft::Terminal::TerminalControl::CursorStyle, CursorShape, Microsoft::Terminal::TerminalControl::CursorStyle::Vintage);
GETSET_SETTING(TerminalApp::TerminalSettings, uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT);
GETSET_SETTING(TerminalApp::TerminalSettings, hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS);
GETSET_SETTING(TerminalApp::TerminalSettings, bool, CopyOnSelect, false);
GETSET_SETTING(TerminalApp::TerminalSettings, bool, InputServiceWarning, true);
GETSET_SETTING(TerminalApp::TerminalSettings, bool, FocusFollowMouse, false);

GETSET_SETTING(TerminalApp::TerminalSettings, Windows::Foundation::IReference<uint32_t>, TabColor, nullptr);
SETTING(TerminalApp::TerminalSettings, uint32_t, DefaultForeground, DEFAULT_FOREGROUND_WITH_ALPHA);
SETTING(TerminalApp::TerminalSettings, uint32_t, DefaultBackground, DEFAULT_BACKGROUND_WITH_ALPHA);
SETTING(TerminalApp::TerminalSettings, uint32_t, SelectionBackground, DEFAULT_FOREGROUND);
SETTING(TerminalApp::TerminalSettings, int32_t, HistorySize, DEFAULT_HISTORY_SIZE);
SETTING(TerminalApp::TerminalSettings, int32_t, InitialRows, 30);
SETTING(TerminalApp::TerminalSettings, int32_t, InitialCols, 80);

SETTING(TerminalApp::TerminalSettings, bool, SnapOnInput, true);
SETTING(TerminalApp::TerminalSettings, bool, AltGrAliasing, true);
SETTING(TerminalApp::TerminalSettings, uint32_t, CursorColor, DEFAULT_CURSOR_COLOR);
SETTING(TerminalApp::TerminalSettings, Microsoft::Terminal::TerminalControl::CursorStyle, CursorShape, Microsoft::Terminal::TerminalControl::CursorStyle::Vintage);
SETTING(TerminalApp::TerminalSettings, uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT);
SETTING(TerminalApp::TerminalSettings, hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS);
SETTING(TerminalApp::TerminalSettings, bool, CopyOnSelect, false);
SETTING(TerminalApp::TerminalSettings, bool, InputServiceWarning, true);
SETTING(TerminalApp::TerminalSettings, bool, FocusFollowMouse, false);

SETTING(TerminalApp::TerminalSettings, Windows::Foundation::IReference<uint32_t>, TabColor, nullptr);

// When set, StartingTabColor allows to create a terminal with a "sticky" tab color.
// This color is prioritized above the TabColor (that is usually initialized based on profile settings).
Expand All @@ -77,44 +77,44 @@ namespace winrt::TerminalApp::implementation
// TODO: to ensure that this property is not populated during settings reload,
// we should consider moving this property to a separate interface,
// passed to the terminal only upon creation.
GETSET_SETTING(TerminalApp::TerminalSettings, Windows::Foundation::IReference<uint32_t>, StartingTabColor, nullptr);
SETTING(TerminalApp::TerminalSettings, Windows::Foundation::IReference<uint32_t>, StartingTabColor, nullptr);

// ------------------------ End of Core Settings -----------------------

GETSET_SETTING(TerminalApp::TerminalSettings, hstring, ProfileName);
GETSET_SETTING(TerminalApp::TerminalSettings, bool, UseAcrylic, false);
GETSET_SETTING(TerminalApp::TerminalSettings, double, TintOpacity, 0.5);
GETSET_SETTING(TerminalApp::TerminalSettings, hstring, Padding, DEFAULT_PADDING);
GETSET_SETTING(TerminalApp::TerminalSettings, hstring, FontFace, DEFAULT_FONT_FACE);
GETSET_SETTING(TerminalApp::TerminalSettings, int32_t, FontSize, DEFAULT_FONT_SIZE);
SETTING(TerminalApp::TerminalSettings, hstring, ProfileName);
SETTING(TerminalApp::TerminalSettings, bool, UseAcrylic, false);
SETTING(TerminalApp::TerminalSettings, double, TintOpacity, 0.5);
SETTING(TerminalApp::TerminalSettings, hstring, Padding, DEFAULT_PADDING);
SETTING(TerminalApp::TerminalSettings, hstring, FontFace, DEFAULT_FONT_FACE);
SETTING(TerminalApp::TerminalSettings, int32_t, FontSize, DEFAULT_FONT_SIZE);

GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Text::FontWeight, FontWeight);
SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Text::FontWeight, FontWeight);

GETSET_SETTING(TerminalApp::TerminalSettings, hstring, BackgroundImage);
GETSET_SETTING(TerminalApp::TerminalSettings, double, BackgroundImageOpacity, 1.0);
SETTING(TerminalApp::TerminalSettings, hstring, BackgroundImage);
SETTING(TerminalApp::TerminalSettings, double, BackgroundImageOpacity, 1.0);

GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill);
GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::HorizontalAlignment, BackgroundImageHorizontalAlignment, winrt::Windows::UI::Xaml::HorizontalAlignment::Center);
GETSET_SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::VerticalAlignment, BackgroundImageVerticalAlignment, winrt::Windows::UI::Xaml::VerticalAlignment::Center);
SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill);
SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::HorizontalAlignment, BackgroundImageHorizontalAlignment, winrt::Windows::UI::Xaml::HorizontalAlignment::Center);
SETTING(TerminalApp::TerminalSettings, winrt::Windows::UI::Xaml::VerticalAlignment, BackgroundImageVerticalAlignment, winrt::Windows::UI::Xaml::VerticalAlignment::Center);

GETSET_SETTING(TerminalApp::TerminalSettings, Microsoft::Terminal::TerminalControl::IKeyBindings, KeyBindings, nullptr);
SETTING(TerminalApp::TerminalSettings, Microsoft::Terminal::TerminalControl::IKeyBindings, KeyBindings, nullptr);

GETSET_SETTING(TerminalApp::TerminalSettings, hstring, Commandline);
GETSET_SETTING(TerminalApp::TerminalSettings, hstring, StartingDirectory);
GETSET_SETTING(TerminalApp::TerminalSettings, hstring, StartingTitle);
GETSET_SETTING(TerminalApp::TerminalSettings, bool, SuppressApplicationTitle);
GETSET_SETTING(TerminalApp::TerminalSettings, hstring, EnvironmentVariables);
SETTING(TerminalApp::TerminalSettings, hstring, Commandline);
SETTING(TerminalApp::TerminalSettings, hstring, StartingDirectory);
SETTING(TerminalApp::TerminalSettings, hstring, StartingTitle);
SETTING(TerminalApp::TerminalSettings, bool, SuppressApplicationTitle);
SETTING(TerminalApp::TerminalSettings, hstring, EnvironmentVariables);

GETSET_SETTING(TerminalApp::TerminalSettings, Microsoft::Terminal::TerminalControl::ScrollbarState, ScrollState, Microsoft::Terminal::TerminalControl::ScrollbarState::Visible);
SETTING(TerminalApp::TerminalSettings, Microsoft::Terminal::TerminalControl::ScrollbarState, ScrollState, Microsoft::Terminal::TerminalControl::ScrollbarState::Visible);

GETSET_SETTING(TerminalApp::TerminalSettings, Microsoft::Terminal::TerminalControl::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::TerminalControl::TextAntialiasingMode::Grayscale);
SETTING(TerminalApp::TerminalSettings, Microsoft::Terminal::TerminalControl::TextAntialiasingMode, AntialiasingMode, Microsoft::Terminal::TerminalControl::TextAntialiasingMode::Grayscale);

GETSET_SETTING(TerminalApp::TerminalSettings, bool, RetroTerminalEffect, false);
GETSET_SETTING(TerminalApp::TerminalSettings, bool, ForceFullRepaintRendering, false);
GETSET_SETTING(TerminalApp::TerminalSettings, bool, SoftwareRendering, false);
GETSET_SETTING(TerminalApp::TerminalSettings, bool, ForceVTInput, false);
SETTING(TerminalApp::TerminalSettings, bool, RetroTerminalEffect, false);
SETTING(TerminalApp::TerminalSettings, bool, ForceFullRepaintRendering, false);
SETTING(TerminalApp::TerminalSettings, bool, SoftwareRendering, false);
SETTING(TerminalApp::TerminalSettings, bool, ForceVTInput, false);

GETSET_PROPERTY(hstring, PixelShaderPath);
SETTING(TerminalApp::TerminalSettings, hstring, PixelShaderPath);

private:
std::optional<std::array<uint32_t, COLOR_TABLE_SIZE>> _ColorTable;
Expand Down
58 changes: 29 additions & 29 deletions src/cascadia/TerminalSettingsModel/GlobalAppSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,35 +62,35 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
void UnparsedDefaultProfile(const hstring& value);
void ClearUnparsedDefaultProfile();

GETSET_SETTING(Model::GlobalAppSettings, int32_t, InitialRows, DEFAULT_ROWS);
GETSET_SETTING(Model::GlobalAppSettings, int32_t, InitialCols, DEFAULT_COLS);
GETSET_SETTING(Model::GlobalAppSettings, bool, AlwaysShowTabs, true);
GETSET_SETTING(Model::GlobalAppSettings, bool, ShowTitleInTitlebar, true);
GETSET_SETTING(Model::GlobalAppSettings, bool, ConfirmCloseAllTabs, true);
GETSET_SETTING(Model::GlobalAppSettings, winrt::Windows::UI::Xaml::ElementTheme, Theme, winrt::Windows::UI::Xaml::ElementTheme::Default);
GETSET_SETTING(Model::GlobalAppSettings, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal);
GETSET_SETTING(Model::GlobalAppSettings, bool, ShowTabsInTitlebar, true);
GETSET_SETTING(Model::GlobalAppSettings, hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS);
GETSET_SETTING(Model::GlobalAppSettings, bool, CopyOnSelect, false);
GETSET_SETTING(Model::GlobalAppSettings, bool, InputServiceWarning, true);
GETSET_SETTING(Model::GlobalAppSettings, winrt::Microsoft::Terminal::TerminalControl::CopyFormat, CopyFormatting, 0);
GETSET_SETTING(Model::GlobalAppSettings, bool, WarnAboutLargePaste, true);
GETSET_SETTING(Model::GlobalAppSettings, bool, WarnAboutMultiLinePaste, true);
GETSET_SETTING(Model::GlobalAppSettings, Model::LaunchPosition, InitialPosition, nullptr, nullptr);
GETSET_SETTING(Model::GlobalAppSettings, bool, CenterOnLaunch, false);
GETSET_SETTING(Model::GlobalAppSettings, Model::LaunchMode, LaunchMode, LaunchMode::DefaultMode);
GETSET_SETTING(Model::GlobalAppSettings, bool, SnapToGridOnResize, true);
GETSET_SETTING(Model::GlobalAppSettings, bool, ForceFullRepaintRendering, false);
GETSET_SETTING(Model::GlobalAppSettings, bool, SoftwareRendering, false);
GETSET_SETTING(Model::GlobalAppSettings, bool, ForceVTInput, false);
GETSET_SETTING(Model::GlobalAppSettings, bool, DebugFeaturesEnabled, _getDefaultDebugFeaturesValue());
GETSET_SETTING(Model::GlobalAppSettings, bool, StartOnUserLogin, false);
GETSET_SETTING(Model::GlobalAppSettings, bool, AlwaysOnTop, false);
GETSET_SETTING(Model::GlobalAppSettings, Model::TabSwitcherMode, TabSwitcherMode, Model::TabSwitcherMode::InOrder);
GETSET_SETTING(Model::GlobalAppSettings, bool, DisableAnimations, false);
GETSET_SETTING(Model::GlobalAppSettings, hstring, StartupActions, L"");
GETSET_SETTING(Model::GlobalAppSettings, bool, FocusFollowMouse, false);
GETSET_SETTING(Model::GlobalAppSettings, Model::WindowingMode, WindowingBehavior, Model::WindowingMode::UseNew);
SETTING(Model::GlobalAppSettings, int32_t, InitialRows, DEFAULT_ROWS);
SETTING(Model::GlobalAppSettings, int32_t, InitialCols, DEFAULT_COLS);
SETTING(Model::GlobalAppSettings, bool, AlwaysShowTabs, true);
SETTING(Model::GlobalAppSettings, bool, ShowTitleInTitlebar, true);
SETTING(Model::GlobalAppSettings, bool, ConfirmCloseAllTabs, true);
SETTING(Model::GlobalAppSettings, winrt::Windows::UI::Xaml::ElementTheme, Theme, winrt::Windows::UI::Xaml::ElementTheme::Default);
SETTING(Model::GlobalAppSettings, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal);
SETTING(Model::GlobalAppSettings, bool, ShowTabsInTitlebar, true);
SETTING(Model::GlobalAppSettings, hstring, WordDelimiters, DEFAULT_WORD_DELIMITERS);
SETTING(Model::GlobalAppSettings, bool, CopyOnSelect, false);
SETTING(Model::GlobalAppSettings, bool, InputServiceWarning, true);
SETTING(Model::GlobalAppSettings, winrt::Microsoft::Terminal::TerminalControl::CopyFormat, CopyFormatting, 0);
SETTING(Model::GlobalAppSettings, bool, WarnAboutLargePaste, true);
SETTING(Model::GlobalAppSettings, bool, WarnAboutMultiLinePaste, true);
SETTING(Model::GlobalAppSettings, Model::LaunchPosition, InitialPosition, nullptr, nullptr);
SETTING(Model::GlobalAppSettings, bool, CenterOnLaunch, false);
SETTING(Model::GlobalAppSettings, Model::LaunchMode, LaunchMode, LaunchMode::DefaultMode);
SETTING(Model::GlobalAppSettings, bool, SnapToGridOnResize, true);
SETTING(Model::GlobalAppSettings, bool, ForceFullRepaintRendering, false);
SETTING(Model::GlobalAppSettings, bool, SoftwareRendering, false);
SETTING(Model::GlobalAppSettings, bool, ForceVTInput, false);
SETTING(Model::GlobalAppSettings, bool, DebugFeaturesEnabled, _getDefaultDebugFeaturesValue());
SETTING(Model::GlobalAppSettings, bool, StartOnUserLogin, false);
SETTING(Model::GlobalAppSettings, bool, AlwaysOnTop, false);
SETTING(Model::GlobalAppSettings, Model::TabSwitcherMode, TabSwitcherMode, Model::TabSwitcherMode::InOrder);
SETTING(Model::GlobalAppSettings, bool, DisableAnimations, false);
SETTING(Model::GlobalAppSettings, hstring, StartupActions, L"");
SETTING(Model::GlobalAppSettings, bool, FocusFollowMouse, false);
SETTING(Model::GlobalAppSettings, Model::WindowingMode, WindowingBehavior, Model::WindowingMode::UseNew);

private:
guid _defaultProfile;
Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/TerminalSettingsModel/IInheritable.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
// - Clear(): clear the user set value
// - the setting is saved as an optional, where nullopt means
// that we must inherit the value from our parent
#define GETSET_SETTING(projectedType, type, name, ...) \
#define SETTING(projectedType, type, name, ...) \
public: \
/* Returns true if the user explicitly set the value, false otherwise*/ \
bool Has##name() const \
Expand Down Expand Up @@ -182,7 +182,7 @@ private: \
// like Profile.Foreground (where null is interpreted
// as an acceptable value, rather than "inherit")
// "type" is exposed as an IReference
#define GETSET_NULLABLE_SETTING(projectedType, type, name, ...) \
#define NULLABLE_SETTING(projectedType, type, name, ...) \
public: \
/* Returns true if the user explicitly set the value, false otherwise*/ \
bool Has##name() const \
Expand Down
Loading