Browse Source

Move HighlightCurrentLine from AvalonEdit.Addin to ICSharpCode.AvalonEdit

pull/289/head
Patryk Mikos 12 years ago
parent
commit
5de622f937
  1. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj
  2. 24
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
  3. 13
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs
  4. 16
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs
  5. 13
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxHighlighting/CustomizingHighlighter.cs
  6. 9
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs
  7. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
  8. 82
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/CurrentLineHighlightRenderer.cs
  9. 46
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
  10. 16
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs

1
src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj

@ -112,7 +112,6 @@
<Compile Include="Src\ContextActions\FindBaseClasses.cs" /> <Compile Include="Src\ContextActions\FindBaseClasses.cs" />
<Compile Include="Src\ContextActions\FindDerivedClassesOrOverrides.cs" /> <Compile Include="Src\ContextActions\FindDerivedClassesOrOverrides.cs" />
<Compile Include="Src\ContextActions\GoToEntityAction.cs" /> <Compile Include="Src\ContextActions\GoToEntityAction.cs" />
<Compile Include="Src\CurrentLineHighlightRenderer.cs" />
<Compile Include="Src\EnhancedScrollBar.cs" /> <Compile Include="Src\EnhancedScrollBar.cs" />
<Compile Include="Src\HiddenDefinitionRenderer.cs" /> <Compile Include="Src\HiddenDefinitionRenderer.cs" />
<Compile Include="Src\SyntaxHighlighting\CustomizingHighlighter.cs" /> <Compile Include="Src\SyntaxHighlighting\CustomizingHighlighter.cs" />

24
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs

@ -48,7 +48,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
public ITextEditor Adapter { get; set; } public ITextEditor Adapter { get; set; }
BracketHighlightRenderer bracketRenderer; BracketHighlightRenderer bracketRenderer;
CurrentLineHighlightRenderer currentLineRenderer;
//CaretReferencesRenderer caretReferencesRenderer; //CaretReferencesRenderer caretReferencesRenderer;
ContextActionsRenderer contextActionsRenderer; ContextActionsRenderer contextActionsRenderer;
HiddenDefinition.HiddenDefinitionRenderer hiddenDefinitionRenderer; HiddenDefinition.HiddenDefinitionRenderer hiddenDefinitionRenderer;
@ -58,7 +57,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, OnHelpExecuted)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, OnHelpExecuted));
this.bracketRenderer = new BracketHighlightRenderer(this.TextArea.TextView); this.bracketRenderer = new BracketHighlightRenderer(this.TextArea.TextView);
this.currentLineRenderer = new CurrentLineHighlightRenderer(this.TextArea.TextView);
//this.caretReferencesRenderer = new CaretReferencesRenderer(this); //this.caretReferencesRenderer = new CaretReferencesRenderer(this);
this.contextActionsRenderer = new ContextActionsRenderer(this); this.contextActionsRenderer = new ContextActionsRenderer(this);
this.hiddenDefinitionRenderer = new HiddenDefinition.HiddenDefinitionRenderer(this); this.hiddenDefinitionRenderer = new HiddenDefinition.HiddenDefinitionRenderer(this);
@ -73,7 +71,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
this.TextArea.TextView.MouseDown += TextViewMouseDown; this.TextArea.TextView.MouseDown += TextViewMouseDown;
this.TextArea.TextView.MouseUp += TextViewMouseUp; this.TextArea.TextView.MouseUp += TextViewMouseUp;
this.TextArea.Caret.PositionChanged += HighlightBrackets; this.TextArea.Caret.PositionChanged += HighlightBrackets;
this.TextArea.Caret.PositionChanged += HighlightCurrentLine;
this.TextArea.TextView.VisualLinesChanged += CodeEditorView_VisualLinesChanged; this.TextArea.TextView.VisualLinesChanged += CodeEditorView_VisualLinesChanged;
SetupTabSnippetHandler(); SetupTabSnippetHandler();
@ -107,9 +104,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
case "HighlightBrackets": case "HighlightBrackets":
HighlightBrackets(null, e); HighlightBrackets(null, e);
break; break;
case "HighlightCurrentLine":
HighlightCurrentLine(null, e);
break;
case "EnableFolding": case "EnableFolding":
UpdateParseInformationForFolding(); UpdateParseInformationForFolding();
break; break;
@ -120,8 +114,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
} }
#region CaretPositionChanged - Bracket Highlighting and current line highlighting #region CaretPositionChanged - Bracket Highlighting
/// <summary> /// <summary>
/// Highlights matching brackets. /// Highlights matching brackets.
/// </summary> /// </summary>
@ -153,20 +146,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
} }
/// <summary>
/// Highlights current line
/// </summary>
void HighlightCurrentLine(object sender, EventArgs e)
{
if(this.Adapter.Language != null) {
if(CodeEditorOptions.Instance.HighlightCurrentLine) {
this.currentLineRenderer.SetHighlight(this.TextArea.Caret.Line);
} else {
this.currentLineRenderer.SetHighlight(-1);
}
}
}
#endregion #endregion
#region Custom Tab command (code snippet expansion) #region Custom Tab command (code snippet expansion)
@ -534,7 +513,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
var customizations = CustomizedHighlightingColor.FetchCustomizations(language); var customizations = CustomizedHighlightingColor.FetchCustomizations(language);
CustomizingHighlighter.ApplyCustomizationsToDefaultElements(this, customizations); CustomizingHighlighter.ApplyCustomizationsToDefaultElements(this, customizations);
BracketHighlightRenderer.ApplyCustomizationsToRendering(this.bracketRenderer, customizations); BracketHighlightRenderer.ApplyCustomizationsToRendering(this.bracketRenderer, customizations);
CurrentLineHighlightRenderer.ApplyCustomizationsToRendering(this.currentLineRenderer, customizations);
HighlightingOptions.ApplyToRendering(this, customizations); HighlightingOptions.ApplyToRendering(this, customizations);
this.TextArea.TextView.Redraw(); // manually redraw if default elements didn't change but customized highlightings did this.TextArea.TextView.Redraw(); // manually redraw if default elements didn't change but customized highlightings did
} }

