SyntaxEditor Manual Syntax Highlight

SyntaxEditor for WPF Forum

Posted 2 years ago by Gergely Bacsó
Version: 17.2.0661
Avatar

How is it possible to do manual syntax highlight in SyntaxEditor?
For example chars from index 4 to 10 should be blue and bold, and so on?

Thank you,
Gergely

Comments (9)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Our control is geared to be a code editor and have the styles be based on lexing/tokenization of the text.  While we do support classifications of various text ranges to override default token-based styles and to apply custom styles over those ranges, it's not geared for heavy usage.  It sounds like you might rather be looking for a general RichTextBox instead if you are trying to manually color all the ranges yourself and don't do it based on pattern-matching/lexing.


Actipro Software Support

Posted 2 years ago by Gergely Bacsó
Avatar

Hi,

do you maybe have then a RichTextBox in which the user can't change the formatting (given by the application) with keyboard shortcuts, etc.?
can also outlining be applied to that?

Thank you

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

No but there is a native RichTextBox in WPF you could set as read-only.  It wouldn't have built-in code outlining though.


Actipro Software Support

Posted 2 years ago by Gergely Bacsó
Avatar

Hi,

I like the style of your code/text editor very much. So it looks like the easier way for me is to duplicate my ANTLR grammar and write it the Actipro way too (and keep the two grammars synchronized...), rather than to try to build an own code editor from a basic WPF RichTextBox.

Do you maybe have some advice or some automation tool to keep ANTLR and Actipro grammars in sync? (Or generate an Actipro langdef from ANTLR?)

Thanks

Answer - Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

If you have a code-oriented language, you could build a lexer from our tools to accomplish basic syntax highlighting.  And you could make a custom IParser service that just wraps a call to your ANTLR grammar parser.  That way you could call your existing ANTLR grammar parser asynchronously (via a worker thread in our parse request dispatcher) any time text changes.  You just couldn't use those results to do syntax highlighting.  But they'd be available in the document's ParseData property each time parsing completes for other examination purposes.


Actipro Software Support

Posted 2 years ago by Gergely Bacsó
Avatar

That would be good, but the problem is that I need the parser as well for syntax highlighting, I can't just rely on the lexer. ...or syntax highlighting won't be very good...

Posted 2 years ago by Gergely Bacsó
Avatar

...or maybe I do a mixture by doing basic syntax highlighting with the lexer defined the Actipro way, and do the additional highlighting with the help of the ANTLR AST.

So this leads back to the original question: how can I manually format the text in the code editor? (Let's suppose I won't use it heavily...)

Answer - Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

The "SyntaxEditor / User Interface Features / Adornment Features / Syntax Highlighting" topic talks a bit about this.  You effectively make a classification tagger with related styles registered in the ambient highlighting style registry, and have to tag the ranges you want custom highlighting on.  A number of the Adornments samples show use of this kind of feature too.


Actipro Software Support

Posted 2 years ago by Gergely Bacsó
Avatar

Hello,

thank you, this is what I was looking for!

The latest build of this product (v2019.1 build 0683) 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.