SyntaxEditor vNext Multiple Selection Pasting

by Avatar Bill Henning (Actipro) - 2 comments
Thursday, August 2, 2018 at 3:34pm

BlogPostBanner-SyntaxEditor-DevNotes

As mentioned in a previous post, we have been working on refactoring the core internal implementation of our SyntaxEditor code editor control on the WPF, UWP, and WinForms platforms.  This effort (codenamed vNext) is being made to bring all three platforms onto the same codebase for easier updating moving forward, and to enhance features wherever possible.

As described in recent blog posts, we've been working on adding multiple caret/selection support to SyntaxEditor in vNext.  In this post, I'd like to show off a neat new feature related to copying/pasting text when there are multiple selections.

Pasting Demo

At the start of this animation, I do a line copy, which occurs when there is no selection and you press Ctrl+C.  Then I paste that line in three times.

Next I select the text "Actipro," then Ctrl+select the text "SyntaxEditor," and finally Ctrl+select the text "vNext."  The Ctrl+selections have allowed me to create three selections.  At this point I could type and it would replace each of those selections with what I typed.  Instead, I'm going to press Ctrl+C again to copy the selected text.

2018-08-02_11-15-36

When I copy multiple selections, each selection's text is appended together and delimited by a line terminator.  So if you would paste what I copied into Notepad, it would paste as:

Actipro
SyntaxEditor
vNext

In the animation, the next thing I do is put a caret in each of the three empty strings by Ctrl+clicking in them.  We just added some new vNext logic that will compare the number of selections with the number of lines in the pasted text.  When they are equal, as they are in this demo, each line in the pasted text will get pasted into the related selection.  The end result is you can see how each of the three selections I originally copied end up in a separate target selection.

Summary

Multiple caret/selection support touches many portions of the editor and we are continuing to work through updating all feature areas to support it.

Let us know what you think in the comments.

SyntaxEditor vNext Multiple Caret/Selection Progress

by Avatar Bill Henning (Actipro) - 3 comments
Wednesday, July 18, 2018 at 3:56pm

BlogPostBanner-SyntaxEditor-DevNotes

As mentioned in a previous post, we have been working on refactoring the core internal implementation of our SyntaxEditor code editor control on the WPF, UWP, and WinForms platforms.  This effort is being made to bring all three platforms onto the same codebase for easier updating moving forward, and to enhance features wherever possible.

We are continuing development on our SyntaxEditor control, adding many modern features under a unified API design.  One enormous feature area getting added is multiple carets/selections.  We briefly proposed adding this feature several months ago in this blog post to gather feedback.

Now that we've had time to iterate on development of it, I wanted to share a demo so you can see how it works.

Multiple Carets/Selections Demo

In this screen capture animation, we show how SyntaxEditor vNext will support multiple carets/selections.

2018-07-18_11-41-52

I first select a word using my mouse and click/dragging like normal.  Then I select text under it while holding the Ctrl key and click/dragging.  Afterward I notice I accidentally selected too many characters.  I hold Ctrl and click the second selection to collapse it.  Then I hold Ctrl and click/drag to make the correct selection.

Next I hold Ctrl and click in another word to add a third caret.  I remove that same third caret by Ctrl+clicking on it again.  This is a nice feature for when you accidentally add a caret/selection you didn't mean to add.

Finally, edit actions like typing will affect all selections.  You can see in the animation how typing "Foo" affects the two selections.  Pressing Ctrl+Z for undo applies to all the selections.

Summary

Adding multiple caret/selection support is a massive feature area that touches many portions of the product.  While it's taken a while to implement, we're very pleased with the progress thus far and think it will really be exciting for end users.

Let us know what you think of this feature area in the comments.

Interest in SyntaxEditor Multiple Caret/Selection Features?

by Avatar Bill Henning (Actipro) - 9 comments
Tuesday, February 20, 2018 at 4:02pm

BlogPostBanner-SyntaxEditor-DevNotes

As mentioned in a previous post, we have been working on refactoring the core internal implementation of our SyntaxEditor code editor control on the WPF, UWP, and WinForms platforms.  This effort is being made to bring all three platforms onto the same codebase for easier updating moving forward, and to enhance features wherever possible.

As we continue development of SyntaxEditor vNext, we are getting into porting in the caret/selection feature area.  We've seen a couple newer editors support the concept of multiple carets/selections and would like to get some feedback on if this is a desired feature by our customers.  This is different than the rectangular box selection feature we currently already support.

Rectangular Box Selection

Rectangular box selection is already supported in SyntaxEditor and looks like this:

SyntaxEditorBoxSelection

When this selection is active, you can type and it will enter text at the same column on each line.  You can also copy box-selected text and when it's pasted, it will retain the box layout.  This is a very handy and powerful feature.

