02
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.


15
Apr 09

links for 2009-04-15


04
Apr 09

links for 2009-04-04


10
Mar 09

First Poll Results

A little while back I asked people a couple of questions to help guide future PN development.

The results ended up looking like this:

Is the fact that you can float PN document windows useful?

This question is concerned with whether the MDI window management system is helpful to people. I suspected that most users had windows maximised all the time and used the tabs to switch – i.e. MDI wasn’t buying them much. Here are the results:

Results of MDI Poll

18% of people were using the abilities of MDI windows and were very happy about them. Pretty much everyone else doesn’t care or would rather be able to split the view.

Don’t worry, this isn’t going to drive any instant knee-jerk changes, but I’m keeping it in mind for future design work. I am definitely going to address the lack of split views, I’m just trying to decide how.

Do you use the individual output windows?

Here I wondered whether the hidden away option to use individual output windows instead of the global one for each window was actually being used – I suspected not. I was wrong!

Individual Output Poll Results

Lots of people use the individual output windows, and it appears lots of people have no idea what output windows are! I’m not sure whether this is because they have no need in their editing for tools and output, or are just unaware of the features.

I’ll be posting some more questions soon, and wanted to thank everyone who took the time to answer these polls or comment – it’s appreciated!


21
Feb 09

links for 2009-02-21


19
Feb 09

Programmer’s Notepad 2 0.9.926 Released

This is a minor bugfix testing release for Programmer’s Notepad, fixing a few niggles with the last release.

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.


17
Feb 09

Adding a Menu Item from Your Extension

This is the second post in the Writing your First Extension series. You can see the full article here: Writing Your First Extension.

Menu items are added via the IPN object provided at extension load time. You add menu items by providing an implementation of IMenuItems. Here is a very simple implementation supporting a single item:

class Menu : public extensions::IMenuItems
{
public:
    Menu()
    {
        memset(&item1, 0, sizeof(item1));
        item1.Handler = &MyExtensionFunc;
        item1.Title = L"Hello World";
        // item1.Type = extensions::miItem;
        // item1.UserData = 0;
    }

    /**
     * Get the number of MenuItem instances that can be retrieved.
     */
    virtual int GetItemCount() const
    {
        return 1;
    }

    /**
     * Get an individual MenuItem instance by index.
     */
    virtual extensions::MenuItem& GetItem(int index) const
    {
        if (index == 0)
            return const_cast<extensions ::menuitem&>(item1);
    }

private:
    extensions::MenuItem item1;
};

This very simple implementation adds a single menu item called "Hello World". When the item is selected, the MyExtensionFunc method will be executed by PN.

It might seem like a fair bit of code to add a menu item, but in the next SDK version I’ll provide a general-purpose helper to make this easy. The reason for the interface is to make it easy for you to provide sub-menus. MenuItem instances can contain child items by changing Type to miSubItem and filling in the SubItems member with another instance implementing IMenuItems.

The handler method looks like this:

void MyExtensionFunc(extensions::cookie_t /*cookie*/)
{
    g_PN->GetGlobalOutputWindow()->AddToolOutput("Hello World!");
    g_PN->ShowOutput();
}

Once you have your handler and IMenuItems implementation, you just need to tell PN about your items. In your init function you need something like this:

bool __stdcall pn_init_extension(int iface_version, extensions::IPN* pn)
{
    if(iface_version != PN_EXT_IFACE_VERSION)
        return false;

    g_PN = pn;

    Menu menu;
    pn->AddPluginMenuItems(&menu);

    return true;
}

Now you have Programmer’s Notepad presenting your commands in the menu and can handle their selection. Next time we’ll look at the other events PN lets you attach to.


16
Feb 09

links for 2009-02-16


16
Feb 09

Creating your first Programmer’s Notepad extension

PyPN provides a great way to add functionality to Programmer’s Notepad by writing simple Python code, but you might want to do something more advanced. For this there’s the Programmer’s Notepad Extension SDK.

The SDK lets you extend PN using C++, allowing you to react to editor events and provide new commands in the menu. PyPN is itself implemented as an extension using this same SDK, and you can use the SDK to provide support for other scripting languages too.

What You’ll Need

You need a Windows C++ compiler and the Boost C++ library. Note that you don’t need to compile any of boost, we use the header-only bits.

I suggest using the free Microsoft Visual C++ Express if you don’t already have Visual Studio, this should guarantee compatibility.

Getting Started

Download the SDK and copy the template project, this is a good base for your extension. Note that the SDK also contains a demo extension showing use of various parts of the SDK. Change the name and version of your extension and you’re ready to add it to Programmer’s Notepad for the first time:

void __declspec(dllexport) __stdcall pn_get_extension_info(PN::BaseString& name, PN::BaseString& version)
{
    name = "My First Plugin";
    version = "1.0";
}

Compile the extension and place the .dll file in your PN directory. Now run “pn –findexts” and your plugin will be discovered and loaded the next time you start PN. Go to Tools->Options->Extensions and see your extension listed.

Everything else you want to do flows from the instance of IPN that’s passed to your init function. This interface gives you access to the open documents, lets you sign up to handle document events and gives you access to app-level services like script registration, find in files and options management.

Working with Documents

Everything you want to do with an open document is done through the IDocument interface. You get a pointer to one of these from your IPN instance by calling GetCurrentDocument, NewDocument or equivalent.

    // Make a new document
    IDocumentPtr doc = pn->NewDocument(NULL);

    // Send scintilla messages (see scintilla.org documentation)
    doc->SendEditorMessage(SCI_APPENDTEXT, 6, (LPARAM)"Hello!");

    // Save changes
    doc->Save("c:\\temp\\test.txt", true);

    // Done with the document
    doc->Close();

This is the first in a series of posts that will become the introductory documentation for extensions. Next time we’ll look at how to add menu commands for your plugin. The series will be added to the docs site as we go: Writing your First Extension


14
Feb 09

links for 2009-02-14