Comment / Uncomment Commands Disabled

SyntaxEditor for WPF Forum

Posted 14 years ago by Evan
Version: 9.1.0507
Avatar
I'm just starting a new project that relies on the WPF SyntaxEditor for editing scripts that are based on a custom, LISP-based language. The language definition that was set up yesterday seems to be working great, the colors are showing up appropriately, the whole deal; however, the built in CommentLines and UncommentLines in the EditorCommands do not seem to be working (they are disabled when the editor's document is loaded and remain disabled regardless). The other functions, such as Indent, work just fine.

One thing I noticed was that in the sample applications included with the Actipro installer, the same exact problem comes up. If you compile & run the project, open the 'SDI Code Editor' external example, and try commenting / uncommenting in the default C# Add-In language, no problems- it works like a charm. Once you select another language from the 'Language' menu item, however, it's gone. The Comment and Uncomment buttons are disabled and will not ever function.

This may be unrelated, but I thought it worth mentioning. Is there something I ought to be investigating inside of my language definition?

Regards,
Evan

Comments (3)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Evan,

Commenting and uncommenting features are language-specific. So in order for them to be enabled, you need an ILineCommenter service defined on your ISyntaxLanguage. This documentation topic gives you more detail:
"Language Creation Guide - Optional Features (Services) / Line Commenter"

We don't yet have support for line commenters in the language definition files but will be adding that in the future. So if you load your language from a .langdef file, right afterwards you can register an ILineCommenter service on the language instance to get all this working.

We also have a QuickStart showing off line commenters. Be sure to check that out.


Actipro Software Support

Posted 14 years ago by Evan
Avatar
Thank you for your response!

The following lines both work independently:
this.RegisterService<ILineCommenter>(new LineBasedLineCommenter
 { StartDelimiter = ";" });
this.RegisterService<ILineCommenter>(new RangeLineCommenter 
{ StartDelimiter = "/*", EndDelimiter = "*/" });
The problem I'm facing now (which is not nearly so dire- I can live with just single-line commenting for now if need be) is that there doesn't appear to be a way to allow for both range commenting and line-based commenting in the same implementation without a routine that checks the syntax editor's state at runtime and decides which to use at that point. If I register both types of service, the editor (I believe via the GetLineCommenter extension method) just grabs the latter of the two.

Any ideas? Again, thanks for your help.

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

Well those are just two of our implementations for an ILineCommenter. Since our model uses interfaces, you could create your own custom ILineCommenter-implementing class that makes a contextual decision on whether to line- or range-comment. Then maybe have it even call our implementation based on which way you want to go.


Actipro Software Support

The latest build of this product (v24.1.1) 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.