Squiggle lines on-demand

SyntaxEditor for WPF Forum

Posted 12 years ago by Kasper
Version: 11.2.0551
Avatar
Hi guys,

In my application, I would like to show the issues found during validation by adding squiggle lines under the problematic keywords etc. The validation process is not a part of the SyntaxEditor control, so I'm having a bit of trouble migrating your samples to my situation, since they pretty much all seems to rely on a class that can inspect the text of the SyntaxEditor and then add adornments as needed. I would like to add and remove squiggle lines when my validation has occurred, which happens on various occasions. I guess I'm looking for a more manual and external approach than the one you use in your samples, for adding squiggle lines. What's the best and easiest way to do that?

Comments (7)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Kasper,

The way adornments work is that as a view is going to render a line, it asks for any tags over that line's range that would trigger an adornment to be rendered. If you set up a collection tagger (look for CollectionTagger in the samples) you can simply add/remove tagged ranges to that when your validation is done, like:
using (IDisposable batch = collectionTagger.CreateBatch()) {
    collectionTagger.Clear();
    // Add ranges from your validation results here
}
After that code executes, it should trigger SyntaxEditor to render those lines again since you are indicating that the visuals changed.


Actipro Software Support

Posted 12 years ago by Kasper
Avatar
I'm sorry, but would it be possible for you to provide me with just a bit more details on how to do this? The code sample you have provided doesn't make much sense to me out of context, and I'm not sure where to look for the CollectionTagger. As far as I can tell, you only use it in the IntraTextNoteTagger sample, and while that sample is kinda what I need, I would like to use the built-in squiggle instead of creating one myself.

What I really want to know, is what I should call/do, once my validation is done and I'm ready to add and remove squiggles. I imagine that the easiest way would be to remove them all each time a validation is done and then re-add the ones I still need, but perhaps I'm wrong there. Either way, I would really appreciate a more detailed suggestion on how to do this :)
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Kasper,

Take a look at the AdornmentsSquigglesIntro QuickStart as that shows you how to use our built-in squiggle adornments (you effectively just return tags that implement ISquiggleTag). That sample uses a custom tagger that inherits TaggerBase<ISquiggleTag> but in your case you'd want to use a CollectionTagger<ISquiggleTag> instead per what I described above.

When validation is done, I'd probably recommend doing the code snippet in my preview post to clear and re-add them all in a single batch.


Actipro Software Support

Posted 12 years ago by Kasper
Avatar
Hi,

>Take a look at the AdornmentsSquigglesIntro QuickStart as that shows you how to use our built-in squiggle adornments (you effectively just return tags that implement ISquiggleTag).

Yes, but the difference, as I see it, is that the information about what to underline comes from within the class and not from the outside. I'm still not sure how to add "tags" from outside the SyntaxEditor-space, which was also a part of my previous question. I now have a CodeValidationIssueTagger, which inherits CollectionTagger<ISquiggleTag>, but how do I, from my main window, get access to it and add information about what to underline? I have looked into the GetService() method on the Language, but no matter what I do, I can't seem to get an object out that allows me to add stuff to it. So I guess what I really need to know, is how to access AND supply information to the tagger from the outside, which in this situation is my main window, where all the interesting stuff is happening :)

Edit: Okay, judging from the IntraTextNoteTagger demo, I'm supposed to use the Properties collection on the Document, to get my tagger and not the GetService() method on the Language. That wasn't very clear to me, since it's being added with the RegisterService() method :). I guess I just got one step closer!

Edit 2: Yes, once I had access to the CollectionTagger instance from my main window, and realized that there was now actually nothing left for my own Tagger implementation to do, it seems to work!!

[Modified at 01/26/2012 04:39 AM]

[Modified at 01/26/2012 05:04 AM]
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I'm glad you got it working. Yes, there is a tagger provider on the language that will create a new tagger instance for each document instance. That's why you are able to retrieve a document-specific tagger from its properties.


Actipro Software Support

Posted 11 years ago by Pieter Bezuidenhout
Avatar

I have a similar scenario where I need to parse the whole document, which won't be large due to the usage scenario, from the outside as GetTags only returns the current line being edited. How does one get access to the CollectionTagger? Also, where can I specify the parameter that is used in the implementation of TaggerBase<ISquiggleTag>.GetTags?

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Pieter,

The MainControl's code in the AdornmentsIntraTextNotes QuickStart shows how you can retrieve a tagger from the Document Properties.  You'd do that if you are trying to access the tagger to add/remove tags.  The parameter to GetTags can be null.


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.