Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

AvalonEdit: BackgroundGeometryBuilder.GetRectsFromVisualSegment fails when ShowTabs is true

$
0
0

Hi, I have a pretty simple use case that works fine as long as I don't set ShowTabs to true in AvalonEdit. I have a IBackgroundRenderer where I want to highlight som characters by drawing a rectangle around them with this simple code:

private static void highlightCharacters(TextView textView, DrawingContext drawingContext, VisualLine visualLine, int startIndex, int length)
{
    var rects = BackgroundGeometryBuilder.GetRectsFromVisualSegment(textView, visualLine, startIndex, startIndex + length);
    foreach (Rect r in rects)
    {
        Rect drawRect = new Rect(r.X, r.Y, r.Width, r.Height);

        drawingContext.DrawRectangle(s_brush, null, drawRect);
    }
}

The problem with a line with tabs and ShowTabs (textView.Options.ShowTabs == true) is that the indexes seems to be all offset with the amount of tabs on that line. E.g. if I ask for startIndex 0 and length 1 and the first char on that line is a tab then a rect with Width 0 is returned instead of 32.

Bug? Am I doing anything wrong? Workaround?

Thanks!


Viewing all articles
Browse latest Browse all 1764

Trending Articles