Hilighting invalid tokens

SyntaxEditor for Windows Forms Forum

Posted 13 years ago by troy tarrant
Avatar
Hi,

Is it possible to hilight invalid lexical tokens with an red/green squiggle underline in a similar fashion to Word ?

Cheers

Troy

Comments (5)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Troy,

Yes, you can. You use span indicators to do that. Basically you just add a span indicator that inherits from SquiggleLineIndicator to your document. We have some built-in samples like SpellingErrorIndicator, CompilerErrorIndicator, etc.

So you end up doing something like this for a compiler error starting at offset 1 and going for 5 characters in length:
editor.Document.Indicators.Add(new CompilerErrorIndicator(), 1, 5);


Actipro Software Support

Posted 13 years ago by troy tarrant
Avatar
Thanks... should've looked in the class library for squiggle... and presumably (couldn't see it at quick glance) there is an event where you can trap the hover over an indicator so you can provide a hover text pop up ???

Cheers

Troy
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes you can handle TokenMouseHover and then in that, call the editor.Document.Indicators.GetSpanIndicatorForOffset method (pass it the offset of the token) to get the span indicators over that token. Then in the event arguments pass an e.ToolTipText back. It uses our formatting tags too so it will support bold, italics, etc.


Actipro Software Support

Posted 13 years ago by Jean Versailles
Avatar
As I type an xml token in the editor, I want the editor to detect the invalid xml token base on a schema and use the squiggle line to under the invalid token.

If I want the editor to automatically underline the errors with the Squiggle Line what event should I use?

Do you have an example?

The LanguageDefinitionBuilder that comes with the ActiproSoftware Control does not show the Squiggle Line Indicator.

jen0s
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
We don't have a specific example for that. We do have the example where it will mark tags that don't match the schema when you press a button. I believe I mentioned that in this post:
http://www.actiprosoftware.com/Support/Forums/ViewForumTopic.aspx?ForumTopicID=1313

If you follow the steps in that post you can see squiggles used to show where the error is.

However again that is not happening dynamically as you type like what you want. You'd have to do some parsing after the tokens have been created for the feature you want. I'd recommend creating a semantic parser that inherits from SemanticParser and in the PostParse method, look over the modified range for malformed tags. If you find any, add the squiggle span indicators to mark them.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.