From 74e0f42f761cde418f45c9708ca063e959abc117 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 1 Jun 2012 18:08:44 +0200 Subject: [PATCH] make colors of current statement marker customizable --- .../Src/Options/HighlightingOptions.xaml.cs | 14 ++++++++++++ .../Services/Debugger/CurrentLineBookmark.cs | 22 ++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) 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 04ee9d4bed..d40ebf0dc7 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs @@ -415,6 +415,20 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options breakpointMarker = new CustomizedHighlightingItem(customizationList, breakpointMarker, language, canSetFont: false); breakpointMarker.PropertyChanged += item_PropertyChanged; items.Add(breakpointMarker); + + IHighlightingItem currentStatementMarker = new SimpleHighlightingItem( + CurrentLineBookmark.Name, + ta => { + ta.Document.Text = "current statement line"; + marker = textMarkerService.Create(0, ta.Document.TextLength); + }) + { + Background = CurrentLineBookmark.DefaultBackground, + Foreground = CurrentLineBookmark.DefaultForeground + }; + currentStatementMarker = new CustomizedHighlightingItem(customizationList, currentStatementMarker, language, canSetFont: false); + currentStatementMarker.PropertyChanged += item_PropertyChanged; + items.Add(currentStatementMarker); } void item_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) diff --git a/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs b/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs index 26be9ea858..922a868b75 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs @@ -65,11 +65,14 @@ namespace ICSharpCode.SharpDevelop.Debugging } public override bool CanToggle { - get { - return false; - } + get { return false; } } + public const string Name = "Current statement"; + + public static readonly Color DefaultBackground = Colors.Yellow; + public static readonly Color DefaultForeground = Colors.Blue; + public override int ZOrder { get { return 100; } } @@ -90,8 +93,17 @@ namespace ICSharpCode.SharpDevelop.Debugging { IDocumentLine line = this.Document.GetLine(startLine); ITextMarker marker = markerService.Create(line.Offset + startColumn - 1, Math.Max(endColumn - startColumn, 1)); - marker.BackgroundColor = Colors.Yellow; - marker.ForegroundColor = Colors.Blue; + ISyntaxHighlighter highlighter = this.Document.GetService(typeof(ISyntaxHighlighter)) as ISyntaxHighlighter; + marker.BackgroundColor = DefaultBackground; + marker.ForegroundColor = DefaultForeground; + + if (highlighter != null) { + var color = highlighter.GetNamedColor(Name); + if (color != null) { + marker.BackgroundColor = color.Background.GetColor(null); + marker.ForegroundColor = color.Foreground.GetColor(null); + } + } return marker; }