Mark search results when using FindAll

SyntaxEditor for WPF Forum

Posted 9 years ago by Stefan
Version: 11.1.0540
Avatar
Hi,

I implemented a "Find all" search with SyntaxEditor.ActiveView.CurrentSnapshot.FindAll.

But the search results are not marked in the editor like they are marked if I use SyntaxEditor.ActiveView.Searcher.FindNext.

My question now is how I can mark these results? I know that in each search result, I have a snapshot range. So I think I need to highlight somehow these snapshot ranges. How can I do it? (In the WinForms version, I used SyntaxEditor.Document.FindReplace.MarkAll)

Best regards,
Stefan

[Modified at 02/08/2011 07:23 AM]

Comments (4)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Stefan,

You could use classification tags for that in the WPF SyntaxEditor. Check out the AdornmentsIntraTextNotes QuickStart, which actually does a bit more than what you need.

The pieces you want from that are to create a tagger that inherits CollectionTagger<IClassificationTag>. Register the tagger like it does on the language. There is already a pre-defined ClassificationTag class you can use as your tags since it implements IClassificationTag. Just make sure you register a highlighting style for the classification type you use to indicate match results. An example of registering styles is in IntraTextNoteTag.

In MainControl.OnAddNoteButtonClick you can see how to get the tagger and add tag instances to it. You'd basically do that when you do your find all. You'd loop through each snapshot range result and add a tag to the tagger for it. The tagger will take care of moving the ranges around as the user does edits after that. Then later just clear the tags from the tagger when you want them to disappear.

Hope that helps!


Actipro Software Support

Posted 9 years ago by Stefan
Avatar
Thank you again,

it is working fine!

Best regards,
Stefan
Posted 9 years ago by Stefan
Avatar
Hello,

I now have the problem that a special adornment (a grey rectangle for the first and last line) overlaps the tag highlighting. As a result, all search results in the first and last line are not highlighted.

Can I somehow "merge" the highlighting, or is there a way to draw my tag highlighting over the adornment?

Best regards,
Stefan
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Stefan,

When you create AdornmentLayerDefinition objects for your adornment managers, you can set Orderings in there where you say what it should be before/after. Thus you can order things properly with that.

Note that we found a bug with the ordering logic on our end that if you use multiple adornment layers, things may not sort completely right. You may have to specify an Ordering relative to each built-in layer to work around the bug. The documentation on adornments lists the built-in layers.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.