Tweets by @Actipro
Please take some time to learn more about us and our product offerings.
As seen in yesterday's post, delimiter (bracket) highlighting is coming to the WPF and Silverlight SyntaxEditor controls in the 2012.2 version (due very soon).
A new language service that was described yesterday was a structure matcher service. This allows delimiter sets to be located. When one of these is registered on a language, SyntaxEditor automatically gains a new feature: move/select to matching bracket.
UPDATE: Version 2012.2 is live and available for download now.
Let's take a look at how this all works. Say we have this scenario in SyntaxEditor where the caret is next to a parenthesis.
Notice that the bracket highlight is not visible because the caret is on the inside of the parenthesis and the highlights for this language are told to only show when the caret is on the outside of a parenthesis.
Now we press Ctrl+Shift+] and voila, the structure matcher returns the nearby delimiters to SyntaxEditor, and the full delimiter range is selected.
So you may be asking, how did that work, when delimiter highlighting didn't register the parenthesis as a valid delimiter? We designed the structure matcher so that an option can be passed asking it to be more liberal in its matching algorithms. So while the delimiter highlighting matching logic for a language may have very specific locations a match can occur, other features like move/select to matching bracket can find matches that are anywhere next to the caret.
On a side note, the hotkeys for moving (Ctrl+]) and selecting (Ctrl+Shift+]) to the matching bracket only work in WPF since Silverlight doesn't allow us to watch for that key sequence being pressed. However you can still provide this functionality to customers via a menu item in Silverlight.
Move and select to matching bracket is some handy functionality when editing code blocks. We're excited to offer it in the 2012.2 version.
September 13, 2012 at 21:10
Hi Bill,Ctrl+Shift+]doesn't work for me per default in your 'syntax editor SDI Code Editor' sample nor in my application.do i have to specify something additional??implement a 'structure matcher service'?g Helmut
September 14, 2012 at 01:23
As noted above, that key sequence won't work in Silverlight. But in WPF it should work in languages that support the structure matcher out of the box. So in WPF it works by default with our C#/VB languages from the .NET Languages Add-on. I just tried it.
Bill Henning (Actipro)
September 14, 2012 at 01:31
Hi Bill - only WPF and C# for me It doesn't work at my pc.i downloaded the new 2012_2 edition.Start the Samples Browsergo to 'Syntax Editor'start the 'Updated 'SDI code editor'.Klick 'run external Code'go to line public static void Main(string args)place the cursor before the last bracket. args***CURSOR_HERE***)press CTRL SHIFT ] (on my keyboard this means press the ')9]' keyand nothing happens.
September 14, 2012 at 01:53
I just did the same and it worked fine. It must be the keyboard shortcut that is causing you problems due to culture differences. Just so you know, our default shortcut is defined like this, so you can change it as needed in the SyntaxEditor.InputBindings collection:
this.InputBindings.Add(new KeyBinding(EditorCommands.SelectToMatchingBracket, Key.OemCloseBrackets, ModifierKeys.Control | ModifierKeys.Shift));
September 14, 2012 at 02:12
Hi Bill,THX again this.InputBindings.Add(new KeyBinding(EditorCommands.SelectToMatchingBracket,Key.D9, ModifierKeys.Control | ModifierKeys.Shift));Now does the thing similar to yours BTW: on my keyboard i have to press ALT and the ')9]' Key to get an ']'.normally pressing ths key gives a '9'But the combination CTRLSHIFTALT')9]'-Key didn't work either - no idea how i could get the Key.OemCloseBrackets without an 'ALT' ...
October 1, 2012 at 02:15
Actipro Blog 2012 Q3 Posting Summary
Actipro Blog 2012 Q3 Posting Summary
The Actipro Blog - WPF, WinRT XAML, Silverlight, and WinForms Development