Author Archives


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!


31
Oct 08

Server E-mail Fixed

There were problems with the pnotepad.org host not sending on e-mail, so registrations for the forums and comment notifications were not being sent. This is all fixed now, so if you were trying to register please try again!


31
Oct 08

35 New Schemes

That’s right! 35 New Schemes for Programmer’s Notepad, all the schemes that Scintilla supports should now be available. These new schemes will not be bundled with PN but will be available as downloadable add-ons.

The schemes are:

  1. ASN.1
  2. AVE
  3. Ada
  4. Apache Conf
  5. AutoIt
  6. Baan
  7. BlitzBasic
  8. Bullant
  9. Csound
  10. E-Script
  11. Eiffel
  12. Erlang
  13. Flagship
  14. Forth files
  15. FreeBasic
  16. Inno Setup
  17. Kix-Script
  18. Lisp and Scheme
  19. Lot
  20. Lout
  21. Lua
  22. MMixal
  23. Objective Caml
  24. Octave
  25. Opal
  26. POV-Ray SDL
  27. PostScript
  28. Prolog
  29. PureBasic
  30. Rebol
  31. Scriptol
  32. Smalltalk
  33. Spice
  34. Yaml
  35. nnCron

Download from Google Code

The schemes will be linked from pnotepad.org as soon as I get around to it.


15
Oct 08

Wombat Preset

Matt sent me a Programmer’s Notepad preset for a colour scheme that he uses across all of his editors, known as Wombat:

Programmers Notepad

I like it a lot, perhaps even more than the Zenburn scheme that’s shipping with 0.9 right now. Wombat will be included with the next release, but if you need it now then you can get it here:

Download the Wombat Preset for Programmer’s Notepad

Simply expand the zip and drop the xml file in your PN\presets directory. Then select Wombat from Tools|Options|Styles and press the Load button. Thanks Matt!

Do you have some colours of your own that you think other people would like? Save your preset and send it to me or post it in the forums!


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


1
Oct 08

And We’re Back!

During my lunch hour today I rebuilt the VM that hosts pnotepad.org and untidy.net. It had been very unreliable over the last few weeks/months and it finally got to the point where it was easier to take the hit and rebuild rather than continuing to nurse it back to life.

Fortunately a good backup plan and the offloading of mail services to Google Apps last year meant that this was relatively painless. It was made even easier by the excellent facilities provided by my virtual machine host Bytemark. They made it a matter of a simple menu selection to have my VM rebuilt with a debian base image, LAMP stack ready to go. Recommended.

As far as I can tell all of the sites are up and working, the one thing remaining for me to check is that mail is still functional. I’ll get to that this evening.

I now need to keep an eye on load and stability with the new install and check that everything is as it should be. This time I made a point of creating a local VM for use when testing configuration changes and web site changes so keeping the server working properly should be easier.


12
Sep 08

Hansel-link, so that’s where the traffic came from

I was out last night, and noticed when I got back that for a brief while the pnotepad.org server had stopped responding. I didn’t really look into it but this morning it all became clear as I read my feeds in Google Reader. Scott Hanselman has a great review of the use of WTL in Chrome (Google’s new browser) in his latest Weekly Source Code.

He linked to an old article I wrote way back when on the Joys of WTL. Fun to see my own words quoted back at me on Scott’s blog! WTL is still the UI framework used for Programmer’s Notepad 2 and in the most part has served very well.

I’d also downloaded the Chromium code to go spelunking into their WTL use having read the excellent post from Peter Krumins’ blog on Code Reuse in Chrome.

Interestingly Google include the WTL code in their distribution, this was something I’d been thinking about doing for PN to reduce the number of steps needed for people to build PN. It would also help with the fact that PN 2.0.9 needs changes currently only available in the WTL Subversion depot.


28
Jul 08

Software Tracking

While playing around with new search engine Cuil I stumbled across a software tracking website I hadn’t seen before: Wakoopa

Sign up for Wakoopa, install a small piece of software and they will track your software use and build up an online profile showing this information. In return they’ll recommend software for you and let you know about new versions. Seems interesting, and you can see a bunch of users of Wakoopa also like Programmer’s Notepad: Programmer’s Notepad on Wakoopa. When I looked, 101 users had clocked up more than 370 hours of usage, across Mexico, Norway, Iran and the Netherlands (amongst many more). Hello international users!

Using Wakoopa reminded me of Ohloh – an open source software tracker. Ohloh concentrates on tracking contributions to open source software, and analyses the source code and commit history for open source projects to build up interesting metrics on each project. Some interesting statistics from the Ohloh Programmer’s Notepad page:

162,795 C++ Code Lines (with a further 29,856 lines of comment)
79,622 C Code Lines (with a further 12,076 lines of comment)

The ratio of comment to code for Programmer’s Notepad 2 is 15.5%, and was only 9.6% for version 1 – clearly I’m getting better behaved in my old age. Statistics are also provided for each developer, and I can see that my Median Commit Rate is 10 commits per month changing 2,200 lines of code – that’s a lot of code for an evenings and weekends project. Of course some of my commits are code contributed by others – don’t want to take all the credit!

You can click the button below to add your support for Programmer’s Notepad at Ohloh:


5
Jun 08

C# Automatic Properties can have Attributes

The MSDN documentation for Automatic Properties (a C# 3 language feature) states that attributes are not valid on automatic properties. This is not true, the following code compiles and works as expected:

public class Data
{
[XmlAttribute]
public int SomeNumber { get; set; }
}

class Program
{
static void Main(string[] args)
{
using (XmlWriter w = XmlWriter.Create(@”c:\temp\test.xml”))
{
XmlSerializer s = new XmlSerializer(typeof (Data));
s.Serialize(w, new Data { SomeNumber = 5 });
}
}
}

Running this code results in an XML file looking roughly like this (I stripped some unneeded namespace declarations):

< ?xml version="1.0" encoding="utf-8"?>
<data SomeNumber="5" />

SomeNumber is saved as an attribute, so the XmlAttribute attribute worked correctly.


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.