From ef84891df1f3df6d4aac75a8ea0ea909aae06efd Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 7 Nov 2024 17:52:23 +0800 Subject: [PATCH] feature: add new `Editor Font Size` configuration for all text editors (#661) Signed-off-by: leo --- src/Resources/Locales/en_US.axaml | 1 + src/Resources/Locales/zh_CN.axaml | 1 + src/Resources/Locales/zh_TW.axaml | 1 + src/ViewModels/Preference.cs | 7 +++++++ src/Views/Blame.axaml | 1 + src/Views/Preference.axaml | 22 +++++++++++++++++----- src/Views/RevisionFileContentViewer.axaml | 5 ++++- src/Views/TextDiffView.axaml | 3 +++ 8 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 8e905d6e..166ad3ab 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -435,6 +435,7 @@ APPEARANCE Default Font Default Font Size + Editor Font Size Monospace Font Only use monospace font in text editor Theme diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 4ecb5734..5632a3ef 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -438,6 +438,7 @@ 外观配置 缺省字体 默认字体大小 + 代码字体大小 等宽字体 仅在文本编辑器中使用等宽字体 主题 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 8d9f0325..229a5fdb 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -438,6 +438,7 @@ 外觀設定 預設字型 預設字型大小 + 程式碼字型大小 等寬字型 僅在文字編輯器中使用等寬字型 佈景主題 diff --git a/src/ViewModels/Preference.cs b/src/ViewModels/Preference.cs index efd31b72..68065df1 100644 --- a/src/ViewModels/Preference.cs +++ b/src/ViewModels/Preference.cs @@ -102,6 +102,12 @@ namespace SourceGit.ViewModels set => SetProperty(ref _defaultFontSize, value); } + public double EditorFontSize + { + get => _editorFontSize; + set => SetProperty(ref _editorFontSize, value); + } + public LayoutInfo Layout { get => _layout; @@ -579,6 +585,7 @@ namespace SourceGit.ViewModels private bool _onlyUseMonoFontInEditor = false; private bool _useSystemWindowFrame = false; private double _defaultFontSize = 13; + private double _editorFontSize = 13; private LayoutInfo _layout = new LayoutInfo(); private int _maxHistoryCommits = 20000; diff --git a/src/Views/Blame.axaml b/src/Views/Blame.axaml index 98e1c4f2..9d3afd77 100644 --- a/src/Views/Blame.axaml +++ b/src/Views/Blame.axaml @@ -57,6 +57,7 @@ Background="Transparent" Foreground="{DynamicResource Brush.FG1}" FontFamily="{DynamicResource Fonts.Monospace}" + FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=EditorFontSize}" BlameData="{Binding Data}"/> diff --git a/src/Views/Preference.axaml b/src/Views/Preference.axaml index 9cf47f9c..73be0f7c 100644 --- a/src/Views/Preference.axaml +++ b/src/Views/Preference.axaml @@ -121,7 +121,7 @@ - + + + + - @@ -184,16 +196,16 @@ - - - @@ -19,7 +20,9 @@ - + diff --git a/src/Views/TextDiffView.axaml b/src/Views/TextDiffView.axaml index 4ba8628e..57427321 100644 --- a/src/Views/TextDiffView.axaml +++ b/src/Views/TextDiffView.axaml @@ -23,6 +23,7 @@ DeletedHighlightBrush="{DynamicResource Brush.Diff.DeletedHighlight}" IndicatorForeground="{DynamicResource Brush.FG2}" FontFamily="{DynamicResource Fonts.Monospace}" + FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=EditorFontSize}" UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}" WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}" ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}" @@ -44,6 +45,7 @@ DeletedHighlightBrush="{DynamicResource Brush.Diff.DeletedHighlight}" IndicatorForeground="{DynamicResource Brush.FG2}" FontFamily="{DynamicResource Fonts.Monospace}" + FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=EditorFontSize}" UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}" WordWrap="False" ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}" @@ -64,6 +66,7 @@ DeletedHighlightBrush="{DynamicResource Brush.Diff.DeletedHighlight}" IndicatorForeground="{DynamicResource Brush.FG2}" FontFamily="{DynamicResource Fonts.Monospace}" + FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=EditorFontSize}" UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}" WordWrap="False" ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"