How to toggle Syntax highlighting state

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by James Deadman
Version: 4.0.0282
Avatar
Hello,

I would like to ask a couple of questions please regarding Syntax Highlighting and Outlining.

1. Is it possible to turn syntax highlighting on/off for a file without necessarily changing its syntax language to be PlainText? Essentially we want our users to be able to toggle it on and off (via the GUI) and so wondered if there was a straight-forward way to do this please?

2. For the PlainText syntax language, is there any benefit to setting Outlining to be Automatic rather than to None? I have tried simple text operations (e.g. selection) in both cases and couldnt see a difference.

Thanks,
James

Comments (9)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi James,

1) You can toggle Document.LexicalParsingEnabled. That should enable/disable syntax highlighting.

2) For languages that don't use outlining features (like plaintext), the outlining setting shouldn't make a difference between Auto and None.


Actipro Software Support

Posted 15 years ago by James Deadman
Avatar
Hi,

Thanks for your help with my queries.

For the syntax highlighting toggle i'll try the LexicalParsingEnabled attribute as you suggest. Would turning this attribute off affect any other features such as bookmarks, line modification markers, etc. please?

Thanks,
James
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
No it shouldn't affect indicators.


Actipro Software Support

Posted 15 years ago by James Deadman
Avatar
Okay thats great. Thanks again for your help.
Posted 11 years ago by Jon Heaton
Avatar

Is there a way to disable syntax highlighting while allowing intelliprompt without setting all of the styles to black?  I need to be able to disable intelliprompt and highlighting separately at runtime.

[Modified 11 years ago]

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

Hi Jon,

Setting Document.LexicalParsingEnabled to false may still allow IntelliPrompt.  It does for our .NET Languages Add-on.


Actipro Software Support

Posted 11 years ago by Michael Dempsey - Sr. Developer, Teradata Corp
Avatar

In my case I ONLY want to turn off the colors - I still need to programatically use the parser.

If I set Document.LexicalParsingEnabled=False I assume I will not be able to use the parser. Correct?

If that is so is my only choice to spin through all the styles and set them all to the same color?

Thanks 

Posted 11 years ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

That or make a switch in the GetHighlightingStyle() method in your language.

public override HighlightingStyle GetHighlightingStyle(IToken token)
{
  if (DisableColors)
    return this.HighlightingStyles["DefaultStyle"];
  else
  {
    // implement default behavior
  }
}

[Modified 11 years ago]


Best regards, Tobias Lingemann.

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

I think parsers make their own instance of a lexer so you are probably ok doing this.  But if not, you are correct, doing what Tobias said or changing the styles would be the fallback.


Actipro Software Support

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.