PyPN


2
Sep 10

Zen Coding in Programmer’s Notepad

A user requested support for Zen Coding on the bug tracker.

Zen Coding is a system for writing HTML and CSS in text editors, expanding shorthand notation to full code.

I hadn’t used Zen myself, but a quick read of the excellent Smashing Magazine Introduction and a watch of the above video and I was intrigued.

Zen itself is an editor-agnostic set of scripts available in both Javascript and Python. That’s right, Python!

As testament to the good design of Zen, it was a piece of cake to integrate it with PyPN, allowing you to drop Zen for PyPN into your scripts directory and start taking advantage of this useful shorthand.

If you use PN 2.1.4 or later, you can start using Zen yourself right now:

  1. Download Zen Coding for PyPN Preview
  2. Extract the contents of the zip into your Programmer’s Notepad\Scripts directory
  3. Start PN
  4. Optionally bind the Expand Abbreviation script to a keyboard shortcut

Future enhancements to this implementation (and PN 2.1.5) will bring tab stops so that you can tab through the generated code, and probably other Zen Coding commands. For now, let me know what you think!


19
Nov 09

New Development Build

Now that the Mercurial code move is over and a whole bunch more bugs have been worked out, I’m happy to announce the first 2.1 testing release that’s being signalled for downloads. The new build is also available for download here:

Download 2.1.1.2047 Installer
Download 2.1.1.2047 Portable

In case you haven’t been keeping up with the various announced changes, 2.1 has these headline features:

  1. Full Unicode Support
  2. Support for Translations – PN in your language
  3. Prototype Command Bar feature (with PyPN)
  4. Multiple simultaneous selections, including typing into block selections
  5. Virtual space

There are also a lot of bug fixes, smaller improvements and extensions interface improvements. This release of 2.1 is close to what I want to release as the new stable build as soon as it’s proven at least as stable as 2.0.10.


13
Oct 09

PN Command Bar

Version 2.1 introduces a new prototype feature called the Command Bar. The Command Bar enables modal editing control, allowing advanced keyboard control of the editor – the initial implementation adds some simple VI-style commands.

The handling for the commands is entirely implemented in PyPN, and it’s designed so it’s easy for you to extend and test your extensions immediately. Just edit commands.py and run it as a script and the command handling is updated.

The look and feel will obviously be worked on over time, but this version will be in the forthcoming testing release and can be enabled from the options if you have PyPN installed. This quick video doesn’t show you all of the features already supported (skipping search and some other combination commands) but gives you a feel for what can be done.


13
May 09

PyPN Script Repository

Like the idea of using Python scripts to enhance Programmer’s Notepad but not sure where to start? James Yoneda has created the awesome ScriptShare website for exactly this purpose:

Scriptshare in Google Chrome

Scriptshare in Google Chrome

There are a bunch of scripts already there, and hopefully you will add yours too! We’re working on getting this moved over to pnotepad.org eventually.

My thanks to James for putting this effort in and creating such a useful site in such short time!


13
May 09

PyPN 0.10.973 Released

I’m happy to announce a minor bug fix release for PyPN, the Python extension for Programmer’s Notepad. This release fixes a PN crash if you tried to create a Scintilla object with no active document, and also the exception syntax problem preventing PyPN from working in Python 2.4-2.5.

Downloads


2
May 09

Programmer’s Notepad 2 0.9.962 Released

The latest testing release of Programmer’s Notepad is out. This release brings a whole bunch of great changes: Script (macro) recording when using PyPN, a customizable toolbar, firefox-style tab ordering and smart highlight. There are also a load of bug fixes too.

Downloads

There is also a new PyPN release fixing a couple of issues with the included scripts from the last build:

Thanks to all the users who have put time and effort into reporting and following up on bugs, testing, and contributing patches.


11
Feb 09

Programmer’s Notepad 2 0.9.921 Released

The latest testing release of Programmer’s Notepad 2 is finally out. There are plenty of fixes in this release, and a few minor new features too. Of particular note are the following:

  1. Updates to the extensions interface allowing extensions to create menu items
  2. International input fixed (I know this will please a whole bunch of users)
  3. Read only edit protection cleaned up
  4. More text transforms, also available from context menu
  5. Tab to space and vice versa conversions fixed
  6. Notepad’s .LOG feature natively supported
  7. Fix a problem using PN on the Windows 7 beta causing PN to hang on exit

Downloads

There is a new PyPN release supporting the updated plugin interface:

Thanks to all the users who have put time and effort into reporting and following up on bugs, testing, and contributing patches.


5
Nov 08

Search within comments

