diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml
index 5208a269..5df3ca71 100644
--- a/src/Resources/Locales/en_US.axaml
+++ b/src/Resources/Locales/en_US.axaml
@@ -464,6 +464,7 @@
Enable Streaming
APPEARANCE
Default Font
+ Editor Tab Width
Font Size
Default
Editor
diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml
index 0e8b9f7d..72b434f9 100644
--- a/src/Resources/Locales/zh_CN.axaml
+++ b/src/Resources/Locales/zh_CN.axaml
@@ -467,6 +467,7 @@
启用流式输出
外观配置
缺省字体
+ 编辑器制表符宽度
字体大小
默认
代码编辑器
diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml
index f4cfad08..bc9991f6 100644
--- a/src/Resources/Locales/zh_TW.axaml
+++ b/src/Resources/Locales/zh_TW.axaml
@@ -467,6 +467,7 @@
啟用串流輸出
外觀設定
預設字型
+ 編輯器制表符寬度
字型大小
預設
程式碼
diff --git a/src/ViewModels/Preferences.cs b/src/ViewModels/Preferences.cs
index 5cd7c8a4..016fd4c4 100644
--- a/src/ViewModels/Preferences.cs
+++ b/src/ViewModels/Preferences.cs
@@ -111,6 +111,12 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _editorFontSize, value);
}
+ public int EditorTabWidth
+ {
+ get => _editorTabWidth;
+ set => SetProperty(ref _editorTabWidth, value);
+ }
+
public LayoutInfo Layout
{
get => _layout;
@@ -649,6 +655,7 @@ namespace SourceGit.ViewModels
private bool _useSystemWindowFrame = false;
private double _defaultFontSize = 13;
private double _editorFontSize = 13;
+ private int _editorTabWidth = 4;
private LayoutInfo _layout = new LayoutInfo();
private int _maxHistoryCommits = 20000;
diff --git a/src/Views/Blame.axaml b/src/Views/Blame.axaml
index 1ddb18fb..b700b580 100644
--- a/src/Views/Blame.axaml
+++ b/src/Views/Blame.axaml
@@ -58,6 +58,7 @@
Foreground="{DynamicResource Brush.FG1}"
FontFamily="{DynamicResource Fonts.Monospace}"
FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorFontSize}"
+ TabWidth="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorTabWidth}"
BlameData="{Binding Data}"/>
diff --git a/src/Views/Blame.axaml.cs b/src/Views/Blame.axaml.cs
index 1784efc1..7e273998 100644
--- a/src/Views/Blame.axaml.cs
+++ b/src/Views/Blame.axaml.cs
@@ -260,6 +260,15 @@ namespace SourceGit.Views
set => SetValue(BlameDataProperty, value);
}
+ public static readonly StyledProperty TabWidthProperty =
+ AvaloniaProperty.Register(nameof(TabWidth), 4);
+
+ public int TabWidth
+ {
+ get => GetValue(TabWidthProperty);
+ set => SetValue(TabWidthProperty, value);
+ }
+
protected override Type StyleKeyOverride => typeof(TextEditor);
public BlameTextEditor() : base(new TextArea(), new TextDocument())
@@ -268,6 +277,10 @@ namespace SourceGit.Views
ShowLineNumbers = false;
WordWrap = false;
+ Options.IndentationSize = TabWidth;
+ Options.EnableHyperlinks = false;
+ Options.EnableEmailHyperlinks = false;
+
_textMate = Models.TextMateHelper.CreateForEditor(this);
TextArea.LeftMargins.Add(new LineNumberMargin() { Margin = new Thickness(8, 0) });
@@ -280,8 +293,6 @@ namespace SourceGit.Views
TextArea.TextView.ContextRequested += OnTextViewContextRequested;
TextArea.TextView.VisualLinesChanged += OnTextViewVisualLinesChanged;
TextArea.TextView.Margin = new Thickness(4, 0);
- TextArea.TextView.Options.EnableHyperlinks = false;
- TextArea.TextView.Options.EnableEmailHyperlinks = false;
}
public override void Render(DrawingContext context)
@@ -350,6 +361,10 @@ namespace SourceGit.Views
Text = string.Empty;
}
}
+ else if (change.Property == TabWidthProperty)
+ {
+ Options.IndentationSize = TabWidth;
+ }
else if (change.Property.Name == "ActualThemeVariant" && change.NewValue != null)
{
Models.TextMateHelper.SetThemeByApp(_textMate);
diff --git a/src/Views/Preferences.axaml b/src/Views/Preferences.axaml
index 3bdd150a..12679e50 100644
--- a/src/Views/Preferences.axaml
+++ b/src/Views/Preferences.axaml
@@ -148,7 +148,7 @@
-
+
+ Minimum="10" Maximum="18" Increment="0.5"
+ Height="28"
+ Padding="4"
+ BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
+ CornerRadius="3"
+ Value="{Binding DefaultFontSize, Mode=TwoWay}">
@@ -218,10 +218,23 @@
+
+
+
+
+
-
@@ -232,16 +245,16 @@
-
-
-
diff --git a/src/Views/RevisionFileContentViewer.axaml.cs b/src/Views/RevisionFileContentViewer.axaml.cs
index c74f2db2..16f4fc83 100644
--- a/src/Views/RevisionFileContentViewer.axaml.cs
+++ b/src/Views/RevisionFileContentViewer.axaml.cs
@@ -15,6 +15,15 @@ namespace SourceGit.Views
{
public class RevisionTextFileView : TextEditor
{
+ public static readonly StyledProperty TabWidthProperty =
+ AvaloniaProperty.Register(nameof(TabWidth), 4);
+
+ public int TabWidth
+ {
+ get => GetValue(TabWidthProperty);
+ set => SetValue(TabWidthProperty, value);
+ }
+
protected override Type StyleKeyOverride => typeof(TextEditor);
public RevisionTextFileView() : base(new TextArea(), new TextDocument())
@@ -22,13 +31,16 @@ namespace SourceGit.Views
IsReadOnly = true;
ShowLineNumbers = true;
WordWrap = false;
+
+ Options.IndentationSize = TabWidth;
+ Options.EnableHyperlinks = false;
+ Options.EnableEmailHyperlinks = false;
+
HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
TextArea.LeftMargins[0].Margin = new Thickness(8, 0);
TextArea.TextView.Margin = new Thickness(4, 0);
- TextArea.TextView.Options.EnableHyperlinks = false;
- TextArea.TextView.Options.EnableEmailHyperlinks = false;
}
protected override void OnLoaded(RoutedEventArgs e)
@@ -69,6 +81,16 @@ namespace SourceGit.Views
}
}
+ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
+ {
+ base.OnPropertyChanged(change);
+
+ if (change.Property == TabWidthProperty)
+ {
+ Options.IndentationSize = TabWidth;
+ }
+ }
+
private void OnTextViewContextRequested(object sender, ContextRequestedEventArgs e)
{
var selected = SelectedText;
diff --git a/src/Views/TextDiffView.axaml b/src/Views/TextDiffView.axaml
index 3ea7af14..7ea6b44b 100644
--- a/src/Views/TextDiffView.axaml
+++ b/src/Views/TextDiffView.axaml
@@ -27,6 +27,7 @@
IndicatorForeground="{DynamicResource Brush.FG2}"
FontFamily="{DynamicResource Fonts.Monospace}"
FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorFontSize}"
+ TabWidth="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorTabWidth}"
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preferences.Instance}, Path=UseSyntaxHighlighting}"
WordWrap="{Binding Source={x:Static vm:Preferences.Instance}, Path=EnableDiffViewWordWrap}"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preferences.Instance}, Path=ShowHiddenSymbolsInDiffView}"
@@ -59,6 +60,7 @@
IndicatorForeground="{DynamicResource Brush.FG2}"
FontFamily="{DynamicResource Fonts.Monospace}"
FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorFontSize}"
+ TabWidth="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorTabWidth}"
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preferences.Instance}, Path=UseSyntaxHighlighting}"
WordWrap="False"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preferences.Instance}, Path=ShowHiddenSymbolsInDiffView}"
@@ -81,6 +83,7 @@
IndicatorForeground="{DynamicResource Brush.FG2}"
FontFamily="{DynamicResource Fonts.Monospace}"
FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorFontSize}"
+ TabWidth="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorTabWidth}"
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preferences.Instance}, Path=UseSyntaxHighlighting}"
WordWrap="False"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preferences.Instance}, Path=ShowHiddenSymbolsInDiffView}"
diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs
index 93d31668..630be1b2 100644
--- a/src/Views/TextDiffView.axaml.cs
+++ b/src/Views/TextDiffView.axaml.cs
@@ -475,6 +475,15 @@ namespace SourceGit.Views
set => SetValue(ShowHiddenSymbolsProperty, value);
}
+ public static readonly StyledProperty TabWidthProperty =
+ AvaloniaProperty.Register(nameof(TabWidth), 4);
+
+ public int TabWidth
+ {
+ get => GetValue(TabWidthProperty);
+ set => SetValue(TabWidthProperty, value);
+ }
+
public static readonly StyledProperty EnableChunkSelectionProperty =
AvaloniaProperty.Register(nameof(EnableChunkSelection));
@@ -519,12 +528,13 @@ namespace SourceGit.Views
ShowLineNumbers = false;
BorderThickness = new Thickness(0);
+ Options.IndentationSize = TabWidth;
+ Options.EnableHyperlinks = false;
+ Options.EnableEmailHyperlinks = false;
+
_lineStyleTransformer = new LineStyleTransformer(this);
TextArea.TextView.Margin = new Thickness(2, 0);
- TextArea.TextView.Options.EnableHyperlinks = false;
- TextArea.TextView.Options.EnableEmailHyperlinks = false;
-
TextArea.TextView.BackgroundRenderers.Add(new LineBackgroundRenderer(this));
TextArea.TextView.LineTransformers.Add(_lineStyleTransformer);
}
@@ -734,10 +744,14 @@ namespace SourceGit.Views
}
else if (change.Property == ShowHiddenSymbolsProperty)
{
- var val = change.NewValue is true;
+ var val = ShowHiddenSymbols;
Options.ShowTabs = val;
Options.ShowSpaces = val;
}
+ else if (change.Property == TabWidthProperty)
+ {
+ Options.IndentationSize = TabWidth;
+ }
else if (change.Property == FileNameProperty)
{
Models.TextMateHelper.SetGrammarByFileName(_textMate, FileName);