Background-highlighting all string tokens equal to selected

SyntaxEditor for Windows Forms Forum

Posted 3 years ago by YEVGENIY A GRIGORYEV
Version: 20.1.0403
Avatar

In the previous version our users relied on the following behavior:

Double-clicking a language token (we are using C#), such as a variable name would background-highlight all instances of the string in the editor.

The behavior is apparently not present in 2020.1

Is there a way to restore this behavior?

Comments (3)

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

Hello,

That sounds like custom functionality your team may have built into usage of the older version.  Did you use span indicators in the old version to accomplish that?

You can achieve background highlighting using a classification tagger in the new version.  You effectively "tag" (mark) a text range using a certain classification type.  That classification type is registered with the ambient highlighting style registry to have a related highlighting style that has a background color.  The "Adornments - Highlight Word" QuickStart is a good example of using a classification tagger to highlight text ranges.

We also have another QuickStart added in the upcoming version called "Adornments - Highlight Ranges" where it shows how you can select a range and press a button to add a background highlight over that range.  That's effectively what you'd want to do here, but over the text ranges that your variable falls on.


Actipro Software Support

Posted 3 years ago by YEVGENIY A GRIGORYEV
Avatar

Thank you, we will check deeper in what made it work.

Posted 3 years ago by YEVGENIY A GRIGORYEV
Avatar

Thanks again for the leads, yes, it turns out, we were indeed using span indicators in the previous version after selection changed event.

Following your recommendation, in the new version, we are able to extend TaggerBase and register it as a TextViewTaggerProverder, tapping the same .SelectionChanged event.

We are using .GetCurrentWordText for the "gray" single click select and .SelectedText for the "light blue" select following double-click to preserve this for our users that are used to double-clicking.

thanks.

The latest build of this product (v24.1.0) 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.