The next release of SyntaxEditor for WPF, part of WPF Studio 2009.2, has a lot of major new functionality added. A significant chunk of that deals with the addition of new text tagging and adornment layer frameworks.
What you can do to help
We’re looking for some existing SyntaxEditor for WPF customers who would like to get their hands on the latest code before it is publicly released, specifically to help us test out these new tagging and adornment features. We’ll explain below more about what each framework provides.
If you are an existing customer and are interested in testing out the new features, please email our sales team. Again, only do so if you plan on implementing code that uses tagging and/or adornments.
What are text tagging and adornment layers?
Text tagging is the ability to associate some data (a tag) with ranges of text. Our built-in tagging mechanism makes it easy for you to provide tagged ranges both using virtualization and without. An example of text tagging would be to mark certain ranges of text as parse errors. Text tagging is a logical way of marking text, and can also be paired with adornment layers that can provide custom rendering over tagged text areas.
Adornment layers, first described in this post, are a way to render any UIElement within the text area of a SyntaxEditor. Adornments can be ordered and sandwiched between any other adornment layers. As an example, the caret and selection are both adornment layers. The caret has a Rectangle that blinks to render the caret. The selection is a complex Path.
The neat thing about tagging and adornments is that the sky is the limit on what custom rendering you can achieve in the editor. Let’s take a quick look at some of the full source QuickStarts that will be included in the next version, all of which demo tagging and/or adornment layers.
Adornments 1: Smoke Text
The first adornments QuickStart was already mentioned in a previous post, which also included a video of it that shows it’s animations.
Basically, as you type, smoke clouds puff out of where text changes occurred and dissipate away. It’s a very neat demonstration of special effects using animated adornments.
Adornments 2: Squiggles Intro
This QuickStart shows how a tagger for the built-in ISquiggleTag interface can be used to render certain ranges of text with squiggle lines underneath.
Note that each instance of the word Actipro in the text above has squiggle lines below it. Our tagger in this sample scans the text of each rendered line and tags ranges that contain the word Actipro.
The rendering implementation of the squiggle adornments is handled internally by SyntaxEditor code, which automatically watches for ISquiggleTag instances. Therefore all you need is a tagger to provide the functionality above. You have full control over the color used to render the squiggle lines too.
Adornments 3: Custom Decorator
This QuickStart shows the ease in which you can combine taggers with custom adornment managers to achieve decorations around ranges of text.
Just like the previous QuickStart, instances of the text Actipro are tagged, but this time with a custom tag instead of ISquiggleTag. We also add a custom adornment manager class that watches for tagged ranges and adds a “Knight Rider”-ish red animated swoosh that glides back and forth.
Implementation of the adornment manager is actually rather simple due to us wrapping up most of the meat of tag watching, etc. in a handy DecorationAdornmentManagerBase base class for you.
Adornments 4: Highlight Word
This QuickStart uses a tagger that provides IClassificationTag tags. The tagger is created to as view-specific (as opposed to document-specific in other samples) and highlights all the words in the view that match the word at the caret.
In the screenshot, you can see that both instances of the word System are highlighted. IClassificationTag, a built-in tag type that is monitored by SyntaxEditor, allows you to override the rendering style of any text. Thus we could have just as easily changed the foreground of the two System instances to red if we had wished.
Adornments 5: Alternating Rows
This QuickStart shows how to create an alternating row background for all “even” document lines, similar to what you often see in grids.
Notice the subtle gray background on each even line. It updates the adornments automatically as you scroll or type text.
Changes to classifications
In SyntaxEditor 2009.1 we had “classifier” features that worked similarly to the new tagging mechanism but were specifically for classification purposes. In 2009.2, we have switched those features to use the tagging mechanism since it is more generic and can be used for other features too, as seen above. Details on this change and how to convert code (probably just a one line change for impacted customers) will be in the 2009.2 documentation. The highlight word QuickStart described above is a great demonstration of how the old classifier mechanism is now implemented with taggers that return IClassificationTag.
Summary
We’re really excited about these updates as they open up the doors to many new possibilities with the editor. If you would like to help us test them out before they go public, please write our sales team ASAP. Thanks!
By the way, these features are in the Silverlight version of SyntaxEditor too.