[Monaco]Add option to set font size (#32559)

* Add setting to enable/disable it and add Peek support

* Add ability to set font size
This commit is contained in:
Aaron Junker-Wildi
2024-04-24 14:17:29 +02:00
committed by GitHub
parent 5b4da37a43
commit d9008186cf
14 changed files with 109 additions and 4 deletions

View File

@@ -397,6 +397,8 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco
_html = _html.Replace("[[PT_LANG]]", _vsCodeLangSet, StringComparison.InvariantCulture);
_html = _html.Replace("[[PT_WRAP]]", _settings.Wrap ? "1" : "0", StringComparison.InvariantCulture);
_html = _html.Replace("[[PT_THEME]]", Settings.GetTheme(), StringComparison.InvariantCulture);
_html = _html.Replace("[[PT_STICKY_SCROLL]]", _settings.StickyScroll ? "1" : "0", StringComparison.InvariantCulture);
_html = _html.Replace("[[PT_FONT_SIZE]]", _settings.FontSize.ToString(CultureInfo.InvariantCulture), StringComparison.InvariantCulture);
_html = _html.Replace("[[PT_CODE]]", _base64FileCode, StringComparison.InvariantCulture);
_html = _html.Replace("[[PT_STICKY_SCROLL]]", _settings.StickyScroll ? "1" : "0", StringComparison.InvariantCulture);
_html = _html.Replace("[[PT_URL]]", FilePreviewCommon.MonacoHelper.VirtualHostName, StringComparison.InvariantCulture);

View File

@@ -77,6 +77,26 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco
}
}
/// <summary>
/// Gets the font size for the previewer. Set by PT settings.
/// </summary>
public double FontSize
{
get
{
try
{
return moduleSettings.GetSettings<PowerPreviewSettings>(PowerPreviewSettings.ModuleName).Properties.MonacoPreviewFontSize.Value;
}
catch (FileNotFoundException)
{
// Couldn't read the settings.
// Assume default of 14.
return 14;
}
}
}
/// <summary>
/// Gets a value indicating whether sticky scroll should be enabled. Set by PT settings.
/// </summary>