Recolor tokens at runtime?

SyntaxEditor for Windows Forms Forum

Posted 11 years ago by David
Hi, just a quick question, is it possible to apply a highlighting style to a token at runtime, using a programmed lexer?

E.g. colouring keywords in a language when they are defined as a new type.

I know you can do this in a dynamic XML lexer, by defining a pattern group with a given style, and then adding tokens to that group at runtime.

Was just wondering how this would be done (if possible) for a custom written lexer.


Comments (3)

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

The style used usually comes from the token's HighlightingStyle property, which by default returns the style based what was set in the lexer setup. So you could alter that property's result if you needed to. Use of a custom token class might make that easier.

In the newer WPF/Silverlight SyntaxEditor object model, we allow custom ranges to be tagged completely separately from the tokens and those tagged ranges have the ability to override the coloring used by text in the ranges. That sort of design is a bit cleaner than what is in WinForms right now. We hope to eventually port that design back to WinForms.

Actipro Software Support

Posted 10 years ago by David
Thanks for the reply.

The WPF/Silverlight framework has a lot of nice new design frameworks. I'm especially eager to use the ANTLR parser framework. Do you have an estimate to when winforms will get all these features?
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Hi David,

You are correct, the WPF/Silverlight implementations of SyntaxEditor overall have much nicer object models and more advanced features available since we built it from scratch from years of experience in building code editors. WPF/Silverlight is still is missing some features that are in the WinForms SyntaxEditor. We are in the process of enhancing the .NET Languages Add-on and core SyntaxEditor control there so that it covers all the feature areas found in WinForms. Then we hope to port back our newer designs to WinForms. Sorry but we can't give a timeframe right now. We're working as fast as we can on it, but since we're trying to innovate and improve as we port feature areas over, it takes a bit longer. In the end a better product is created though.

Actipro Software Support

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