How to "pause" lexical parsing?

SyntaxEditor for Windows Forms Forum

Posted 12 years ago by Jeff Cohen
Version: 4.0.0239
Avatar
I've defined a few keypress triggers in my dynamic xml file, and I'm handling the TriggerActivated event. I'm just trying to add a matching character when the user types an initial double-quote (or single quote, etc.).

When the user types the first quote, for a moment all the text after it turns red because the lexer realizes that everything that follows is now in a child "string" state (whose style dictates that the text color should be red).

When my code inserts the second quote, all goes back to normal. But the momentary flash is unfortunate.

I've tried to wrap my insertion code with:

editor.Document.LexicalParsingEnabled = false;
editor.Document.SemanticParsingEnabled = false

... insert closing quote here ...

editor.Document.LexicalParsingEnabled = true;
editor.Document.SemanticParsingEnabled = true;

but this didn't help at all.

What's the right way to "pause" the parsing while I'm programmatically changing the text?

Or, maybe using triggers was the wrong idea in the first place?

Thanks!
Jeff

Comments (4)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Turning off lexical parsing like that is bad because when you re-enable it you will be triggering a complete document reparse.

What you might be able to do is in the KeyTyping event, call Document.SuspendParsing and then in KeyTyped call Document.ResumeParsing when your quote key is pressed. Just insert your other quote before you resume parsing.

Hope that helps.


Actipro Software Support

Posted 12 years ago by Jeff Cohen
Avatar
I don't see any properties or methods called SuspendParsing or ResumeParsing on the Document class. I also did a search in the online help file that didn't turn up anthing for those names.
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You're right... my apologies. I looked at the code and while we do have them, they are currently internal. We'd have to look into the impact of making those public before actually doing that because they might cause issues if used inappropriately.


Actipro Software Support

Posted 12 years ago by Jeff Cohen
Avatar
No problem :-) I can probably work around it for now.

Thanks again.
The latest build of this product (v2018.1 build 0341) was released 6 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.