Skip to content

Commit ef84891

Browse files
committed
feature: add new Editor Font Size configuration for all text editors (#661)
Signed-off-by: leo <[email protected]>
1 parent ffeb636 commit ef84891

File tree

8 files changed

+35
-6
lines changed

8 files changed

+35
-6
lines changed

src/Resources/Locales/en_US.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@
435435
<x:String x:Key="Text.Preference.Appearance" xml:space="preserve">APPEARANCE</x:String>
436436
<x:String x:Key="Text.Preference.Appearance.DefaultFont" xml:space="preserve">Default Font</x:String>
437437
<x:String x:Key="Text.Preference.Appearance.DefaultFontSize" xml:space="preserve">Default Font Size</x:String>
438+
<x:String x:Key="Text.Preference.Appearance.EditorFontSize" xml:space="preserve">Editor Font Size</x:String>
438439
<x:String x:Key="Text.Preference.Appearance.MonospaceFont" xml:space="preserve">Monospace Font</x:String>
439440
<x:String x:Key="Text.Preference.Appearance.OnlyUseMonoFontInEditor" xml:space="preserve">Only use monospace font in text editor</x:String>
440441
<x:String x:Key="Text.Preference.Appearance.Theme" xml:space="preserve">Theme</x:String>

src/Resources/Locales/zh_CN.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@
438438
<x:String x:Key="Text.Preference.Appearance" xml:space="preserve">外观配置</x:String>
439439
<x:String x:Key="Text.Preference.Appearance.DefaultFont" xml:space="preserve">缺省字体</x:String>
440440
<x:String x:Key="Text.Preference.Appearance.DefaultFontSize" xml:space="preserve">默认字体大小</x:String>
441+
<x:String x:Key="Text.Preference.Appearance.EditorFontSize" xml:space="preserve">代码字体大小</x:String>
441442
<x:String x:Key="Text.Preference.Appearance.MonospaceFont" xml:space="preserve">等宽字体</x:String>
442443
<x:String x:Key="Text.Preference.Appearance.OnlyUseMonoFontInEditor" xml:space="preserve">仅在文本编辑器中使用等宽字体</x:String>
443444
<x:String x:Key="Text.Preference.Appearance.Theme" xml:space="preserve">主题</x:String>

src/Resources/Locales/zh_TW.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@
438438
<x:String x:Key="Text.Preference.Appearance" xml:space="preserve">外觀設定</x:String>
439439
<x:String x:Key="Text.Preference.Appearance.DefaultFont" xml:space="preserve">預設字型</x:String>
440440
<x:String x:Key="Text.Preference.Appearance.DefaultFontSize" xml:space="preserve">預設字型大小</x:String>
441+
<x:String x:Key="Text.Preference.Appearance.EditorFontSize" xml:space="preserve">程式碼字型大小</x:String>
441442
<x:String x:Key="Text.Preference.Appearance.MonospaceFont" xml:space="preserve">等寬字型</x:String>
442443
<x:String x:Key="Text.Preference.Appearance.OnlyUseMonoFontInEditor" xml:space="preserve">僅在文字編輯器中使用等寬字型</x:String>
443444
<x:String x:Key="Text.Preference.Appearance.Theme" xml:space="preserve">佈景主題</x:String>

src/ViewModels/Preference.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ public double DefaultFontSize
102102
set => SetProperty(ref _defaultFontSize, value);
103103
}
104104

105+
public double EditorFontSize
106+
{
107+
get => _editorFontSize;
108+
set => SetProperty(ref _editorFontSize, value);
109+
}
110+
105111
public LayoutInfo Layout
106112
{
107113
get => _layout;
@@ -579,6 +585,7 @@ private bool RemoveInvalidRepositoriesRecursive(List<RepositoryNode> collection)
579585
private bool _onlyUseMonoFontInEditor = false;
580586
private bool _useSystemWindowFrame = false;
581587
private double _defaultFontSize = 13;
588+
private double _editorFontSize = 13;
582589
private LayoutInfo _layout = new LayoutInfo();
583590

584591
private int _maxHistoryCommits = 20000;

src/Views/Blame.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
Background="Transparent"
5858
Foreground="{DynamicResource Brush.FG1}"
5959
FontFamily="{DynamicResource Fonts.Monospace}"
60+
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=EditorFontSize}"
6061
BlameData="{Binding Data}"/>
6162

6263
<!-- Not supported mask (for binary files) -->

