Skip to content

Commit

Permalink
discard changes fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
PankajBhojwani committed Oct 5, 2023
1 parent 5a64ea5 commit 267a6c9
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 22 deletions.
46 changes: 35 additions & 11 deletions src/cascadia/TerminalSettingsEditor/Appearances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,34 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
LightColorSchemeName(val.Name());
}

void AppearanceViewModel::AddNewAxisKeyValuePair()
{
if (!_appearance.SourceProfile().FontInfo().FontAxes())
{
_appearance.SourceProfile().FontInfo().FontAxes(winrt::single_threaded_map<winrt::hstring, float>());
}
auto fontAxesMap = _appearance.SourceProfile().FontInfo().FontAxes();

// We use "<>" as a 'dummy' value for the key because if we instead just have an empty string,
// the user might click 'add new' and immediately hit 'save settings' which will cause a crash
// because we try to write a map entry that has an empty string as the key.
FontAxesVector().Append(winrt::make<winrt::Microsoft::Terminal::Settings::Editor::implementation::AxisKeyValuePair>(L"<>", (float)0, fontAxesMap));
fontAxesMap.Insert(L"<>", (float)0);
}

void AppearanceViewModel::DeleteAxisKeyValuePair(winrt::hstring key)
{
for (uint32_t i = 0; i < _FontAxesVector.Size(); i++)
{
if (_FontAxesVector.GetAt(i).AxisKey() == key)
{
_FontAxesVector.RemoveAt(i);
_appearance.SourceProfile().FontInfo().FontAxes().Remove(key);
break;
}
}
}

DependencyProperty Appearances::_AppearanceProperty{ nullptr };

Appearances::Appearances() :
Expand Down Expand Up @@ -482,26 +510,22 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
}

void Appearances::AxisKeyValuePairDelete_Click(const IInspectable& sender, const RoutedEventArgs& /*e*/)
void Appearances::DeleteAxisKeyValuePair_Click(const IInspectable& sender, const RoutedEventArgs& /*e*/)
{
if (const auto& button{ sender.try_as<Controls::Button>() })
{
if (const auto& tag{ button.Tag().try_as<winrt::hstring>() })
{
for (const auto axisKeyValuePair : Appearance().FontAxesVector())
{
if (axisKeyValuePair.as<Editor::AxisKeyValuePair>().AxisKey() == tag)
{
uint32_t index;
Appearance().FontAxesVector().IndexOf(axisKeyValuePair, index);
Appearance().FontAxesVector().RemoveAt(index);
break;
}
}
Appearance().DeleteAxisKeyValuePair(tag.value());
}
}
}

void Appearances::AddNewAxisKeyValuePair_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/)
{
Appearance().AddNewAxisKeyValuePair();
}

bool Appearances::IsVintageCursor() const
{
return Appearance().CursorShape() == Core::CursorStyle::Vintage;
Expand Down
6 changes: 5 additions & 1 deletion src/cascadia/TerminalSettingsEditor/Appearances.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
Editor::ColorSchemeViewModel CurrentColorScheme();
void CurrentColorScheme(const Editor::ColorSchemeViewModel& val);

void AddNewAxisKeyValuePair();
void DeleteAxisKeyValuePair(winrt::hstring key);

WINRT_PROPERTY(bool, IsDefault, false);

// These settings are not defined in AppearanceConfig, so we grab them
Expand Down Expand Up @@ -154,7 +157,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
fire_and_forget BackgroundImage_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
void BIAlignment_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
void FontFace_SelectionChanged(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::Controls::SelectionChangedEventArgs& e);
void AxisKeyValuePairDelete_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
void DeleteAxisKeyValuePair_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
void AddNewAxisKeyValuePair_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);

// manually bind FontWeight
Windows::Foundation::IInspectable CurrentFontWeight() const;
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsEditor/Appearances.idl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ namespace Microsoft.Terminal.Settings.Editor
ColorSchemeViewModel CurrentColorScheme;
Windows.Foundation.Collections.IObservableVector<ColorSchemeViewModel> SchemesList;

void AddNewAxisKeyValuePair();
void DeleteAxisKeyValuePair(String key);
Windows.Foundation.Collections.IObservableVector<AxisKeyValuePair> FontAxesVector;

OBSERVABLE_PROJECTED_APPEARANCE_SETTING(String, FontFace);
Expand Down
49 changes: 39 additions & 10 deletions src/cascadia/TerminalSettingsEditor/Appearances.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,47 @@

<local:SettingContainer x:Uid="Profile_FontAxes"
Style="{StaticResource ExpanderSettingContainerStyle}">
<ListView ItemsSource="{Binding Source={StaticResource FontAxesCVS}}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:AxisKeyValuePair">
<StackPanel Spacing="16">
<ListView ItemsSource="{Binding Source={StaticResource FontAxesCVS}}"

Check failure on line 295 in src/cascadia/TerminalSettingsEditor/Appearances.xaml

View workflow job for this annotation

GitHub Actions / Spell checking

`CVS` is not a recognized word. (unrecognized-spelling)

Check failure on line 295 in src/cascadia/TerminalSettingsEditor/Appearances.xaml

View workflow job for this annotation

GitHub Actions / Spell checking

