Browse Source

fix marker display on the same code editor.

pull/191/merge
Eusebiu Marcu 16 years ago
parent
commit
fe6ca3d58a
  1. 12
      Debugger/ILSpy.Debugger/AvalonEdit/ITextMarker.cs
  2. 19
      Debugger/ILSpy.Debugger/AvalonEdit/TextMarkerService.cs
  3. 4
      Debugger/ILSpy.Debugger/Bookmarks/BreakpointBookmark.cs
  4. 3
      Debugger/ILSpy.Debugger/Bookmarks/CurrentLineBookmark.cs

12
Debugger/ILSpy.Debugger/AvalonEdit/ITextMarker.cs

@ -5,6 +5,8 @@ using System; @@ -5,6 +5,8 @@ using System;
using System.Collections.Generic;
using System.Windows.Media;
using ILSpy.Debugger.Bookmarks;
namespace ILSpy.Debugger.AvalonEdit
{
/// <summary>
@ -71,6 +73,16 @@ namespace ILSpy.Debugger.AvalonEdit @@ -71,6 +73,16 @@ namespace ILSpy.Debugger.AvalonEdit
/// Gets/Sets an object that will be displayed as tooltip in the text editor.
/// </summary>
object ToolTip { get; set; }
/// <summary>
/// Gets or sets if the marker is visible or not.
/// </summary>
Predicate<object> IsVisible { get; set; }
/// <summary>
/// Gets or sets the bookmark.
/// </summary>
IBookmark Bookmark { get; set; }
}
public enum TextMarkerType

19
Debugger/ILSpy.Debugger/AvalonEdit/TextMarkerService.cs

@ -49,10 +49,10 @@ namespace ILSpy.Debugger.AvalonEdit @@ -49,10 +49,10 @@ namespace ILSpy.Debugger.AvalonEdit
{
if (e.Bookmark is MarkerBookmark) {
var bm = (MarkerBookmark)e.Bookmark;
if (DebugData.CurrentType != null && DebugData.CurrentType.FullName.Equals(bm.Type.FullName, StringComparison.OrdinalIgnoreCase)) {
if (DebugData.CurrentType != null && DebugData.CurrentType == bm.Type) {
// add bookmark for the current type
DocumentLine line = codeEditor.Document.GetLineByNumber(bm.LineNumber);
bm.Marker = bm.CreateMarker(this, line.Offset, line.Length);
bm.CreateMarker(this, line.Offset, line.Length);
}
}
}
@ -120,6 +120,9 @@ namespace ILSpy.Debugger.AvalonEdit @@ -120,6 +120,9 @@ namespace ILSpy.Debugger.AvalonEdit
int lineStart = line.Offset;
int lineEnd = lineStart + line.Length;
foreach (TextMarker marker in markers.FindOverlappingSegments(lineStart, line.Length).Reverse()) {
if (!marker.IsVisible(marker.Bookmark))
continue;
Brush foregroundBrush = null;
if (marker.ForegroundColor != null) {
foregroundBrush = new SolidColorBrush(marker.ForegroundColor.Value);
@ -160,6 +163,9 @@ namespace ILSpy.Debugger.AvalonEdit @@ -160,6 +163,9 @@ namespace ILSpy.Debugger.AvalonEdit
int viewStart = visualLines.First().FirstDocumentLine.Offset;
int viewEnd = visualLines.Last().LastDocumentLine.Offset + visualLines.Last().LastDocumentLine.Length;
foreach (TextMarker marker in markers.FindOverlappingSegments(viewStart, viewEnd - viewStart).Reverse()) {
if (!marker.IsVisible(marker.Bookmark))
continue;
if (marker.BackgroundColor != null) {
BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
geoBuilder.AlignToWholePixels = true;
@ -295,8 +301,15 @@ namespace ILSpy.Debugger.AvalonEdit @@ -295,8 +301,15 @@ namespace ILSpy.Debugger.AvalonEdit
Redraw();
}
}
}
}
/// <inheritdoc/>
public object ToolTip { get; set; }
/// <inheritdoc/>
public Predicate<object> IsVisible { get; set; }
/// <inheritdoc/>
public IBookmark Bookmark { get; set; }
}
}

4
Debugger/ILSpy.Debugger/Bookmarks/BreakpointBookmark.cs

@ -91,6 +91,10 @@ namespace ILSpy.Debugger.Bookmarks @@ -91,6 +91,10 @@ namespace ILSpy.Debugger.Bookmarks
ITextMarker marker = markerService.Create(offset, length);
marker.BackgroundColor = Color.FromRgb(180, 38, 38);
marker.ForegroundColor = Colors.White;
marker.IsVisible = b => b is MarkerBookmark && ((MarkerBookmark)b).Type == DebugData.CurrentType;
marker.Bookmark = this;
this.Marker = marker;
return marker;
}
}

3
Debugger/ILSpy.Debugger/Bookmarks/CurrentLineBookmark.cs

@ -81,6 +81,9 @@ namespace ILSpy.Debugger.Bookmarks @@ -81,6 +81,9 @@ namespace ILSpy.Debugger.Bookmarks
ITextMarker marker = markerService.Create(offset + startColumn - 1, length);
marker.BackgroundColor = Colors.Yellow;
marker.ForegroundColor = Colors.Blue;
marker.IsVisible = b => b is MarkerBookmark && ((MarkerBookmark)b).Type == DebugData.CurrentType;
marker.Bookmark = this;
this.Marker = marker;
return marker;
}
}

Loading…
Cancel
Save