Programmer’s Notepad as WinSCP Editor

SteveJ shows how to use Programmer’s Notepad as the file editor with WinSCP

Erlang and Prolog support

Now available on the add-ons page:

Lifehacker Poll

Programmer’s notepad is listed on Lifehacker again today, in a voting poll against Notepad2, Notepad++ and Zulupad (which I hadn’t heard of before). You’re more than welcome to vote for PN!

Lifehacker Battle of the Notepad Alternatives

The poll is a little odd, not listing a whole bunch of the most popular editors like Emacs, Context, Textpad and the like - you won’t find me complaining!

Boost::Xpressive and Scintilla

Programmer’s Notepad has long needed an improved Regular Expressions engine. Currently PN uses PCRE for all tasks but searching Scintilla. This is because PCRE doesn’t support searching anything but a memory buffer - i.e. it doesn’t support iterators. We need iterator (or indirect access) support because a regex engine for a text editor can’t expect all text for the editor to be in a single contiguous memory block.

Boost::Regex has been suggested several times, but it still doesn’t support named captures. When allowing users to specify regular expressions for use in parsing, named captures can significantly simply the process. For example, when using a regular expression to parse compiler output we have two alternatives:

  1. \s*(?P<f>.+)(?P<l>[0-9]+)(,(?P<c>[0-9]+))?\s*:

    This uses the standard named capture syntax to name the three capture blocks: “f” for filename, “l” for line and “c” for column. The single expression can be parsed and understood by PN without the user having to understand capture indexing.

  2. \s*(.+)([0-9]+)(,([0-9]+))?\s*:

    This uses basic regular expression capture groups and results in the user having to enter three additional pieces of non-obvious data: the capture index for each capture. In this case these would be 1, 2, and 4 but this would potentially change for each output pattern.

 

I believe that using named captures significantly improves the user experience around this, especially considering that PN uses %f, %l and %c to represent the three named capture groups meaning that users don’t even need to understand regular expression capture syntax to use them.

Boost 1.35 introduces version 2 of Boost.Xpressive, the other boost regular expressions engine. Boost.Xpressive naturally supports iterators. Version 2 supports named captures.

Implementing a Scintilla Iterator

Xpressive requires a bi-directional iterator class (one that can move forwards and backwards over the contents). I’ve currently implemented a very simple, naive iterator to prove that this can work:

/**
 * std::iterator compatible iterator for Scintilla contents
 */
class ScintillaIterator :     public std::iterator<std::bidirectional_iterator_tag, char>
{
public:
    ScintillaIterator() :
        m_scintilla(0),
        m_pos(0),
        m_end(0)
    {
    }

    ScintillaIterator(CScintilla* scintilla, int pos) :
        m_scintilla(scintilla),
        m_pos(pos),
        m_end(scintilla->GetLength())
    {
    }

    ScintillaIterator(const ScintillaIterator& copy) :
        m_scintilla(copy.m_scintilla),
        m_pos(copy.m_pos),
        m_end(copy.m_end)
    {
    }

    bool operator == (const ScintillaIterator& other) const
    {
        return (ended() == other.ended())
            && (m_scintilla == other.m_scintilla)
            && (m_pos == other.m_pos);
    }

    bool operator != (const ScintillaIterator& other) const
    {
        return !(*this == other);
    }

    char operator * () const
    {
        return charAt(m_pos);
    }

    ScintillaIterator& operator ++ ()
    {
        m_pos++;
        return *this;
    }

    ScintillaIterator& operator — ()
    {
        m_pos–;
        return *this;
    }

    int pos() const
    {
        return m_pos;
    }

private:
    char charAt(int position) const
    {
        return m_scintilla->GetCharAt(position);
    }

    bool ended() const
    {
        return m_pos == m_end;
    }

    int m_pos;
    int m_end;
    CScintilla* m_scintilla;
};

 

This can then be used with Xpressive like this:

typedef boost::xpressive::basic_regex<ScintillaIterator> sciregex;
typedef boost::xpressive::match_results<ScintillaIterator> scimatch;
typedef boost::xpressive::sub_match<ScintillaIterator> scisub_match;

