Create Adorner in ViewLine with WordWrapMode Word

SyntaxEditor for WPF Forum

Posted 13 years ago by Tino Schnerwitzki
Version: 11.1.0545
Avatar
Hi,

I´m using SyntaxEditor with WordWrapMode set to Word.
What I want to do now is to add an adorner at the start of certain viewlines (depending on certain tokens at the line start). The text should slide to right where ever an adorner is drawn.
What I did is adding IIntraTextSpacerTags to a tagger in the Format method in a ITextFormater. An AdornerManager consumes the tags draws the adorners.
The problem now is that sometimes the adorners are drawn at the end of the previous line even though the tag are created using the StartOffset of the viewline.
If I try to adjust the width of the adorner (by setting the endoffset of the TagVersionRange when creating the tag) the same adorner did not jump on the previous line.

Is the approach to solve this problem - using a TextFormater and an Adorner - correct? If not how can this be achieved?
Is it correct that an adorner that still fits on the previous line will be drawn there if the WordWrapMode is set to Word? If so, can this be avoided?

Thanks in advance.

Comments (4)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Tino,

This sort of thing is somewhat difficult to give assistance on without a sample to look at. Can you make a new simple sample project that shows the issue, and email it over to our support address? Please reference this post in the email and be sure to rename the .zip file extension so it doesn't get spam blocked. Thanks!


Actipro Software Support

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Tino,

Thanks for the sample. The problem seems to be that even though your text gets wrapped to a new line, the adorner you inject can still fit on the line before so it wraps up there. The WPF text formatter just sees the intra-text space almost like another word of its own and wraps it with the same logic it uses to wrap words.

I don't think intra-text adornments are good for your scenario. I'd recommend instead that you create a custom editor view margin perhaps just left of the text and render your info there, if you need word wrap support.


Actipro Software Support

Posted 13 years ago by Tino Schnerwitzki
Avatar
Hi,
the problem with the custom editor view margin will be that this margin affects all lines.
I need the special margin only sometimes e.g. if a line (first token in the line) match special conditions.

Any Idea how this can be achieved?

Thanks :)
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Tino,

The three options are:
1) A custom editor view margin, which will affect all lines but will work fine with word wrap. Maybe show limited info here to save on width and show more when mouse hovering over.
2) An intra-text adornment like what you did, however it will be considered a "word" in terms of word wrap and thus flows according to word wrap rules as you saw, which isn't really good for your scenario.
3) An adornment layer that sits behind the text and doesn't affect flow at all. Perhaps after hovering over the adornment some popup appears with more info.

It sounds like #2 is your desired option, and it will probably work fine as long as you disable word wrap, or if you only apply your intra-text spacer at the start of a real document line (ignore the starts of soft-wrapped lines from word wrap).


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.