mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
enhance: allow to configure editor tab width in preferences window (#1048)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
11af5d9b29
commit
2137ad9ec9
11 changed files with 98 additions and 19 deletions
|
@ -15,6 +15,15 @@ namespace SourceGit.Views
|
|||
{
|
||||
public class RevisionTextFileView : TextEditor
|
||||
{
|
||||
public static readonly StyledProperty<int> TabWidthProperty =
|
||||
AvaloniaProperty.Register<RevisionTextFileView, int>(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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue