• Products
  • Download
  • Purchase
  • Support
  • Company
Actipro Software company logo
Twitter Follow Actipro RSS Subscribe (RSS Feed)

The Actipro Blog

Tag Cloud

  • aero
  • blog
  • docking
  • editors
  • gauge
  • intelliprompt
  • navigation
  • propertygrid
  • ribbon
  • shared library
  • silverlight
  • syntaxeditor
  • themes
  • views
  • winforms
  • wpf

Latest Twitter News

November 21, 2011 at 11:14 AM
#WPF Studio 2011.2 is out now! Includes enhanced themes for native WPF conrtols and new SyntaxEditor features. http://t.co/uEMCaGPG

September 26, 2011 at 1:25 PM
If you'd like to see our #WPF / #Silverlight SyntaxEditor code editor control ported to Metro, provide feedback here: http://t.co/xXBNIDTi

September 15, 2011 at 8:31 PM
If you want to see SyntaxEditor eventually show up in Win8's #xaml UI, be sure to add your support to this MS thread: http://t.co/FBjz6TuC

August 15, 2011 at 1:47 PM
New SyntaxEditor IntelliPrompt parameter info feature docs/samples ready for the 2011.2 #WPF and #Silverlight releases. http://t.co/ezoYIjv

August 2, 2011 at 2:40 PM
First look at new automated IntelliPrompt parameter info coming to our C#/VB editor control in #WPF / #Silverlight http://t.co/CUz6O1T

Twitter Follow us on Twitter

Month List

  • 2012
    • February (3)
    • January (2)
  • 2011
    • December (2)
    • November (7)
    • October (2)
    • September (1)
    • August (5)
    • July (3)
    • June (6)
    • May (5)
    • April (8)
    • March (4)
    • February (5)
    • January (9)
  • 2010
    • December (9)
    • November (10)
    • October (4)
    • September (8)
    • August (12)
    • July (9)
    • June (7)
    • May (6)
    • April (7)
    • March (6)
    • February (6)
    • January (4)
  • 2009
    • December (2)
    • November (2)
    • October (12)
    • September (3)
    • August (11)
    • July (10)
    • June (6)
    • May (3)
    • April (7)
    • March (6)
    • February (8)
    • January (10)
  • 2008
    • December (10)
    • November (2)
    • October (3)
    • September (5)
    • August (5)
    • July (8)
    • June (4)
    • May (4)
    • April (10)
    • March (8)
    • February (1)
    • January (2)

Category List

  • RSS feed for ActiproActipro (289)
  • RSS feed for Blog SummaryBlog Summary (13)
  • RSS feed for GeneralGeneral (34)
  • RSS feed for In developmentIn development (150)
  • RSS feed for New featuresNew features (140)
  • RSS feed for New productNew product (30)
  • RSS feed for PromotionPromotion (2)
  • RSS feed for SilverlightSilverlight (71)
  • RSS feed for Tips and tricksTips and tricks (4)
  • RSS feed for Visual Studio 2008Visual Studio 2008 (2)
  • RSS feed for Windows FormsWindows Forms (20)
  • RSS feed for Windows VistaWindows Vista (10)
  • RSS feed for WPFWPF (235)
  • RSS feed for XAMLXAML (23)

About Us

Actipro Software is a leading provider of .NET user interface controls for the WPF, Silverlight, and WinForms frameworks, and is most well-known for their SyntaxEditor syntax-highlighting code editor control.

Please take some time to learn more about us and our product offerings.

SyntaxEditor for WPF - Snapshot translation

December 15, 2008 at 1:48 AM
by Bill Henning (Actipro)

In this post I’d like to talk about an exciting new feature we’ve recently implemented in our SyntaxEditor for WPF codebase.  Again, we haven’t released the product yet but there is a lot of interest in it so I’ve been trying to post on some of the things we’re working on.  Everything discussed here is part of our next generation text/parsing model, which we eventually plan on making available to SyntaxEditor for WinForms too.

