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

Add miscellaneous simple settings to the settings UI #17923

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
81 changes: 58 additions & 23 deletions src/cascadia/TerminalSettingsEditor/Appearances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
}

double AppearanceViewModel::LineHeight() const
double AppearanceViewModel::_extractCellSizeValue(const hstring val) const
{
const auto fontInfo = _appearance.SourceProfile().FontInfo();
const auto cellHeight = fontInfo.CellHeight();
const auto str = cellHeight.c_str();
const auto str = val.c_str();

auto& errnoRef = errno; // Nonzero cost, pay it once.
errnoRef = 0;
Expand All @@ -588,29 +586,49 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
return str == end || errnoRef == ERANGE ? NAN : value;
}

void AppearanceViewModel::LineHeight(const double value)
double AppearanceViewModel::LineHeight() const
{
std::wstring str;
const auto cellHeight = _appearance.SourceProfile().FontInfo().CellHeight();
return _extractCellSizeValue(cellHeight);
}

if (value >= 0.1 && value <= 10.0)
{
str = fmt::format(FMT_STRING(L"{:.6g}"), value);
}
double AppearanceViewModel::CellWidth() const
{
const auto cellWidth = _appearance.SourceProfile().FontInfo().CellHeight();
return _extractCellSizeValue(cellWidth);
}

const auto fontInfo = _appearance.SourceProfile().FontInfo();
#define CELL_SIZE_SETTER(modelName, viewModelName) \
std::wstring str; \
\
if (value >= 0.1 && value <= 10.0) \
{ \
str = fmt::format(FMT_STRING(L"{:.6g}"), value); \
} \
\
const auto fontInfo = _appearance.SourceProfile().FontInfo(); \
\
if (fontInfo.modelName() != str) \
{ \
if (str.empty()) \
{ \
fontInfo.Clear##modelName(); \
} \
else \
{ \
fontInfo.modelName(str); \
} \
_NotifyChanges(L"Has" #viewModelName, L## #viewModelName); \
}

if (fontInfo.CellHeight() != str)
{
if (str.empty())
{
fontInfo.ClearCellHeight();
}
else
{
fontInfo.CellHeight(str);
}
_NotifyChanges(L"HasLineHeight", L"LineHeight");
}
void AppearanceViewModel::LineHeight(const double value)
{
CELL_SIZE_SETTER(CellHeight, LineHeight);
}

void AppearanceViewModel::CellWidth(const double value)
{
CELL_SIZE_SETTER(CellWidth, CellWidth);
}

bool AppearanceViewModel::HasLineHeight() const
Expand All @@ -619,17 +637,34 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
return fontInfo.HasCellHeight();
}

bool AppearanceViewModel::HasCellWidth() const
{
const auto fontInfo = _appearance.SourceProfile().FontInfo();
return fontInfo.HasCellWidth();
}

void AppearanceViewModel::ClearLineHeight()
{
LineHeight(NAN);
}

void AppearanceViewModel::ClearCellWidth()
{
CellWidth(NAN);
}

Model::FontConfig AppearanceViewModel::LineHeightOverrideSource() const
{
const auto fontInfo = _appearance.SourceProfile().FontInfo();
return fontInfo.CellHeightOverrideSource();
}

Model::FontConfig AppearanceViewModel::CellWidthOverrideSource() const
{
const auto fontInfo = _appearance.SourceProfile().FontInfo();
return fontInfo.CellWidthOverrideSource();
}