src/Views/Preference.axaml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
<TabItem.Header>
122122
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Preference.Appearance}"/>
123123
</TabItem.Header>
124-
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32,Auto" ColumnDefinitions="Auto,*">
124+
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32,32,Auto" ColumnDefinitions="Auto,*">
125125
<TextBlock Grid.Row="0" Grid.Column="0"
126126
Text="{DynamicResource Text.Preference.Appearance.Theme}"
127127
HorizontalAlignment="Right"
@@ -170,10 +170,22 @@
170170
Value="{Binding DefaultFontSize, Mode=TwoWay}"/>
171171

172172
<TextBlock Grid.Row="4" Grid.Column="0"
173+
Text="{DynamicResource Text.Preference.Appearance.EditorFontSize}"
174+
HorizontalAlignment="Right"
175+
Margin="0,0,16,0"/>
176+
<NumericUpDown Grid.Row="4" Grid.Column="1"
177+
Minimum="10" Maximum="18" Increment="0.5"
178+
Height="28"
179+
Padding="4"
180+
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
181+
CornerRadius="3"
182+
Value="{Binding EditorFontSize, Mode=TwoWay}"/>
183+
184+
<TextBlock Grid.Row="5" Grid.Column="0"
173185
Text="{DynamicResource Text.Preference.Appearance.ThemeOverrides}"
174186
HorizontalAlignment="Right"
175187
Margin="0,0,16,0"/>
176-
<TextBox Grid.Row="4" Grid.Column="1"
188+
<TextBox Grid.Row="5" Grid.Column="1"
177189
Height="28"
178190
CornerRadius="3"
179191
Text="{Binding ThemeOverrides, Mode=TwoWay}">
@@ -184,16 +196,16 @@
184196
</TextBox.InnerRightContent>
185197
</TextBox>
186198

187-
<CheckBox Grid.Row="5" Grid.Column="1"
199+
<CheckBox Grid.Row="6" Grid.Column="1"
188200
Content="{DynamicResource Text.Preference.Appearance.OnlyUseMonoFontInEditor}"
189201
IsChecked="{Binding OnlyUseMonoFontInEditor, Mode=TwoWay}"/>
190202

191-
<CheckBox Grid.Row="6" Grid.Column="1"
203+
<CheckBox Grid.Row="7" Grid.Column="1"
192204
Height="32"
193205
Content="{DynamicResource Text.Preference.Appearance.UseFixedTabWidth}"
194206
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseFixedTabWidth, Mode=TwoWay}"/>
195207

196-
<CheckBox Grid.Row="7" Grid.Column="1"
208+
<CheckBox Grid.Row="8" Grid.Column="1"
197209
Height="32"
198210
Content="{DynamicResource Text.Preference.Appearance.UseNativeWindowFrame}"
199211
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSystemWindowFrame, Mode=OneTime}"

src/Views/RevisionFileContentViewer.axaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:m="using:SourceGit.Models"
66
xmlns:v="using:SourceGit.Views"
7+
xmlns:vm="using:SourceGit.ViewModels"
78
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
89
x:Class="SourceGit.Views.RevisionFileContentViewer">
910
<UserControl.DataTemplates>
@@ -19,7 +20,9 @@
1920
</DataTemplate>
2021

2122
<DataTemplate DataType="m:RevisionTextFile">
22-
<v:RevisionTextFileView FontFamily="{DynamicResource Fonts.Monospace}" Background="{DynamicResource Brush.Contents}"/>
23+
<v:RevisionTextFileView FontFamily="{DynamicResource Fonts.Monospace}"
24+
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=EditorFontSize}"
25+
Background="{DynamicResource Brush.Contents}"/>
2326
</DataTemplate>
2427

2528
<DataTemplate DataType="m:RevisionImageFile">

src/Views/TextDiffView.axaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
DeletedHighlightBrush="{DynamicResource Brush.Diff.DeletedHighlight}"
2424
IndicatorForeground="{DynamicResource Brush.FG2}"
2525
FontFamily="{DynamicResource Fonts.Monospace}"
26+
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=EditorFontSize}"
2627
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
2728
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
2829
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
@@ -44,6 +45,7 @@
4445
DeletedHighlightBrush="{DynamicResource Brush.Diff.DeletedHighlight}"
4546
IndicatorForeground="{DynamicResource Brush.FG2}"
4647
FontFamily="{DynamicResource Fonts.Monospace}"
48+
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=EditorFontSize}"
4749
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
4850
WordWrap="False"
4951
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
@@ -64,6 +66,7 @@
6466
DeletedHighlightBrush="{DynamicResource Brush.Diff.DeletedHighlight}"
6567
IndicatorForeground="{DynamicResource Brush.FG2}"
6668
FontFamily="{DynamicResource Fonts.Monospace}"
69+
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=EditorFontSize}"
6770
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
6871
WordWrap="False"
6972
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"

0 commit comments

Comments
 (0)