SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

AvalonEdit: BackgroundGeometryBuilder.GetRectsFromVisualSegment fails when ShowTabs is true

Last post 04-24-2017 10:29 PM by Gupa. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 04-02-2017 3:58 PM

    • Gupa
    • Not Ranked
    • Joined on 04-02-2017
    • Posts 2

    AvalonEdit: BackgroundGeometryBuilder.GetRectsFromVisualSegment fails when ShowTabs is true

    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!

  • 04-24-2017 10:29 PM In reply to

    • Gupa
    • Not Ranked
    • Joined on 04-02-2017
    • Posts 2

    Re: AvalonEdit: BackgroundGeometryBuilder.GetRectsFromVisualSegment fails when ShowTabs is true

    Anyone have any ideas? All feedback welcome.

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.