nerd-cake[1]I hope to eventually have some more programming-related updates here; I’m working on a solution at work to add compile-time type-safety to Windows message passing that will make a good article (or two) when I’m done.

In the meantime, I have my IFComp updates, although vacation and the sheer number of other projects I have at home is cutting down on the amount of time I have to code in Inform 7.

What both these types of posts need, however, is a good way to format code.  By default, WordPress does not do a good job at all with code samples.  Luckily, however, there are a wide variety of plugins available to do a better job.  The one I chose is WP-Syntax, which leverages the GeSHi highlighter engine to do formatting syntax highlighting for a wide variety of languages.

None of these languages include Inform 7, but syntax highlighting wouldn’t really do much for Inform 7 anyway. For that language I’m just happy to have a nice box and a good font, which I get by default.

Here’s a (nonsensical) example for C++, to show off the highlighter features:

template <typename T, typename U>
class Complicated <T *, U> : public ComplicatedBase
{
public:
    Complicated(const CString &szData) 
    { 
        if (szData.IsEmpty())
        {
            m_szData = "Error";
        }
        else
            m_szData = szData;
    }
    virtual ~Complicated() { /*do nothing*/ }
    void SomeFunction() const;
private:
    CString m_szData;
};

…and another for SQL:

SELECT t1.a AS Name, t2.b AS Something_or_other
FROM Table_1 t1
    INNER JOIN Table_2 t2 ON t1.t1_ID = t2.t1_id
WHERE t1.c BETWEEN 4 AND 8
-- had a GROUP BY here...

Pretty cool, eh? The drawback is that the very nice visual editor in WordPress is not compatible with the formatter, but I can live with writing in raw HTML to get results this nice.