diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs
index c9b2d46eb9..dfeb428798 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs
@@ -42,6 +42,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
textEditor.TextArea.TextView.ClearValue(TextView.NonPrintableCharacterBrushProperty);
textEditor.TextArea.TextView.ClearValue(TextView.LinkTextForegroundBrushProperty);
textEditor.TextArea.TextView.ClearValue(TextView.LinkTextBackgroundBrushProperty);
+ textEditor.TextArea.TextView.ClearValue(TextView.ColumnRulerBrushProperty);
// 'assigned' flags are used so that the first matching customization wins.
// This is necessary because more specific customizations come first in the list
@@ -51,6 +52,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
bool assignedNonPrintableCharacter = false;
bool assignedLineNumbers = false;
bool assignedLinkText = false;
+ bool assignedColumnRulerColor = false;
+
foreach (CustomizedHighlightingColor color in customizations) {
switch (color.Name) {
case DefaultTextAndBackground:
@@ -106,6 +109,13 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (color.Background != null)
textEditor.TextArea.TextView.LinkTextBackgroundBrush = CreateFrozenBrush(color.Background.Value);
break;
+ case ColumnRulerRenderer.Name:
+ if (assignedColumnRulerColor)
+ continue;
+ assignedColumnRulerColor = true;
+ if (color.Foreground != null)
+ textEditor.TextArea.TextView.ColumnRulerBrush = CreateFrozenBrush(color.Foreground.Value);
+ break;
}
}
}
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs
index 547217bb2d..70f3ea8cde 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs
@@ -245,7 +245,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
}
int ITextEditorOptions.VerticalRulerColumn {
- get { return 120; }
+ get { return ColumnRulerPosition; }
}
}
}
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs
index d40ebf0dc7..62eeb9d398 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs
@@ -39,10 +39,10 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
InitializeComponent();
textEditor.Document.UndoStack.SizeLimit = 0;
- textEditor.Options = CodeEditorOptions.Instance;
+ CodeEditorOptions.Instance.BindToTextEditor(textEditor);
+ textEditor.Options = new TextEditorOptions(CodeEditorOptions.Instance);
bracketHighlighter = new BracketHighlightRenderer(textEditor.TextArea.TextView);
foldingManager = FoldingManager.Install(textEditor.TextArea);
- CodeEditorOptions.Instance.BindToTextEditor(textEditor);
textMarkerService = new TextMarkerService(textEditor.Document);
textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
@@ -429,6 +429,20 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
currentStatementMarker = new CustomizedHighlightingItem(customizationList, currentStatementMarker, language, canSetFont: false);
currentStatementMarker.PropertyChanged += item_PropertyChanged;
items.Add(currentStatementMarker);
+
+ IHighlightingItem columnRuler = new SimpleHighlightingItem(
+ ColumnRulerRenderer.Name,
+ ta => {
+ ta.Document.Text = "some line with a lot of text";
+ ta.TextView.Options.ColumnRulerPosition = 15;
+ ta.TextView.Options.ShowColumnRuler = true;
+ })
+ {
+ Foreground = ColumnRulerRenderer.DefaultForeground
+ };
+ columnRuler = new CustomizedHighlightingItem(customizationList, columnRuler, language, canSetFont: false, canSetBackground: false);
+ columnRuler.PropertyChanged += item_PropertyChanged;
+ items.Add(columnRuler);
}
void item_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/ColumnRulerRenderer.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/ColumnRulerRenderer.cs
index 522e45a23a..f809b57de4 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/ColumnRulerRenderer.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/ColumnRulerRenderer.cs
@@ -4,36 +4,37 @@
using System;
using System.Windows;
using System.Windows.Media;
+
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit
{
///
- /// Redners a ruler at a certain colum
+ /// Renders a ruler at a certain column.
///
public class ColumnRulerRenderer : IBackgroundRenderer
{
-
Pen pen;
int column;
TextView textView;
+ public const string Name = "Column ruler";
+ public static readonly Color DefaultForeground = Colors.LightGray;
+
public ColumnRulerRenderer(TextView textView)
{
if (textView == null)
throw new ArgumentNullException("textView");
- this.pen = new Pen(Brushes.LightGray, 1);
+ this.pen = new Pen(new SolidColorBrush(DefaultForeground), 1);
this.pen.Freeze();
this.textView = textView;
this.textView.BackgroundRenderers.Add(this);
}
public KnownLayer Layer {
- get {
- return KnownLayer.Background;
- }
+ get { return KnownLayer.Background; }
}
public void SetRuler(int column, Brush brush)
@@ -51,11 +52,9 @@ namespace ICSharpCode.AvalonEdit
public void Draw(TextView textView, System.Windows.Media.DrawingContext drawingContext)
{
- if(column < 1)
- return;
-
+ if (column < 1) return;
double offset = textView.WideSpaceWidth * column;
- System.Windows.Size pixelSize = PixelSnapHelpers.GetPixelSize(textView);
+ Size pixelSize = PixelSnapHelpers.GetPixelSize(textView);
double markerXPos = PixelSnapHelpers.PixelAlign(offset, pixelSize.Width);
Point start = new Point(markerXPos, 0);
Point end = new Point(markerXPos, Math.Max(textView.DocumentHeight, textView.ActualHeight));
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
index 232200fbd3..50db99f9df 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
@@ -183,7 +183,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
new FrameworkPropertyMetadata(OnOptionsChanged));
///
- /// Gets/Sets the document displayed by the text editor.
+ /// Gets/Sets the options used by the text editor.
///
public TextEditorOptions Options {
get { return (TextEditorOptions)GetValue(OptionsProperty); }