Bracket/Delimiter color in Textbox

SyntaxEditor for Windows Forms Forum

The latest build of this product (v21.1.1) was released 16 days ago, which was before this thread was created.
Posted 11 days ago by Suraj
Version: 13.1.1
Avatar

Hi

I want to know if there is a possibility to change the color of braces used in the textbox of the SyntaxEditor?

For example, if i type -- one(two(three))

then first set of brackets enclosing "two(three)" have a different colors than the other set enclosing word "three"?

Comments (3)

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

Hello,

In general, the lexer is what tokenizes text and then those tokens end up determining what highlighting style gets applied.  It seems like you want to apply alternate highlighting styles based on the parentheses' nesting level. 

One thing you could try is if you are using a dynamic lexer, have a default lexical state that has a child lexical state whose scope start/stop tokens are parentheses.  Apply a base highlighting style to those parenthesis.  Then have that child lexical state match all of the same lexical patterns as in the default lexical state and have it also have another child lexical state whose scope start/stop tokens are again parenthesis.  But for this set of parenthesis, assign alternate tokens and an alternate highlighting style to them.  You could also even have the child lexcial state of that scope be the original default lexical state.  That way the parenthesis would appear to alternate colors based on nesting level.


Actipro Software Support

Posted 10 days ago by Suraj
Avatar

Hey
Thanks for responding.

I am new to this and your answer is a bit difficult to understand for me. Maybe you could share some example code?

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

Hello,

The method to accomplish it is a bit complex and can be done in various ways, depending on how the lexer in your syntax language is constructed.  I'd probably suggest you make a new simple sample project that shows a SyntaxEditor on a Form with your syntax language active and send that to our support address, mentioning this thread in your email.  Be sure to exclude the bin/obj folders from the .zip you send, so it doesn't get spam blocked.  Then we can have a look at that and tell you how to modify things.  And in your email, also confirm the exact version you are using.  Thanks!


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.