SharpDevelop Community

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

AvalonEdit: Is there a way TextSegments can be colored and cursor knows if in one?

Last post 05-18-2015 8:54 PM by siegi44. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-08-2015 4:53 PM

    AvalonEdit: Is there a way TextSegments can be colored and cursor knows if in one?

    So my goal is the following.  Point 1 works but not sure how to handle others

    • make certain text segments uneditable by typing. (this is done by TextSegmentReadOnlySectionProvider)
    • allow the user to delete the whole text segment if right click over the segment
    • make the text segment a certain color

    All segments are a word or set of words between '<' and '>'

    These segments need to be able to dynamically add new textsegments at runtime

     

    All searches for answers just do not fit my problem exactly

  • 05-12-2015 5:40 PM In reply to

    Re: AvalonEdit: Is there a way TextSegments can be colored and cursor knows if in one?

    Well I managed to find enough info to solve most of this using a customized xshd.

    I stopped relying on text segments beyond making the term uneditable and instead use custom color type for these key words.  This allows me to tell if the carat is in one so I can find the start and end offsets and delete text in code if requested.

     

    Now I just need to be able to add to these terms while the program is running and that may work with an xml writer I hope

  • 05-18-2015 8:54 PM In reply to

    • siegi44
    • Top 10 Contributor
    • Joined on 03-31-2006
    • Steyr, Austria
    • Posts 806
    • Team Members

    Re: AvalonEdit: Is there a way TextSegments can be colored and cursor knows if in one?

    If you want to highlight any text between two markers and are using an XML highlighting definition, this solution might work for you:

    <?xml version="1.0"?>
    <SyntaxDefinition name="Custom Highlighting" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
        <Color name="Test" foreground="Brown" background="Yellow" />
        
        <!-- This is the main ruleset. -->
        <RuleSet>
            <Span color="Test">
                <Begin>&lt;</Begin>
                <End>&gt;</End>
            </Span>
        </RuleSet>
    </SyntaxDefinition>


    kind regards,

    Siegfried

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