Recolor tokens at runtime?

SyntaxEditor for Windows Forms Forum

Posted 8 years ago by David
Avatar
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.

Thanks.

Comments (3)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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 8 years ago by David
Avatar
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 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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 (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.