`CVS` is not a recognized word. (unrecognized-spelling)
IsItemClickEnabled="False"
SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:AxisKeyValuePair">
<Grid Margin="-16,0,-12,0"
ColumnSpacing="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBox Text="{x:Bind AxisKey, Mode=TwoWay}"
Grid.Column="0"/>
<muxc:NumberBox Value="{x:Bind AxisValue, Mode=TwoWay}"
Grid.Column="1"/>
<Button Click="DeleteAxisKeyValuePair_Click"
HorizontalAlignment="Right"
Style="{StaticResource DeleteButtonStyle}"
Tag="{x:Bind AxisKey}"
Grid.Column="2">
<FontIcon FontSize="{StaticResource StandardIconSize}"
Glyph="&#xE74D;" />
</Button>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button Click="AddNewAxisKeyValuePair_Click">
<Button.Content>
<StackPanel Orientation="Horizontal">
<TextBox Text="{x:Bind AxisKey, Mode=TwoWay}" />
<muxc:NumberBox Value="{x:Bind AxisValue, Mode=TwoWay}" />
<Button Click="AxisKeyValuePairDelete_Click"
Tag="{x:Bind AxisKey}" />
<FontIcon FontSize="{StaticResource StandardIconSize}"
VerticalAlignment="Bottom"
Glyph="&#xE710;" />
<TextBlock x:Uid="Profile_AddNewFontAxis"
Style="{StaticResource IconButtonTextBlockStyle}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Button.Content>
</Button>
</StackPanel>
</local:SettingContainer>

<!-- Retro Terminal Effect -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,10 @@
<value>Browse...</value>
<comment>Button label that opens a file picker in a new window. The "..." is standard to mean it will open a new window.</comment>
</data>
<data name="Profile_AddNewFontAxis.Text" xml:space="preserve">
<value>Add new</value>
<comment>Button label that adds a new font axis for the current font.</comment>
</data>
<data name="Profile_BackgroundImageOpacitySlider.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Background image opacity</value>
<comment>Name for a control to choose the opacity of the image presented on the background of the app.</comment>
Expand Down
11 changes: 11 additions & 0 deletions src/cascadia/TerminalSettingsModel/FontConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ winrt::com_ptr<FontConfig> FontConfig::CopyFontInfo(const FontConfig* source, wi
MTSM_FONT_SETTINGS(FONT_SETTINGS_COPY)
#undef FONT_SETTINGS_COPY

// We cannot simply copy the font axes and features with `fontInfo->_FontAxes = source->_FontAxes;`
// since that'll just create a reference; we have to manually copy the values.
if (source->_FontAxes)
{
fontInfo->_FontAxes = winrt::single_threaded_map<winrt::hstring, float>();
for (const auto kVPair : source->_FontAxes.value())

Check failure on line 38 in src/cascadia/TerminalSettingsModel/FontConfig.cpp

View workflow job for this annotation

GitHub Actions / Spell checking

`VPair` is not a recognized word. (unrecognized-spelling)

Check failure on line 38 in src/cascadia/TerminalSettingsModel/FontConfig.cpp

View workflow job for this annotation

GitHub Actions / Spell checking

`VPair` is not a recognized word. (unrecognized-spelling)
{
fontInfo->_FontAxes.value().Insert(kVPair.Key(), kVPair.Value());

Check failure on line 40 in src/cascadia/TerminalSettingsModel/FontConfig.cpp

View workflow job for this annotation

GitHub Actions / Spell checking

`VPair` is not a recognized word. (unrecognized-spelling)

Check failure on line 40 in src/cascadia/TerminalSettingsModel/FontConfig.cpp

View workflow job for this annotation

GitHub Actions / Spell checking

`VPair` is not a recognized word. (unrecognized-spelling)

Check failure on line 40 in src/cascadia/TerminalSettingsModel/FontConfig.cpp

View workflow job for this annotation

GitHub Actions / Spell checking

`VPair` is not a recognized word. (unrecognized-spelling)

Check failure on line 40 in src/cascadia/TerminalSettingsModel/FontConfig.cpp

View workflow job for this annotation

GitHub Actions / Spell checking

`VPair` is not a recognized word. (unrecognized-spelling)
}
}

return fontInfo;
}

Expand Down

1 comment on commit 267a6c9

@github-actions
Copy link

Choose a reason for hiding this comment

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

@check-spelling-bot Report

🔴 Please review

See the 📜action log for details.

Unrecognized words (3)

CVS
iinspectable
VPair

Previously acknowledged words that are now absent testtimeout :arrow_right:
To accept ✔️ these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the git@github.com:microsoft/terminal.git repository
on the dev/pabhoj/sui_font_parity branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.21/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/6422241447/attempts/1'
Pattern suggestions ✂️ (1)

You could add these patterns to .github/actions/spelling/patterns/267a6c9ad610f316d2bec15df69c509ad58fe65a.txt:

# Automatically suggested patterns
# hit-count: 1 file-count: 1
# tput arguments -- https://man7.org/linux/man-pages/man5/terminfo.5.html -- technically they can be more than 5 chars long...
\btput\s+(?:(?:-[SV]|-T\s*\w+)\s+)*\w{3,5}\b

Warnings (1)

See the 📜action log for details.

ℹ️ Warnings Count
ℹ️ candidate-pattern 1

See ℹ️ Event descriptions for more information.

✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

⚠️ The command is written for posix shells. If it doesn't work for you, you can manually add (one word per line) / remove items to expect.txt and the excludes.txt files.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.