void test()
{
    sciregex regex = sciregex::compile("[0-9]+”);
    scimatch match;
    if (regex_match(m_scintilla, match, regex))
    {
        LOG(”Yay!”);
    }
}

This code is now available in Programmer’s Notepad subversion, and it seems to work. The iterator needs a bit of improvement to buffer data from Scintilla, or perhaps needs moving so that it doesn’t have to send a windows message for every character access. However, as a proof of concept it’s a good one and it suggests that we should be able to replace the current lacklustre regex searching support with fully featured multi-line support for the next release.

File Browser, Open Files

The development of Programmer’s Notepad 2.0.9 is well under way, and the first few features have already hit in usable form:

New File Browser and Open Files windows

Two new docking windows have been added supporting:

  • File Browser
  • Currently Open Files

 

Other improvements already in:

  • Removed auto-complete irritations from the find dialog
  • New vista-style task dialogs used for message boxes
  • Separated Document and Text Editor event sinks in extensions interface
  • Added new Document events in extensions interface

Google Code Hosting

Google Code started out as a site to house Google’s Open Source projects and contributions. Then in July 2006 Google announced that they were adding Project Hosting.

This places them somewhat in competition with SourceForge, although they have publicly stated that they don’t intend to offer all the features that SourceForge do (an educated guess suggests this means things like compile farms and shell access).

The SourceForge services have been extremely useful to Programmer’s Notepad over the years. We make use of the tracker, downloads and their hosted Subversion (CVS when we started) for source control. However, there are several problems with the service which have become steadily worse over the years. The site is user-hostile and spattered with animated ads:

sfnet

I have no problem with SourceForge supporting their work through advertising, but the number of huge animated flashing ads on each page completely overwhelms the content the site exists to serve - never a good sign.

The download service they provide is supported by mirrors around the world. Unfortunately, there is no way to direct your users to a link where they can just download your software. Instead, they are forced through a landing page displaying sponsor links and, you guessed it, more advertising.

Finally, and perhaps most importantly, the tracker (system that holds bugs and feature requests) is incredibly frustrating to use.

 

The Google site is refreshingly clean in comparison:

gcode

Sure, advertising hasn’t made it to this page yet but I still trust Google to be a bit more tasteful with their ads based on their other ad-supported services. The tracker is simple-yet-powerful, with customisable tags being used to classify items, and is obviously backed by powerful search. Downloads support direct linking and are also identified using tags.

The site provides a wiki (if you want it) and wiki markup is available throughout. The level of control over the front page presentation and the configuration of features is great.

 

The Programmer’s Notepad source code has all been synchronised into a Google Code SVN repository (browse with change history!) and the 2.0.8 downloads are currently being provided from Google’s servers.

I’m working on a script to import the tracker items from the three PN SourceForge trackers into the Google Code one. I’m not 100% sure it’ll be possible yet, but given that Google make a python script available to upload new downloads, I’m fairly hopeful.

The SourceForge site will stay around, and development and trackers haven’t moved over yet (I’ll be sure to tell you when they do) but Programmer’s Notepad is jumping ship.

 

Visit Programmer’s Notepad at Google Code

Programmer’s Notepad 2.0.8 Stable Released

Finally a new stable build! Programmer’s Notepad 2.0.8 has been just over a year in the making. Some of the highlights of this release:

  • Extensions interface, allows extension of PN using C++ add-ins
  • Python extension (PyPN), allows scripting of PN using Python
  • Tag browsing
  • Keyboard customisation
  • Comment insertion/removal
  • Autocomplete (based on keywords and tags)
  • Code templates

Downloads

This release wouldn’t have been possible without the excellent contributions (patches and documentation), testing, bug reports and feature suggestions made by users.

Windows 95/NT4 Support Dropped

Support for these operating systems in Programmer’s Notepad has been broken for most of the development of 2.0.7 and I’m now not planning on re-instating it. The amount of work required to allow PN to work well on newer OS releases while still running on these old releases is enough that I don’t have the time to dedicate to it.

I would be more than happy to let someone else take on this work if they’re sufficiently motivated, but unless that happens there will be no more 95/NT4 compatible builds.

Hopefully I’ll keep 98 support for as long as possible, but again I won’t be putting more than minimal effort into ensuring continuing support.

ClipX

Occasionally I get a feature request for Programmer’s Notepad asking for clipboard ring support. Personally I’ve never been a big fan of clipboard rings, although it may be implementations like that in Office that puts me off. Jeff Atwood is a big fan of them, however, and pointed to ClipX as an implementation that works regardless of what program you’re using:

clipx-intray

ClipX is freeware, and will from now on be my recommendation for those wanting Clipboard Ring support in Programmer’s Notepad. I’ve even downloaded it and installed it myself to see if I can see what the fuss is about!

SvnExplorer

I needed to do a little browsing of the PN subversion repository this evening, and wanted to do so from a GUI without installing my normal favourite TortoiseSVN. I found SvnExplorer after a bit of searching and it did the job just fine. I’d have preferred not to have to use an installer, but it wasn’t too painful and it did the job.

 

SvnExplorer

 

SvnExplorer Web Site