Announcing pyPN-0.1

I finally got some time to clean up and zip up the current pyPN bits and have uploaded them to the web site:

http://www.pnotepad.org/files/pypn-0.1.zip

You will need the latest development build of PN (2.0.7.608 at the time of writing) and Python 2.4 to use this.

What is pyPN?

pyPN is the first extension for Programmer’s Notepad 2, and provides support for scripting PN using Python! You can already do a lot, but there’s also a lot of functionality yet to be exposed.

Other extensions can be provided using the same mechanism pyPN uses, see http://www.pnotepad.org/plugindoc/ for the gory C++ details (not as scary as you might think!).

Version 0.1

This is definitely beta software, so please experiment and report plenty of feedback! Extract the files into your PN folder and restart PN. If you already have a config.xml file you’ll need to merge the two files.

There will be more documentation as time goes on, but the code includes one very simple sample script showing how scripts can be built in to the scripts window. You can turn any python file or buffer into a runnable script by right-clicking and selecting “Use as Script” - this will add the window to the scripts window from where you can double-click to run.

So, some simple examples:

import pn pn.AddOutput("Hello!\n") > >

This will add text to the output window (you’ll need to show the window first).

To work with scintilla (the text editing component) try something like this:

import pn, scintilla s = scintilla.Scintilla(pn.CurrentDoc()) s.AppendText(6, "Hello!") > >

When you make a mistake in your script at runtime the traceback will be shown in the output window (again, you need to manually show this).

Note that if you put broken scripts in the scripts directory this will currently crash PN on startup - this will be fixed in future versions.

Finally note that you get some automatic indenting when writing Python code now, the code for this is in the init.py file. You can write indenters for other languages in a similar style. The indenting isn’t perfect, but I love it!

Let me know how you get on, and post anything that works for others to see as either a comment or on the forums!