13
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs

@ -153,19 +153,6 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
} }
} }
bool highlightCurrentLine = true;
[DefaultValueAttribute(true)]
public bool HighlightCurrentLine {
get { return highlightCurrentLine; }
set {
if(highlightCurrentLine != value) {
highlightCurrentLine = value;
OnPropertyChanged("HighlightCurrentLine");
}
}
}
bool highlightSymbol = true; bool highlightSymbol = true;
[DefaultValue(true)] [DefaultValue(true)]

16
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs

@ -40,7 +40,6 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
CodeEditorOptions.Instance.BindToTextEditor(textEditor); CodeEditorOptions.Instance.BindToTextEditor(textEditor);
textEditor.Options = new TextEditorOptions(CodeEditorOptions.Instance); textEditor.Options = new TextEditorOptions(CodeEditorOptions.Instance);
bracketHighlighter = new BracketHighlightRenderer(textEditor.TextArea.TextView); bracketHighlighter = new BracketHighlightRenderer(textEditor.TextArea.TextView);
currentLineHighlighter = new CurrentLineHighlightRenderer(textEditor.TextArea.TextView);
foldingManager = FoldingManager.Install(textEditor.TextArea); foldingManager = FoldingManager.Install(textEditor.TextArea);
textMarkerService = new TextMarkerService(textEditor.Document); textMarkerService = new TextMarkerService(textEditor.Document);
textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService); textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
@ -49,7 +48,6 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
} }
BracketHighlightRenderer bracketHighlighter; BracketHighlightRenderer bracketHighlighter;
CurrentLineHighlightRenderer currentLineHighlighter;
FoldingManager foldingManager; FoldingManager foldingManager;
TextMarkerService textMarkerService; TextMarkerService textMarkerService;
List<CustomizedHighlightingColor> customizationList; List<CustomizedHighlightingColor> customizationList;
@ -355,19 +353,14 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
// Create entry for "Current Line highlight" // Create entry for "Current Line highlight"
IHighlightingItem currentLineHighlight = new SimpleHighlightingItem( IHighlightingItem currentLineHighlight = new SimpleHighlightingItem(
CurrentLineHighlightRenderer.CurrentLineHighlight, CustomizingHighlighter.CurrentLineHighlighter,
ta => { ta => {
ta.Document.Text = "example text line"; ta.Document.Text = "example text line";
XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem; ta.TextView.Options.HighlightCurrentLine = true;
if (xshd == null)
return;
var customizationsForCurrentLanguage = customizationList.Where(c => c.Language == null || c.Language == xshd.Name);
CurrentLineHighlightRenderer.ApplyCustomizationsToRendering(currentLineHighlighter, customizationsForCurrentLanguage);
currentLineHighlighter.SetHighlight(1);
}) })
{ {
Foreground = CurrentLineHighlightRenderer.DefaultBorder, Foreground = Colors.Red,//CurrentLineHighlightRenderer.DefaultBorder,
Background = CurrentLineHighlightRenderer.DefaultBackground Background = Colors.Yellow//CurrentLineHighlightRenderer.DefaultBackground
}; };
currentLineHighlight = new CustomizedHighlightingItem(customizationList, currentLineHighlight, language, canSetFont: false); currentLineHighlight = new CustomizedHighlightingItem(customizationList, currentLineHighlight, language, canSetFont: false);
currentLineHighlight.PropertyChanged += item_PropertyChanged; currentLineHighlight.PropertyChanged += item_PropertyChanged;
@ -587,7 +580,6 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
} }
textEditor.Select(0, 0); textEditor.Select(0, 0);
bracketHighlighter.SetHighlight(null); bracketHighlighter.SetHighlight(null);
currentLineHighlighter.SetHighlight(0);
item.ShowExample(textEditor.TextArea); item.ShowExample(textEditor.TextArea);
ITextMarker m = textMarkerService.TextMarkers.SingleOrDefault(); ITextMarker m = textMarkerService.TextMarkers.SingleOrDefault();
if (m != null && m.Tag != null) { if (m != null && m.Tag != null) {

13
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxHighlighting/CustomizingHighlighter.cs

@ -29,6 +29,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
public const string BreakpointMarker = "Breakpoint"; public const string BreakpointMarker = "Breakpoint";
public const string InstructionPointerMarker = "Current statement"; public const string InstructionPointerMarker = "Current statement";
public const string ColumnRuler = "Column ruler"; public const string ColumnRuler = "Column ruler";
public const string CurrentLineHighlighter = "Current line highlighting";
public static void ApplyCustomizationsToDefaultElements(TextEditor textEditor, IEnumerable<CustomizedHighlightingColor> customizations) public static void ApplyCustomizationsToDefaultElements(TextEditor textEditor, IEnumerable<CustomizedHighlightingColor> customizations)
{ {
@ -42,6 +43,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
textEditor.TextArea.TextView.ClearValue(TextView.LinkTextForegroundBrushProperty); textEditor.TextArea.TextView.ClearValue(TextView.LinkTextForegroundBrushProperty);
textEditor.TextArea.TextView.ClearValue(TextView.LinkTextBackgroundBrushProperty); textEditor.TextArea.TextView.ClearValue(TextView.LinkTextBackgroundBrushProperty);
textEditor.TextArea.TextView.ClearValue(TextView.ColumnRulerPenProperty); textEditor.TextArea.TextView.ClearValue(TextView.ColumnRulerPenProperty);
textEditor.TextArea.TextView.ClearValue(TextView.CurrentLineBorderProperty);
textEditor.TextArea.TextView.ClearValue(TextView.CurrentLineBackgroundProperty);
// 'assigned' flags are used so that the first matching customization wins. // 'assigned' flags are used so that the first matching customization wins.
// This is necessary because more specific customizations come first in the list // This is necessary because more specific customizations come first in the list
@ -52,6 +55,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
bool assignedLineNumbers = false; bool assignedLineNumbers = false;
bool assignedLinkText = false; bool assignedLinkText = false;
bool assignedColumnRulerColor = false; bool assignedColumnRulerColor = false;
bool assignedCurrentLineHighlighter = false;
foreach (CustomizedHighlightingColor color in customizations) { foreach (CustomizedHighlightingColor color in customizations) {
switch (color.Name) { switch (color.Name) {
@ -115,6 +119,15 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (color.Foreground != null) if (color.Foreground != null)
textEditor.TextArea.TextView.ColumnRulerPen = CreateFrozenPen(color.Foreground.Value); textEditor.TextArea.TextView.ColumnRulerPen = CreateFrozenPen(color.Foreground.Value);
break; break;
case CurrentLineHighlighter:
if (assignedCurrentLineHighlighter)
continue;
assignedCurrentLineHighlighter = true;
if (color.Background != null)
textEditor.TextArea.TextView.CurrentLineBackground = CreateFrozenBrush(color.Background.Value);
if (color.Foreground != null)
textEditor.TextArea.TextView.CurrentLineBorder = CreateFrozenPen(color.Foreground.Value);
break;
} }
} }
} }

9
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs

@ -69,6 +69,7 @@ namespace ICSharpCode.AvalonEdit.Editing
caret = new Caret(this); caret = new Caret(this);
caret.PositionChanged += (sender, e) => RequestSelectionValidation(); caret.PositionChanged += (sender, e) => RequestSelectionValidation();
caret.PositionChanged += CaretPositionChanged;
ime = new ImeSupport(this); ime = new ImeSupport(this);
leftMargins.CollectionChanged += leftMargins_CollectionChanged; leftMargins.CollectionChanged += leftMargins_CollectionChanged;
@ -559,6 +560,14 @@ namespace ICSharpCode.AvalonEdit.Editing
get { return caret; } get { return caret; }
} }
void CaretPositionChanged(object sender, EventArgs e)
{
if (textView == null)
return;
this.textView.HighlightedLine = this.Caret.Line;
}
ObservableCollection<UIElement> leftMargins = new ObservableCollection<UIElement>(); ObservableCollection<UIElement> leftMargins = new ObservableCollection<UIElement>();
/// <summary> /// <summary>

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj

