Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScintillaNET vs AvalonEdit for providing scripting interface for a WPF Application

I am working on a project which includes implementing a scripting interface for my WPF (.Net4) windows Application. I am curious if anyone can suggest a preferred editor, AvalonEdit vs ScintillaNET. Any pitfalls and advantages of one over the other. We need to support both C# and IronPython as scripting languages. (At least that is the initial plan. We might finalize on one of it though).

One of the downsides of ScintillaNET is that it is just a managed wrapper around the native (unmanaged) Scintilla. Is this going to cause any issues when used with WPF4.

Any pointers and suggestions are appreciated.

like image 933
Bhuvan Avatar asked Dec 20 '11 15:12

Bhuvan


1 Answers

I think this depends on how many features you want to implement in the editor. Also how much work you are willing to put in to extend it and how much of a learning curve you are willing to deal with.

If you are targetting Win32 and you don't mind the unmanaged dll then I think Scintilla.NET won't be a problem. Also you can easily host it in WPF as this page suggests.

Personally I felt that Scintilla performs better than AvalonEdit. It also is easier to get started with a basic editor, and provides a lot out of the box, for instance Scintilla provides code folding out of the box.

With AvalonEdit you have to create a folding strategy and parse the document yourself, This is what I had to do to support IronPython for AvalonEdit which I haven't implemented yet.

All I needed to support an IronPython editor in scintilla was the SciLexer.dll in the search path and the Scintilla.net assembly and the following configuration:

private void Form1_Load(object sender, EventArgs e)
    {
        this.scintilla1 = new ScintillaNet.Scintilla();
        this.scintilla1.ConfigurationManager.Language = "python";
        this.scintilla1.Indentation.ShowGuides = true;
        this.scintilla1.Indentation.SmartIndentType = ScintillaNet.SmartIndent.Simple;
        this.scintilla1.Location = new System.Drawing.Point(0, 0);
        this.scintilla1.Margins.Margin0.Width = 40;
        this.scintilla1.Margins.Margin2.Width = 20;
        this.scintilla1.Name = "scintilla1";
        this.scintilla1.TabIndex = 4;
        this.scintilla1.Whitespace.Mode = ScintillaNet.WhitespaceMode.VisibleAfterIndent;
        this.scintilla1.Dock = DockStyle.Fill;
        this.Controls.Add(this.scintilla1);
    }

For AvalonEdit you have to load an external highlighter file, you can see the this blog post for more info. So if you want the basics (highlighting, folding for python+c#) my conclusion is schintilla is easier and performs better. Although with AvalonEdit you might be able to do more in the end if you are willing to put in the effort and deal with the learning curve. At the moment I am using Scintilla as my stable editor and am experimenting with Avalon as a proof of concept. Perhaps I will form new opinions too as I learn more about the editor.

Good luck

like image 140
Andre Avatar answered Nov 13 '22 12:11

Andre