Bracket/Delimiter color in Textbox

SyntaxEditor for Windows Forms Forum

Posted 3 years 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 (4)

Answer - Posted 3 years 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 3 years 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 3 years 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

Posted 2 years ago by Suraj
Avatar

Thanks a lot for your help. With your example above i was able to achieve what i wanted to.

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.