@ -242,6 +242,7 @@
<DependentUpon>IVisualLineTransformer.cs</DependentUpon> <DependentUpon>IVisualLineTransformer.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Rendering\ColumnRulerRenderer.cs" /> <Compile Include="Rendering\ColumnRulerRenderer.cs" />
<Compile Include="Rendering\CurrentLineHighlightRenderer.cs" />
<Compile Include="Rendering\DefaultTextRunTypographyProperties.cs" /> <Compile Include="Rendering\DefaultTextRunTypographyProperties.cs" />
<Compile Include="Rendering\DocumentColorizingTransformer.cs"> <Compile Include="Rendering\DocumentColorizingTransformer.cs">
<DependentUpon>IVisualLineTransformer.cs</DependentUpon> <DependentUpon>IVisualLineTransformer.cs</DependentUpon>

82
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CurrentLineHighlightRenderer.cs → src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/CurrentLineHighlightRenderer.cs

@ -9,57 +9,72 @@ using System.Windows.Media;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.Rendering
{ {
public class CurrentLineHighlightRenderer : IBackgroundRenderer sealed class CurrentLineHighlightRenderer : IBackgroundRenderer
{ {
#region Fields
int line; int line;
Pen borderPen;
Brush backgroundBrush;
TextView textView; TextView textView;
public static readonly Color DefaultBackground = Color.FromArgb(22, 20, 220, 224); public static readonly Color DefaultBackground = Color.FromArgb(22, 20, 220, 224);
public static readonly Color DefaultBorder = Color.FromArgb(52, 0, 255, 110); public static readonly Color DefaultBorder = Color.FromArgb(52, 0, 255, 110);
public const string CurrentLineHighlight = "Current line highlight"; #endregion
public CurrentLineHighlightRenderer(TextView textView) #region Properties
{
if (textView == null)
throw new ArgumentNullException("textView");
this.textView = textView; public int Line {
this.textView.BackgroundRenderers.Add(this); get { return this.Line; }
this.line = -1; set {
this.line = value;
this.textView.InvalidateLayer(this.Layer);
}
} }
public void SetHighlight(int caretLine) public bool Enabled {
{ get; set;
this.line = caretLine;
this.textView.InvalidateLayer(this.Layer);
} }
void UpdateColors(Color background, Color foreground) public KnownLayer Layer
{ {
this.borderPen = new Pen(new SolidColorBrush(foreground), 1); get { return KnownLayer.Selection; }
this.borderPen.Freeze(); }
this.backgroundBrush = new SolidColorBrush(background); public Brush BackgroundBrush {
this.backgroundBrush.Freeze(); get; set;
} }
public KnownLayer Layer public Pen BorderPen {
{ get; set;
get
{
return KnownLayer.Selection;
} }
#endregion
public CurrentLineHighlightRenderer(TextView textView)
{
if (textView == null)
throw new ArgumentNullException("textView");
this.BorderPen = new Pen(new SolidColorBrush(DefaultBorder), 1);
this.BorderPen.Freeze();
this.BackgroundBrush = new SolidColorBrush(DefaultBackground);
this.BackgroundBrush.Freeze();
this.textView = textView;
this.textView.BackgroundRenderers.Add(this);
this.line = 0;
} }
public void Draw(TextView textView, DrawingContext drawingContext) public void Draw(TextView textView, DrawingContext drawingContext)
{ {
if(!Enabled)
return;
BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder(); BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();
builder.CornerRadius = 1; builder.CornerRadius = 1;
@ -83,18 +98,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
Geometry geometry = builder.CreateGeometry(); Geometry geometry = builder.CreateGeometry();
if (geometry != null) { if (geometry != null) {
drawingContext.DrawGeometry(backgroundBrush, borderPen, geometry); drawingContext.DrawGeometry(this.BackgroundBrush, this.BorderPen, geometry);
}
}
public static void ApplyCustomizationsToRendering(CurrentLineHighlightRenderer renderer, IEnumerable<CustomizedHighlightingColor> customizations)
{
renderer.UpdateColors(DefaultBackground, DefaultBorder);
foreach (CustomizedHighlightingColor color in customizations) {
if (color.Name == CurrentLineHighlight) {
renderer.UpdateColors(color.Background ?? Colors.Pink, color.Foreground ?? Colors.Pink);
break;
}
} }
} }
} }

46
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs

@ -42,6 +42,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
} }
ColumnRulerRenderer columnRulerRenderer; ColumnRulerRenderer columnRulerRenderer;
CurrentLineHighlightRenderer currentLineHighlighRenderer;
/// <summary> /// <summary>
/// Creates a new TextView instance. /// Creates a new TextView instance.
@ -54,6 +55,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
lineTransformers = new ObserveAddRemoveCollection<IVisualLineTransformer>(LineTransformer_Added, LineTransformer_Removed); lineTransformers = new ObserveAddRemoveCollection<IVisualLineTransformer>(LineTransformer_Added, LineTransformer_Removed);
backgroundRenderers = new ObserveAddRemoveCollection<IBackgroundRenderer>(BackgroundRenderer_Added, BackgroundRenderer_Removed); backgroundRenderers = new ObserveAddRemoveCollection<IBackgroundRenderer>(BackgroundRenderer_Added, BackgroundRenderer_Removed);
columnRulerRenderer = new ColumnRulerRenderer(this); columnRulerRenderer = new ColumnRulerRenderer(this);
currentLineHighlighRenderer = new CurrentLineHighlightRenderer(this);
this.Options = new TextEditorOptions(); this.Options = new TextEditorOptions();
Debug.Assert(singleCharacterElementGenerator != null); // assert that the option change created the builtin element generators Debug.Assert(singleCharacterElementGenerator != null); // assert that the option change created the builtin element generators
@ -209,6 +211,8 @@ namespace ICSharpCode.AvalonEdit.Rendering
else else
columnRulerRenderer.SetRuler(-1, ColumnRulerPen); columnRulerRenderer.SetRuler(-1, ColumnRulerPen);
currentLineHighlighRenderer.Enabled = Options.HighlightCurrentLine;
UpdateBuiltinElementGeneratorsFromOptions(); UpdateBuiltinElementGeneratorsFromOptions();
Redraw(); Redraw();
} }
@ -1994,6 +1998,12 @@ namespace ICSharpCode.AvalonEdit.Rendering
if (e.Property == ColumnRulerPenProperty) { if (e.Property == ColumnRulerPenProperty) {
columnRulerRenderer.SetRuler(this.Options.ColumnRulerPosition, this.ColumnRulerPen); columnRulerRenderer.SetRuler(this.Options.ColumnRulerPosition, this.ColumnRulerPen);
} }
if (e.Property == CurrentLineBorderProperty) {
currentLineHighlighRenderer.BorderPen = this.CurrentLineBorder;
}
if (e.Property == CurrentLineBackgroundProperty) {
currentLineHighlighRenderer.BackgroundBrush = this.CurrentLineBackground;
}
} }
/// <summary> /// <summary>
@ -2019,5 +2029,41 @@ namespace ICSharpCode.AvalonEdit.Rendering
get { return (Pen)GetValue(ColumnRulerPenProperty); } get { return (Pen)GetValue(ColumnRulerPenProperty); }
set { SetValue(ColumnRulerPenProperty, value); } set { SetValue(ColumnRulerPenProperty, value); }
} }
/// <summary>
/// The <see cref="CurrentLineBackground"/> property.
/// </summary>
public static readonly DependencyProperty CurrentLineBackgroundProperty =
DependencyProperty.Register("CurrentLineBackground", typeof(Brush), typeof(TextView));
/// <summary>
/// Gets/Sets the background brush used by current line highlighter.
/// </summary>
public Brush CurrentLineBackground {
get { return (Brush)GetValue(CurrentLineBackgroundProperty); }
set { SetValue(CurrentLineBackgroundProperty, value); }
}
/// <summary>
/// The <see cref="CurrentLineBorder"/> property.
/// </summary>
public static readonly DependencyProperty CurrentLineBorderProperty =
DependencyProperty.Register("CurrentLineBorder", typeof(Pen), typeof(TextView));
/// <summary>
/// Gets/Sets the background brush used for the current line.
/// </summary>
public Pen CurrentLineBorder {
get { return (Pen)GetValue(CurrentLineBorderProperty); }
set { SetValue(CurrentLineBorderProperty, value); }
}
/// <summary>
/// Gets/Sets highlighted line number.
/// </summary>
public int HighlightedLine {
get { return this.currentLineHighlighRenderer.Line; }
set { this.currentLineHighlighRenderer.Line = value; }
}
} }
} }

16
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs

@ -430,5 +430,21 @@ namespace ICSharpCode.AvalonEdit
} }
} }
} }
bool highlightCurrentLine = false;
/// <summary>
/// Gets/Sets whether current line should be shown.
/// </summary>
[DefaultValue(false)]
public virtual bool HighlightCurrentLine {
get { return highlightCurrentLine; }
set {
if (highlightCurrentLine != value) {
highlightCurrentLine = value;
OnPropertyChanged("HighlightCurrentLine");
}
}
}
} }
} }

Loading…
Cancel
Save