We’re sad to be ending SyntaxEditor “completion list” blog post week today. :) There’s been a lot of good information presented on the upcoming features for SyntaxEditor for WPF.
To recap, we had these related posts:
For the final post in this series, I’d like to talk about options for how text is auto-completed upon a completion list selection.
The screens below are taken from the QuickStart we have on this topic.
The simple way
Normally the text displayed in the completion list for an item is the same text that is inserted. That is what happens by default.
However SyntaxEditor has the ability to insert alternate text both before and after the caret. Several variations are shown in the following sections.
Alternate text inserted before the caret
In this sample, we have a br tag. It shows br in the list but when it auto-completes, it inserts <br/> into the document.
|

A br tag before and after it is inserted from the completion list
|
Note that the caret is moved after the inserted text.
Alternate text inserted to surround the caret
In this sample, we have a comment. It shows !-- in the list but when it auto-completes, it inserts <!-- --> into the document.
|

A br tag before and after it is inserted from the completion list
|
Note that the caret is automatically moved within the comment’s delimiters following insertion.
This is another similar example. For the hyperlink, it shows a in the list but when it auto-completes, it inserts <a href=”” into the document.
|

A br tag before and after it is inserted from the completion list
|
Again the caret is automatically moved, but this time to within the href attribute value.
With the SyntaxEditor completion object model, you have total control over what is inserted and where the caret moves. It’s very easy to set up.
Allowed characters
One other thing I’d like to discuss while showing these samples is the topic of allowed characters. By default, only letters, digits, and underscores are allowed characters. If you type any other character while a completion list is open, it will either auto-complete or cancel depending on whether you have a full selection in the list or not.
SyntaxEditor lets you customize the allowed characters. For this QuickStart we added the ! and - characters as allowed characters so that comments can be typed.
Enjoy the weekend. We will get into some new feature areas soon!