February, 2006


28
Feb 06

Multi-line Search and Replace

I’ve seen a number of comments spotted around blogs claiming that PN2 doesn’t support multi-line search and replace. This isn’t true.

For example, if you take the following text:

<node1>
<node2>
<node3>

You can change this to <node1><node2><node3> by searching for “>\r\n< " and replacing with ">< ". For this to work, you must have the Allow Backslash Expressions checkbox checked. This checkbox enables the following:

\n - Line Feed Character (#10)
\r - Carriage Return (#13)
\t - Tab (#9)

So, PN does support search and replace across multiple lines. The only thing that it doesn't support is regular expressions across line boundaries - yet!

I wonder if the reason people give up is the \r\n thing instead of \n? This is because windows format files have two characters to match there. I wonder if some editors make \n match the equivalent of \r?\n.

Note: I had to re-type this entry three times before giving up on WordPress’ rich text editor – I couldn’t type those XML nodes in using either the rich editor or the plain text editor without them being stripped.


27
Feb 06

SourceMonitor

SourceMonitor is a free source code analysis tool from Campwood Software. It will analyze source code in a variety of languages including C# and C++, Delphi (Object Pascal) and Java. It allows you to store a series of checkpoints detailing various complexity metrics over time and can help to locate targets for refactoring and simplification.

Here is a screenshot of some metrics for PN before the recent refactoring of the code that transforms XML schemes into instructions for the Scintilla editing component:

Scheme Compiler Metrics

The source files here are sorted according to Max Complexity. The Scheme Compiler here is pretty complex compared to a lot of the other code. Interestingly, the refactoring did not reduce this complexity by much as can be seen here:

Scheme Compiler Complexity After

The number of lines of code and statement counts have shot down due to re-organisation and refactoring but the complexity has only reduced by a small amount. Clearly parts of this code are still quite likely to be difficult to follow and understand for anyone not used to it.

Of course, no metrics tool is worth anything without graphs, double clicking on the SchemeCompiler.cpp file brings up a nice little dialog with in-depth details about that code file:
Scheme Compiler Analysis

The tool can also graph various of the metrics in a graph window on their own. I particularly like the Kiviat Graph which shows that complexity is high and comment content is low suggesting some under-commented complex code! Not all of the metrics this program can show you are necessarily useful and it’s easy to jump to the wrong conclusions about what work would be useful based purely on analysis like this but overall I like it!
A useful free tool for analysing your code: SourceMonitor


27
Feb 06

Source moving to Subversion

Sourceforge have finally released the project subversion facilities to all projects and the source for PN2 is now being managed in subversion following a simple and successful migration process.

If you’re looking for a good subversion GUI interface for windows then you might want to try TortoiseSVN. This works just like TortoiseCVS by integrating with Explorer. It also includes a merge tool, meaning that you don’t need a third party tool just to compare files. The polish doesn’t feel quite as good as it does with TortoiseCVS, but overall it seems quite functional.

The commit notification mailing list is not yet receiving notifications of svn commits but I’ll get to that soon.


17
Feb 06

Middle Click Close in Visual Studio

A long time ago I added middle-click to close tabs in PN – a popular choice. At the time I moaned about this not being supported in Visual Studio. When the VS 2005 development betas were out, myself and many others requested this feature.

Microsoft’s response was that this was not a standard windows UI feature and therefore they would not be implementing it. Leaving aside the fact that Visual Studio often invents UI features of its own and also that IE 7 supports middle-click closing for tabs, this was a really poor response from Microsoft given that it would have been so easy to add this feature and make people happy!

Fortunately for all us Visual Studio users, Jonathan Payne wrote VSTabs, a sort of mini WndTabs for VS 2003 and 2005. This gives you tabs that group paired files (like .cpp and .h) and also gives you middle-click close – wahey! Finally, the source is available so you can tweak to get them working as you like.

Current downsides are that the add-in breaks the right-click context menu, and doesn’t show the modified status of the file (no * for modified files). Oh, and some that I work with hate the colours – who’d have thought?! This should all be relatively easy to fix though.


11
Feb 06

Free Compilers

Looking to compile your code using free tools?

See this list of free compilers.


11
Feb 06

Akismet Rocks

The Akismet plug-in for Wordpress just caught 130 odd spam comments that were submitted over a relatively short period of time. That’s saved me a good bit of time in filtering the comments manually had they made it through. Having a blog is a much more pleasant experience with Akismet installed.

Update: Another 140 since this post, this plugin is definitely saving me time!


4
Feb 06

Help Needed from NAnt and C# users

Bug #1408401 on SourceForge says that 2.0.6.1 broke output parsing for NAnt C# errors. Can someone please test this and if broken attach a sample of the error messages to the bug report so I can fix it?

Thanks.


4
Feb 06

Boost Python Release Builds – Ouch!

I just did a release build of PyPN just to see how fast it ran when everything was built release. It took 14 minutes to build! To put that into perspective, the entirety of the main PN executable takes less than 3 minutes to build. Most of the 14 minutes is spent in the Generating Code stage.

Of course, the first time I ran PN it crashed straight away, due to a compiler settings mismatch – doh! Another 14 minutes down the drain.

The delay is all due to compiling and optimizing Boost Python. All those templates are eventually going to slow a compiler down, and my poor 2Ghz Athlon is not impressed! Once I have this first developer build with PyPN out the door it’s time to get around to trying out SWIG as an alternative (as I promised ages ago). If I have to write a couple of hours more code to get SWIG working as well, then it may be worth it for the compile-time savings.

Update: On my laptop (1.8Ghz Pentium-M) it takes only 4 minutes to compile in release, so I guess that’s more usable. Also, I think my desktop may have something wrong with it, even PN runs like a dog – time for a re-pave.


3
Feb 06

Convert SciTE Language Files Automatically

Sebastian Pipping has written a perl script that can convert from SciTE .properties files to PN scheme files. This is a rough and ready tool, but will make it really easy to convert a lot of languages from SciTE to PN2. Sebastian had this to say about the limitations of the tool:

  • there still is manual completion to do after conversion. best case is you just have to finish the styles but it could also be useless keygroup names or worse. nevertheless the output should be a good base at least.
  • it currently does not handle “font.” and “colour.” style properties. some of these made PN2 denying the scheme file. the code for this is in the script – it is just turned off.
  • all names are extracted from the last comment line before. some property files do not support this concept so the names we get are quite useless or even mis-leading (from far before comments).
  • the script cannot deal with property files using multiple lexers. error handling is almost zero in general.

This will be really useful and should help the number of languages supported by PN soar.

Download Sebastian’s Perl script.

Thanks Sebastian!


3
Feb 06

MATLAB and a Shell Extension

Over on the forums James Myatt has announced a MATLAB scheme that he’s created for PN2 – thanks James!

In other news, I just checked in the code for a Shell Extension for PN2. This allows PN to appear on your shell context menus and work correctly when multiple files are opened. I’ll release this separately before the next full PN release for experimentation (watch this space).