Highlighting Style Viewer with multiple languages

SyntaxEditor for Windows Forms Forum

Posted 13 days ago by Brittney R
Version: 24.1.0
Avatar

I'm currently in the process of updating a couple text editor tools with the Syntax Editor control from 18.1.342.0 to 24.1.0. Looking at your Highlighting Style Viewer QuickStart example, how would one go about organizing this for more than one language (some custom SyntaxLanguages and others langdef files) and only show the classification types of a selected specified language? With the 18.1.342 build, this was switching between the different SyntaxLanguages to load the HighlightingStyles. I'm not sure how to accomplish this in 24.1.0.

Not sure if this matters, but at the moment, my custom languages' ClassificationTypes are being registered to the AmbientHighlightingStyleRegistry.Instance. Should these be in their own custom HighlightingStyleRegistry?





Comments (1)

Posted 12 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Brittney,

If you want to have distinct colors for your different languages then you would need to use a separate HighlightingStyleRegistry for each language.  The Highlighting Style Viewer QuickStart, for example, uses a distinct registry for the Console.  You could do something similar for each language and just never use the AmbientHighlightingStyleRegistry.

The AmbientHighlightingStyleRegistry is convenient when you want everything to generally look the same for each language.  This is similar to how Visual Studio works where most languages have the same colors for string, comment, etc.  If you want one language to be different than the rest while using the AmbientHighlightingStyleRegistry then you have to use distinct keys for the language that should be different.  For example, Visual Studio has a "String" classification type that most languages use, but also a "SQL String" classification type just for SQL.

One thing to consider with separate registries per language is that some classification types are not language-specific, like "Current Line", "Delimiter Matching", and "Line Numbers".  If you allow the user to change these values, you probably want to synchronize the changes across all your registries.

Since maintaining and sycnrhonizing separate registries does have a lot of overhead, another option to consider would be to use the AmbientHighlightingStyleRegistry, but then filter which classification types you show on a per-language basis.  This would help if, for instance, you didn't want to show classification types that didn't apply to that language.  You'd just have to manually maintain a list of what is or isn't shown based on the language selection.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.