void AppearanceViewModel::SetFontWeightFromDouble(double fontWeight)
{
FontWeight(winrt::Microsoft::Terminal::UI::Converters::DoubleToFontWeight(fontWeight));
Expand Down
8 changes: 8 additions & 0 deletions src/cascadia/TerminalSettingsEditor/Appearances.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void ClearLineHeight();
Model::FontConfig LineHeightOverrideSource() const;

double CellWidth() const;
void CellWidth(const double value);
bool HasCellWidth() const;
void ClearCellWidth();
Model::FontConfig CellWidthOverrideSource() const;

void SetFontWeightFromDouble(double fontWeight);

const FontFaceDependentsData& FontFaceDependents();
Expand Down Expand Up @@ -161,6 +167,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void _deleteAllFontKeyValuePairs(FontSettingIndex index);
void _addMenuFlyoutItemToUnused(FontSettingIndex index, Windows::UI::Xaml::Controls::MenuFlyoutItemBase item);

double _extractCellSizeValue(const hstring val) const;

Model::AppearanceConfig _appearance;
winrt::hstring _lastBgImagePath;
std::optional<FontFaceDependentsData> _fontFaceDependents;
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/Appearances.idl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace Microsoft.Terminal.Settings.Editor
OBSERVABLE_PROJECTED_APPEARANCE_SETTING(String, FontFace);
OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Single, FontSize);
OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Double, LineHeight);
OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Double, CellWidth);
OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Windows.UI.Text.FontWeight, FontWeight);
OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Boolean, EnableBuiltinGlyphs);
OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Boolean, EnableColorGlyphs);
Expand Down
16 changes: 16 additions & 0 deletions src/cascadia/TerminalSettingsEditor/Appearances.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,22 @@
Value="{x:Bind Appearance.LineHeight, Mode=TwoWay}" />
</local:SettingContainer>

<!-- Cell Width -->
<local:SettingContainer x:Uid="Profile_CellWidth"
ClearSettingValue="{x:Bind Appearance.ClearCellWidth}"
HasSettingValue="{x:Bind Appearance.HasCellWidth, Mode=OneWay}"
SettingOverrideSource="{x:Bind Appearance.CellWidthOverrideSource, Mode=OneWay}"
Visibility="{x:Bind Appearance.IsDefault, Mode=OneWay}">
<muxc:NumberBox x:Name="_cellWidthBox"
x:Uid="Profile_CellWidthBox"
LargeChange="0.1"
Maximum="10"
Minimum="0.1"
SmallChange="0.1"
Style="{StaticResource NumberBoxSettingStyle}"
Value="{x:Bind Appearance.CellWidth, Mode=TwoWay}" />
</local:SettingContainer>

<!-- Font Weight -->
<local:SettingContainer x:Uid="Profile_FontWeight"
ClearSettingValue="{x:Bind Appearance.ClearFontWeight}"
Expand Down
12 changes: 12 additions & 0 deletions src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,17 @@
<ToggleSwitch IsOn="{x:Bind ViewModel.AutoHideWindow, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>

<!-- Show Admin Shield -->
<local:SettingContainer x:Uid="Globals_ShowAdminShield">
<ToggleSwitch IsOn="{x:Bind ViewModel.ShowAdminShield, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>

<!-- Enable Unfocused Acrylic -->
<local:SettingContainer x:Uid="Globals_EnableUnfocusedAcrylic">
<ToggleSwitch IsOn="{x:Bind ViewModel.EnableUnfocusedAcrylic, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>
Comment on lines +139 to +143
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed that this setting is compatibility.enableUnfocusedAcrylic. Any ideas why it's in the compatibility namespace? To me, it makes sense to have in the appearance page, but the compatibility namespace is making me second guess that it should be in the new compatibility page. Should we remove the compatibility prefix?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was more "OS compatibility" - unfocused acrylic is actually a different implementation of acrylic than usual. It has caused some issues in the past.

</StackPanel>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, AutoHideWindow);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, AlwaysShowNotificationIcon);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, MinimizeToNotificationArea);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ShowAdminShield);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, EnableUnfocusedAcrylic);

private:
Model::GlobalAppSettings _GlobalSettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ namespace Microsoft.Terminal.Settings.Editor
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, AutoHideWindow);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, AlwaysShowNotificationIcon);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, MinimizeToNotificationArea);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ShowAdminShield);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, EnableUnfocusedAcrylic);
}
}
16 changes: 16 additions & 0 deletions src/cascadia/TerminalSettingsEditor/Interaction.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,25 @@
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>