There was a question on the programming reddit today about finding text within comments only. There’s no way to do this from the UI in Programmer’s Notepad, but it’s easy in PyPN:

d = pn.CurrentDoc()
s = scintilla.Scintilla(d)

searchopts = pn.GetUserSearchOptions()

while not pn.CurrentDoc().FindNext(searchopts) == -1:
    # s.GetStyleAt(s.TargetStart) will work in the next PyPN release
    style = d.SendMessage(2010, s.TargetStart, 0)
    # pn.AddOutput(str(style)) - find the current style
    if d.SendMessage(2010, s.TargetStart, 0) == 2:
    break

That small bit of code will find whatever is in the current user’s search options only where the style is 2 – that’s the C++ comment style number. Sadly these numbers are not uniform across schemes, so we’d need to do a bit more work to do this properly across anything. To turn that small snippet of code into a script that can be run from a keyboard shortcut is also easy:

import pn, scintilla

@script("Find In C++ Comments")
def FindInCComments():
    d = pn.CurrentDoc()
    s = scintilla.Scintilla(d)

    searchopts = pn.GetUserSearchOptions()

    while not pn.CurrentDoc().FindNext(searchopts) == -1:
        style = d.SendMessage(2010, s.TargetStart, 0)
        if d.SendMessage(2010, s.TargetStart, 0) == 2:
        break

Just save that into your scripts directory and you’re good to go!


13
Oct 08

Programmer’s Notepad 2 0.9.853

Turbo Pascal Preset  Read only, browser and open files 

Mark All

Today I released a new 0.9 build, here are the highlights:

  1. Create file backups when saving (option, defaulting to off)
  2. Updated some of the images in Find dialog and main UI, read only indicator now uses a tab image instead of text
  3. Extension configuration now stored in user settings directory, meaning this works on Vista without an admin prompt
  4. You can now choose to poll for updates of testing releases (like this one)
  5. Uncomment now works for multiple line-comment lines at once
  6. New keyboard shortcuts for line comments (if you haven’t customised your shortcuts, you’ll get Ctrl-, and Ctrl-. as defaults)
  7. Fixed a crash when going to the Advanced options page
  8. Added a new Turbo preset for Turbo Pascal lovers
  9. Improved the ZenBurn preset
  10. Default scheme font on Vista is now Consolas, still Lucida Console on XP and below

All that, and just since mid-September when .840 was released. If you missed that one, you missed all this:

  1. Allow opening workspace files
  2. Restore editor windows when jumping to a line or tag
  3. Improve regular expressions support (Xpressive now working just fine)
  4. Works on Win2k again
  5. Don’t hold directories open after selecting files
  6. Support explorer context menus in Browser, Open Files and Projects items
  7. Added Mark All (you can’t configure the colors yet, but that’s coming!)
  8. Find in all Project Files
  9. Find next across all open files

You didn’t think I’d been slacking did you?! There have also been lots of behind-the-scenes changes to improve stability and the quality of the code. Not too much more to go now before a new stable release is born. Then onwards with the push to 2.1.

You can download the latest bits here:

0.9.853 Installer

0.9.853 Portable

I’ve also updated PyPN to support Python 2.6 as well as 2.5 and 2.4:

PyPN 0.9.853 for Python 2.4

PyPN 0.9.853 for Python 2.5

PyPN 0.9.853 for Python 2.6


3
Jun 08

Line Movement Commands with PyPN

A bug on Google Code asked for an alternative to the built-in Transpose Lines command in Programmer’s Notepad, allowing a single command to move the current line up or down, allowing repeated use to shift a line through the current document.

To look at implementing this, I started with a python script – it’s so much quicker than writing C++ code to add these commands and going through compile/test for every change.

Here’s how to add these commands as a couple of scripts (which of course can have keyboard shortcuts):

import pn, scintilla, pypn.glue

@script("Move Line Up", "Text")
def MoveLineUp():
	s = scintilla.Scintilla(pn.CurrentDoc())
	l = s.LineFromPosition(s.CurrentPos)
	if (l == 0):
		return

	s.BeginUndoAction()
	s.LineTranspose()
	s.LineUp()
	s.EndUndoAction()

@script("Move Line Down", "Text")
def MoveLineDown():
	s = scintilla.Scintilla(pn.CurrentDoc())
	l = s.LineFromPosition(s.CurrentPos)
	if (l == (s.LineCount-1)):
		return

	s.BeginUndoAction()
	s.LineDown()
	s.LineTranspose()
	s.EndUndoAction()

Drop this in a file in your scripts directory to use it (remember you need PyPN installed), or wait for the next version of PN which has these commands built in.