Saturday, October 10, 2009

AvalonEdit, a (the?) WPF code editor component from the SharpDevelop team (think WPF based, monster cool, code editing, IDE like, uber textbox +10)

Rudi Grobler - Create your own IDE in 10 minutes

untitled

Ok, so I might be stretching reality just a “little” but the purpose of this post is to introduce you to two control libraries that might just do that!

AvalonEdit

AvalonEdit is the new WPF-based editor used in SharpDevelop 4.x. Using the AvalonEdit control is very similar to using a normal TextBox!

<avalonEdit:TextEditor
ShowLineNumbers="True"
Name="textEditor1"
FontFamily="Consolas"
FontSize="10pt"/>

To load a document…

textEditor1.Load("Window1.xaml.cs");

And finally, to turn on syntax highlighting?

textEditor1.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#");

Out-of-the box AvalonEdit supports ASP.NET, Boo, Coco/R grammars, C++, C#, HTML, Java, JavaScript, Patch files, PHP, TeX, VB, XML

AvalonDock

AvalonDock is a WPF controls library which can be used to create a docking layout system like that is present in VisualStudio. It supports fly-out panes, floating windows, multiple docking manager in same window, styles and themes and it can host WinForms controls.


…”

CodeProject - Using AvalonEdit (WPF Text Editor)

“…

The latest version of AvalonEdit can be found as part of the SharpDevelop project. For details on AvalonEdit, please see www.avalonedit.net.

screenshot

Introduction

ICSharpCode.AvalonEdit is the WPF-based text editor that I've written for SharpDevelop 4.0. It is meant as a replacement for ICSharpCode.TextEditor, but should be:

  • Extensible
  • Easy to use
  • Better at handling large files

Extensible means that I wanted SharpDevelop AddIns to be able to add features to the text editor. For example, an AddIn should be able to allow inserting images into comments – this way you could put stuff like class diagrams right into the source code!

With, Easy to use, I'm referring to the programming API. It should just work™. For example, this means if you change the document text, the editor should automatically redraw without having to call Invalidate(). And if you do something wrong, you should get a meaningful exception, not corrupted state and crash later at an unrelated location.

Better at handling large files means that the editor should be able to handle large files (e.g. the mscorlib XML documentation file, 7 MB, 74100 LOC), even when features like folding (code collapsing) are enabled.

…”

My first thought? “Oh… shinny!”

My next was; I wonder if there’s a TSQL syntax (or how hard it would be to create one)? We have a very simple TSQL entry on a form, where we done some simple, regex based syntax highlighting. It sure would be cool to be able to drop in something much more powerful.

Also I think we have teams with other embedded code entry/editing UI’s (VB.Net entry I think). This might be of interest to them too (and this might get them started moving toward WPF, so a win-win! ;)

Come to think of it I have a HTML entry area in my Text Template WLW plug where I could use this too!

Oh and there’s… and then for that… and also…

I can see a number of places where I can use this free, OSS (LGPL) component. :)

(via Reflective Perspective - The Morning Brew #451)

No comments: