November, 2008


7
Nov 08

PN 2 0.9.872 Released

The latest testing release of Programmer’s Notepad 2 is out, fixing a couple of annoying bugs in the previous release amongst other things. This release is also the first in-the-wild use of the “check for updates” feature. If you are running build 853 or newer and have enabled looking for testing updates, then in the next day or so PN will notify you that there is a new version available.

Changes in this build:

  1. Wombat preset included
  2. Ignore ctags warnings when parsing tags
  3. Fixed bug causing tools capture not to work properly
  4. Allow changing display name of root magic folder
  5. Add support for displaying the caret as a block
  6. Switch back to a DLL for Scintilla for those that use a custom build

Note that if you intend to use a custom build of Scintilla (SciLexer.dll) to support other schemes or prototype changes then you will need to build using the project in the PN source or you will lose the new Regular Expression support. To get the source and build the project you might like to look at How To Compile PN on the docs site.


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!