2010-02-16 19:20

Yak Shavings for February 16, 2010

yak shaving
(idiomatic) Any apparently useless activity which, by allowing you to overcome intermediate difficulties, allows you to solve a larger problem.

A while ago, I wrote how I implemented a generic syntax highlighter for PyQt using Pygments.

I got a request for such a feature in Marave, so I digged that code and... it's freaking useless. It's just too slow for reasonable use.

So, that yak's hair is all grown up again, and I just got this new pair of scissors!

The goal is a way to highlight syntax in a QPlainTextEdit that:

  • Doesn't require programming to add a new highlighter
  • Doesn't require programming to add a new color scheme
  • Doesn't require me to spend a year writing highlighters for existing languages
  • Is fast enough

A quick google shows that for C++ you can use Source highlight qt which is based on GNU source highlight.

Alas, no python binding that I could find. So, let's write one!

Here it is: http://marave.googlecode.com/svn/trunk/marave/highlight/

And here's a screenshot of the demo program running, showing itself in its entirety:

You can create a color scheme using CSS, a language definition is a text file, there are a bazillion already written, it seems to be fast enough.

So, another yak shaved, another feature (not finished!) for Marave


Comments powered by Disqus

Contents © 2000-2019 Roberto Alsina