How to highlight all search words

SyntaxEditor for WPF Forum

Posted 2 months ago by Atsushi Furukawa
Version: 14.2
Avatar

Hello. Let me know if you have any tips or hint on highlighting all search words.

Details:
Syntax Editor WPF Version: v14.2 or v17.2
On SDI Code Editor in sample browser of SyntaxEditor, when I typed Ctrl+I, "using",
all "using" in the Editor are highlighted.
But in our application, it does not happen.

I added "SyntaxEditor.IsIncrementalSearchResultHighlightingEnabled = true;" code, 
the phenomenon was not changed.

Our application calls SyntaxEditor.ActiveView.Searcher.FindNextIncremental, etc. for incremental search.
Is it related to the unavailability of highlight all words?

Does the lauguage definition file (made with Language Designer) have anything to do with it?
Thanks in advance.

[Modified 2 months ago]

Comments (4)

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

It might be that you just need to register the display highlighting styles as described in this documentation topic.  There are special display-related highlighting styles that can be registered by that class, and one of them (FindMatchHighlight) is for highlighting search results.  Please let us know if that solves the problem.


Actipro Software Support

Posted 2 months ago by Atsushi Furukawa
Avatar

Hello, 
Thank you for your support.
I added to the language difinition file as follows, then all search words are colored by foreground: black, background: white.

<LanguageDefinition.ClassificationTypes>
...
<ClassificationType Key="FindMatchHighlight" DefaultStyle=",,,#FFF6BA51" />

The color specification does not appear to be valid.
Is the above definition correct?
(Should I add codes to specify the background color?)

[Modified 2 months ago]

Answer - Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

You should not update the language definition XML file by hand.  The Language Designer app is what you want to use to edit .langproj files and it will output .langdef files to load into SyntaxEditor.  Also of note, the classification types in those language files are only for the syntax language and not for general display usage.

Instead, you'd want to register all default display-related classification types and highlighting styles at app startup.  Then you could further customize the style.  Here's a full code example:

var displayClassificationTypes = new DisplayItemClassificationTypeProvider();
displayClassificationTypes.RegisterAll();
			
AmbientHighlightingStyleRegistry.Instance.Register(displayClassificationTypes.FindMatchHighlight,
	new HighlightingStyle(Colors.White, Colors.Red), overwriteExisting: true);


Actipro Software Support

Posted 2 months ago by Atsushi Furukawa
Avatar

Hello,
Thank you for your support.
Now we are able to highlight specific words in our application.
(AmbientHighlightingStyleRegistry.Instance.Register is called in static constructor in the AdornmentsHighlightWord sample project.
On the other hand, in our application, it is necessary to call it in non-static constructor in a class.)

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

Add Comment

Please log in to a validated account to post comments.