Picaxe syntax highlighter for gEdit


I hate trying to understand and edit source code when its presented as plain black text.

It is funny how just a splash of colour can make so much difference to the readability of a source file.

So if you have to examine Picaxe source files on Linux (and you cannot use the LinAxePad editor) you need an alternative.

I use the editor gEdit quite a lot on Linux, and it includes colour highlighting for over a hundred file types. This not only includes the usual suspects (C, C++, Java, and so on) but also other file types (ini files, JSON and so on).

Colour highlighting is often automatically selected by gEdit based upon the file extension (although this does not appear to be working on my current version of Raspbian). You can also make a manual selection via the menu View > Highlight mode… or via the Status Bar if this has been enabled via the View menu.

For Picaxe source files with a .bas extention, gEdit will probably select VB.net syntax highlighting, which is a reasonable choice for common basic keywords.

However, if you want to take it one stage further, you can create your own syntax file.

Whether you decide to put a lot of effort into this is up to you, but I just created a dedicated file with a bit more support for Picaxe than the existing VB.net option. It works quite well for me, although the “if…then…else…endif” bit could be better.

Picaxe syntax highlighter for gEdit

Creating a Language file

On Debian based operating systems (like Lubuntu, Mate and Raspbian) gEdit uses syntax language files that you will probably find in:-

/usr/share/gtksourceview-3.0/language-specs

Each language file has a .lang extension and they are owned by root. So to edit these, I start by running the file manager as root. For example; on Raspbian or Lubuntu from a terminal:-

gksu pcmanfm

…then navigate to the languages-specs folder and open: vbnet.lang in gEdit

Now save this file with a new name: Picaxe.lang

Edit two lines:-

<language id=”vbnet” _name=”VB.NET” version=”2.0″ _section=”Source”>

…change to:-

<language id=”picaxe” _name=”PicAxe” version=”2.0″ _section=”Source”>

And:-

<context id=”vbnet” class=”no-spell-check”>

…change to:-

<context id=”picaxe” class=”no-spell-check”>

If you now close gEdit, then re-open it, you should see “Picaxe” in the Highlight Mode… list.

If you download LinAXEpad from the Picaxe download page, this includes a syntax file: PICAXE.XML. Unfortunately this is not in the required format, but I managed to copy all the keywords from the “commands” section, paste them into my new Picaxe.lang file, and edit the tags and other bits into the required format.

 

For more detail: Picaxe syntax highlighter for gEdit


© 2015 Powered By Engineering Projects Team, Raspberry Pi Projects

Scroll to top