<!-- Search Web Default Query URL -->
<local:SettingContainer x:Uid="Globals_SearchWebDefaultQueryUrl"
CurrentValue="{x:Bind ViewModel.SearchWebDefaultQueryUrl, Mode=OneWay}"
Style="{StaticResource ExpanderSettingContainerStyle}">
<TextBox IsSpellCheckEnabled="False"
Style="{StaticResource TextBoxSettingStyle}"
Text="{x:Bind ViewModel.SearchWebDefaultQueryUrl, Mode=TwoWay}" />
</local:SettingContainer>

<!-- Confirm Close All Tabs -->
<local:SettingContainer x:Uid="Globals_ConfirmCloseAllTabs">
<ToggleSwitch IsOn="{x:Bind ViewModel.ConfirmCloseAllTabs, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>

<!-- Enable Color Selection -->
<local:SettingContainer x:Uid="Globals_EnableColorSelection">
<ToggleSwitch IsOn="{x:Bind ViewModel.EnableColorSelection, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>
</StackPanel>
</Page>
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsEditor/InteractionViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, SnapToGridOnResize);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, FocusFollowMouse);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, DetectURLs);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, SearchWebDefaultQueryUrl);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, WordDelimiters);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ConfirmCloseAllTabs);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, EnableColorSelection);

private:
Model::GlobalAppSettings _GlobalSettings;
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsEditor/InteractionViewModel.idl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ namespace Microsoft.Terminal.Settings.Editor
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, SnapToGridOnResize);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, FocusFollowMouse);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, DetectURLs);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(String, SearchWebDefaultQueryUrl);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(String, WordDelimiters);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ConfirmCloseAllTabs);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, EnableColorSelection);
}
}
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsEditor/ProfileViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
OBSERVABLE_PROJECTED_SETTING(_profile, ShowMarks);
OBSERVABLE_PROJECTED_SETTING(_profile, AutoMarkPrompts);
OBSERVABLE_PROJECTED_SETTING(_profile, RepositionCursorWithMouse);
OBSERVABLE_PROJECTED_SETTING(_profile, RainbowSuggestions);
OBSERVABLE_PROJECTED_SETTING(_profile, AnswerbackMessage);

WINRT_PROPERTY(bool, IsBaseLayer, false);
WINRT_PROPERTY(bool, FocusDeleteButton, false);
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,7 @@ namespace Microsoft.Terminal.Settings.Editor
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, ShowMarks);
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AutoMarkPrompts);
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, RepositionCursorWithMouse);
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, RainbowSuggestions);
OBSERVABLE_PROJECTED_PROFILE_SETTING(String, AnswerbackMessage);
}
}
19 changes: 19 additions & 0 deletions src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,25 @@
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>

<!-- RainbowSuggestions -->
<local:SettingContainer x:Uid="Profile_RainbowSuggestions"
ClearSettingValue="{x:Bind Profile.ClearRainbowSuggestions}"
HasSettingValue="{x:Bind Profile.HasRainbowSuggestions, Mode=OneWay}"
SettingOverrideSource="{x:Bind Profile.RainbowSuggestionsOverrideSource, Mode=OneWay}">
<ToggleSwitch IsOn="{x:Bind Profile.RainbowSuggestions, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>

<!-- Answerback Message -->
<local:SettingContainer x:Uid="Profile_AnswerbackMessage"
ClearSettingValue="{x:Bind Profile.ClearAnswerbackMessage}"
CurrentValue="{x:Bind Profile.AnswerbackMessage, Mode=OneWay}"
HasSettingValue="{x:Bind Profile.HasAnswerbackMessage, Mode=OneWay}"
SettingOverrideSource="{x:Bind Profile.AnswerbackMessageOverrideSource, Mode=OneWay}"
Style="{StaticResource ExpanderSettingContainerStyle}">
<TextBox Style="{StaticResource TextBoxSettingStyle}"
Text="{x:Bind Profile.AnswerbackMessage, Mode=TwoWay}" />
</local:SettingContainer>
</StackPanel>
</Grid>
</Page>
Loading
Loading