Skip to content

Commit

Permalink
LineNumbersMargin property added to TextEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
NickRimmer committed Mar 7, 2024
1 parent c805978 commit 6ad58d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/AvaloniaEdit.Demo/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Visible"
FontWeight="Light"
LineNumbersMargin="10,0,20,0"
FontSize="14" />
</DockPanel>
</Window>
19 changes: 19 additions & 0 deletions src/AvaloniaEdit/TextEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,9 @@ private static void OnShowLineNumbersChanged(AvaloniaPropertyChangedEventArgs e)
leftMargins.Insert(0, lineNumbers);
leftMargins.Insert(1, line);
var lineNumbersForeground = new Binding("LineNumbersForeground") { Source = editor };
var lineNumbersMargin = new Binding("LineNumbersMargin") { Source = editor };
line.Bind(Shape.StrokeProperty, lineNumbersForeground);
line.Bind(MarginProperty, lineNumbersMargin);
lineNumbers.Bind(ForegroundProperty, lineNumbersForeground);
}
else
Expand Down Expand Up @@ -608,6 +610,23 @@ private static void SearchResultsBrushChangedCallback(AvaloniaPropertyChangedEve
}

#endregion

#region LineNumbersMargin
/// <summary>
/// LineNumbersMargin dependency property.
/// </summary>
public static readonly StyledProperty<Thickness> LineNumbersMarginProperty =
AvaloniaProperty.Register<TextEditor, Thickness>("LineNumbersMargin", new Thickness(2, 0, 2, 0));

/// <summary>
/// Gets or sets the margin that is used to display the vertical line to the right of the line numbers.
/// </summary>
public Thickness LineNumbersMargin
{
get => GetValue(LineNumbersMarginProperty);
set => SetValue(LineNumbersMarginProperty, value);
}
#endregion

#region TextBoxBase-like methods
/// <summary>
Expand Down

0 comments on commit 6ad58d4

Please sign in to comment.