Multiple Carets/Selections

Now what happens if you want to make multiple updates but not necessarily in the same column.  Let's take a look at a scenario:

SyntaxEditorMultiScenario

In the screenshot above, the caret is next to a Write method call.  Let's say we want to update all the Write method calls to be WriteLine instead.  We could change it once and copy/paste it to the other locations.  But if we had multiple caret support, you could throw a caret at the end of each of the four Write method calls (in various columns) and simply type Line to update all of them.

One implementation of this I saw used Alt+Click to add carets.  I don't personally like this because Alt is used as a system menu accelerator and causes issues like underlines to appear in menus if you Alt+Click

Another implementation of this used Ctrl+Click to add carets.  That seems better since it won't run into the system menu accelerator issue.  The downside is that Ctrl+Click is currently used in SyntaxEditor (and Visual Studio's code editor) to do quick word selection.  Thus we'd need to rework some of our existing keyboard shortcuts to accommodate new features.

Both these implementations also use Ctrl+U as a way to undo the last selection change, whereas SyntaxEditor and VS currently tie that keyboard shortcut to making selected text lowercase.

Summary

Let's hear from you… is the multiple caret/selection feature something you'd like to see?  How would you prefer to see the keyboard shortcuts adjusted to accommodate new features?

SyntaxEditor vNext - Customizing Line Numbers

by Avatar Bill Henning (Actipro)
Tuesday, December 5, 2017 at 5:08pm

BlogPostBanner-SyntaxEditor-DevNotes

As mentioned in a previous post, we have been working on refactoring the core internal implementation of our SyntaxEditor code editor control on the WPF, UWP, and WinForms platforms.  This effort is being made to bring all three platforms onto the same codebase for easier updating moving forward, and to enhance features wherever possible.

In the previous SyntaxEditor vNext post, we showed some massive improvements in SyntaxEditor touch interaction, including inertia-based touch scrolling and pinch-to-zoom features.  In today's post, we'll examine a new feature area that allows you to customize the line numbers displayed in each view's line number margin.

Default Behavior

By default, a view's line number margin displays the line number (document line index plus one) for each view line.  If a view line is a wrapped line, nothing appears for that view line in the margin.

SyntaxEditorLineNumbersDefault

In vNext, several new features are being added to support customization of the line number display.

Document Fragment Scenario

One scenario where line number customization is appropriate is when you have an enormous file and only want SyntaxEditor to show a fragment of it, such as several thousand lines.  In this scenario, you might make a document with lines 10,000-20,000 in it.  The first line in SyntaxEditor is really line 10,000 in the file, but it normally shows as line #1 in the line number margin.  This can be confusing to the end user.

SyntaxEditorLineNumbersOrigin

A new property on the document class allows you to change the line number origin, which defaults to 1.  For the scenario described above, you'd set it to 10,000 instead.  All line numbers after that origin number will continue to be relative to it.

Advanced Scenarios

What about cases where a language might have specific line numbers or labels that should show for certain view lines?  This is possible too via a new language service that allows for completely customizing the text to display for each view line in the line number margin.

SyntaxEditorLineNumbersCustom

In the screenshot above, we've set the line number margin to show the zero-based offset of each line.  For a couple lines, we've also indicated labels for the namespace and class lines.

Summary

The new custom line numbering features are very easy to use for changing default line number margin content.

SyntaxEditor vNext - Touch Panning and Zooming

by Avatar Bill Henning (Actipro)
Monday, November 20, 2017 at 9:41pm

BlogPostBanner-SyntaxEditor-DevNotes

As mentioned in a previous post, we have been working on refactoring the core internal implementation of our SyntaxEditor code editor control on the WPF, UWP, and WinForms platforms.  This effort is being made to bring all three platforms onto the same codebase for easier updating moving forward, and to enhance features wherever possible.

In the previous post, we discussed how a new text rendering engine was being built that improved rendering speed, and how numerous scrolling improvements have been made.  In today's post, we'll take a look at how some new touch-input features are being added to vNext that take advantage of the rendering engine and scrolling enhancements.

Touch Interaction

In the current version, the UWP SyntaxEditor is the only one that supports touch-based scrolling, and its implementation scrolls in a line-based fashion, making the scroll experience choppy.

In vNext, we wanted to improve this.  As seen in the animation below, we've added touch scrolling support to the WPF, UWP, and WinForms SyntaxEditors, and the scrolling is pixel-smooth.  The scrolling even uses inertia, allowing for flick scrolling!

SyntaxEditorTouch

The WPF and UWP platforms support touch zooming as well, which can also be seen in the animation above.  Simply take two fingers and pinch to zoom.  It all uses smooth animated transitions too.

Summary

Adding improved touch input support is something we've wanted to do for a long time.  We're very pleased with how these features have turned out so far.