SharpDevelop Community

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

Using VisualLineElementGenerator and VisualLineElement to create secondary empty line

Last post 01-27-2017 10:16 PM by DanielGrunwald. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 01-20-2017 12:58 AM

    Using VisualLineElementGenerator and VisualLineElement to create secondary empty line

    I am trying to build a diffing utility into my application and want to show a blank, unnumbered line after certain lines to indicate a deleted line between 2 different files. Based on this thread I foundI'm trying to understand VisualLineElementGenerator and VisualLineElements. I've found a few exmaples of implementations and have managed the ability to insert blank/empty text runs at the begining and in the middle of lines, but not at the end. I've ben trying to maybe have my CreateTextRun function return something like:

    Return New TextCharacters(Environment.NewLine + "!", Me.TextRunProperties)

    But I get an exception saying "The returned TextRun is too long." & vbCrLf & "Parameter name: MyVisualLineElement.CreateTextRun"

     

    Below is my class. How Can I achieve adding the EndOfLine at the end of a run so I get an empty secondary line (if the secondary line contains whitespace that is acceptable)? Thanks!

     

    Private Class MyVisualLineElement
        Inherits VisualLineElement
        Public Sub New()
            MyBase.New(visualLength:=1, documentLength:=0)
        End Sub
     
        Public Overrides Function CreateTextRun(startVisualColumn As Integer, context As ITextRunConstructionContext) As TextRun
            Return New TextCharacters(Environment.NewLine + " ", Me.TextRunProperties)
            'Return New TextEndOfLine(1)
        End Function
    End Class

     

    To be clear, returning New TextEndOfLine(1) the the end of a run doesn't produce an error...it simply doesn't add any additional lines.

  • 01-27-2017 10:16 PM In reply to

    Re: Using VisualLineElementGenerator and VisualLineElement to create secondary empty line

    The 'visualLength' specified in the constructor must match the value returned by `TextCharacters.Length`.

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.