Be warned, this post gets a bit technical and is really meant for all the SyntaxEditor geeks out there! :)

Feature Overview

A snapshot of a document provides an immutable read-only representation of the document at a certain time.  The document always references the most current snapshot.

However say you start some time-consuming parsing on the most current snapshot, which we'll call snapshot 1.  While the parsing is executing, more text changes in the document are made, bringing us to what we'll call snapshot 2.  Then assume snapshot 1's parsing completes and returns an AST of the document.  All the offsets for the AST are based on the text found in snapshot 1.  Since snapshot 2 is the the most current snapshot, the offsets for the AST are most likely incorrect since they were not based on snapshot 2.

SyntaxEditor can translate offsets from one snapshot to another, taking any text changes into account.  So if we wanted to jump directly to a class name, whose offset we know from the AST based on snapshot 1, we can translate the offset from snapshot 1 to the current snapshot (snapshot 2), and move the caret right to the translated offset.

A QuickStart Example

Let’s walk through a QuickStart to show off this feature.  In this QuickStart we have two SyntaxEditor controls.  They both start off with the same document text, however they are separate documents.  The upper editor is read-only and just shows the original contents of both editors.  The lower editor can be modified.

SnapshotTranslation

The snapshot translation QuickStart

Both documents initially contain what is visible in the screenshot above in the upper editor, which is class declarations for MyClassA and MyClassB.  In the lower editor we deleted the MyClassA declaration.  Note the yellow line modification mark in the selection margin where our change was made.

Now back in the upper editor, we highlight the word MyClassB.  Then we click the Translate Selection button.  This takes any text changes that have been made since the original text was set, and translates the offsets of the upper editor’s selection to where the same offsets should now be in the lower editor.

The result is in the screenshot, where it highlights the lower editor’s MyClassB text.  If there was not translation mechanism in place, the selection would have been incorrectly made somewhere in the comment area of the lower editor instead.

Real-World Examples

Here are two real-word examples of using this sort of feature.

The first is based on the overview at the start of this post.  Say you have an AST that you generate based on one snapshot, and you use the resulting AST to render a TreeView containing the document outline.  A common feature is to allow double-clicking on a TreeView node to jump right the related declaration in code.  However considering that the TreeView is generally not in sync with the editor due to typing, etc., in the past it’s been a problem to ensure that we move the caret to the right spot.  With the use of the SyntaxEditor snapshot translation feature, we can almost always go to the correct spot, the only exception being if a text change has been made over the target offset after the time that the TreeView’s snapshot was taken.  However even in that case, the end result is still close.

The second example is find/replace results.  Say you do a replace all operation on a document and list the replace locations in a ListBox.  You could store the snapshot made after each replace in the related ListBox items.  This would allow you to move directly to the replaced text on double-clicks, even after multiple edits have been made following the replace all operation.

Conclusion

I hope that by illustrating this example you can see the power that this mechanism provides.  It will help ensure consistency for the end user’s point of view when making a lot of changes and dealing with find/replace results, AST-related operations, etc.

These sort of things are just some of the core enhancements we’re working on for the design of SyntaxEditor for WPF.  More to come!

Tags: wpf, syntaxeditor
Filed under: Actipro, In development, WPF
Submit to DotNetKicks...
Permalink | Comments (0)

Related posts

Actipro SyntaxEditor for WPF and Editors for WPF are released SyntaxEditor for WPF with a custom theme loaded Yesterday evening we published WP...SyntaxEditor for WPF update in latest WPF Studio build 502 releaseIn a couple past blog posts, we talked about how as of build 501, syntax languages implemented the s...Themes for WPF Part 1 - Native WPF Control Themes In prior blog posts, we’ve detailed some of the great new features coming to the WPF SyntaxEditor ...
Comments are closed
Copyright © 1999-2012 Actipro Software LLC. All rights reserved.
Home Actipro Software | Products | Download | Contact Us