Scripted Plugins

Dec 16, 2014 • Mattias Cibien

One of the pillars of SuperbEdit philosophy is extensibility: the editor must be customized from the ground up allowing users to extend its behavior and implement new functionality.

This is achieved through the use of Packages which, until now, has been limited to .NET (C#, VB, F#) compiled DLLs.

As of this week I started investigating on a way to include scripting languages as a way to extend the editor, without the need to build a DLL every time you make a change.

I started with IronPython with the IronPythonMEF extension since it seemed the easiest way but I was wrong at all since IronPython does not support .NET attributes by default.

This attributes (ExportAction,ExportPanel are some examples) are the pillars for extending the program at this time.

You can read more about this way of extending by checking out MEF, the Managed Extensibility Framework included from .NET 4.0

Attributes support can actually be implemented but it is pretty difficult and I was about to put scripting on hold when a Python-Like language built around .NET came to my mind: Boo

Boo has a syntax like Python but is built to work closely with .NET and has a clearer syntax than his brothers (no more self. for example). Most of all it has full support for attributes and .NET features.

In almost three hours I got the basic implementation running and re-wrote the dummy plugin using Boo.

import SuperbEdit.Base
import System
import System.ComponentModel.Composition

[ExportAction(Menu: "", Order: 0, Owner: "Dummy", RegisterInCommandWindow: true)]
class DummyBooAction(ActionItem):

  shell as Lazy[of IShell]

  def constructor():
    super("DummyBooLang", "Just a developer helper.")

  override def Execute():
    shell.Value.EchoMessage("Test message")

The architecture around scripting is also pretty simple: instead of interpreting at runtime the contents of the file SuperbEdit, when started, compiles the scripts in the Packages folder into assemblies and loads them into memory. Compiled code is always faster than fully interpret the script files.

Moreover this on-the-fly compiler is actually intelligent and won’t try to rebuild your script if not necessary so startup performance is not much affected.

The code for this can be found in the feature/boo-scripting branch on the repository and automated builds are available at the time of writing. Check it out!

Right now, I am going to implement full support for multiple script files plugins (since single-files ones are preety useless), better error handling when compiling scripts and try to make the engine more open to other scripting possibilities (Scripted C# can be a very nice option).

Note: IronPython support is not dropped in favour of Boo but at the moment there is no ETA for it.