Share Tweet reddit Email

Mostly inspired by Allen Huffman and his excellent series of articles about Cross development and Extended Color Basic (CoCo Cross Development part 1, part 2, and part 3), I decided to try coding in BASIC for the CoCo using a modern editor.

Equipped with MAME as emulator and LWTools to create and modify disk images, using the decb utility, I create a handy Makefile that would take my BASIC program, put it in a disk image, start MAME CoCo3 emulator, load and run my program (I will show you this toolchain in a future post). Everything worked great, but editing the BASIC program in a modern emulator was a bit frustrating for two reasons: no immediate syntax check and no syntax highlighting.

Solving the first is not possible unless I have a basic interpreter built-in in the editor, which is not an easy task. For that reason, I decided to survive without it. With the toolchain, running the program in the emulator is fast enough, so the syntax checking isn’t really a dealbreaker… The other annoyance is how bland and boring the listing looks in the editor. Nowadays, any half-good editor offers syntax highlighting for many languages, so why I cannot have that for my CoCo BASIC programs!?

With that in mind, I decided to implement one for the Atom editor. If you are not aware, Atom is a free editor created by Github, and available for Windows, MacOS, and Linux. It is also very hackable and comes with a great plugin support, referred as packages. I have used Atom before, but I never made any package for it – time to learn something new!

To install Atom, just head over https://atom.io, download and install the version for your OS. After I had done it, I decided to load a simple BASIC program to take the before screenshot. This is what looks like:



My next step was to find out how to create a syntax highlight for Atom. As a general rule when you need to learn something new, the better path is to find something similar that was already done and take it from there! I was lucky enough to find a syntax highlighting for the Commodore 64, create by Steven Syrek. I learned that the mechanism uses regular expressions to find the patterns and apply to pre-determined types like keywords, number, strings, and so on.

I copied Steve’s sources and started modifying it, using the Extended Color BASIC quick reference guide I have around, going command by command, function by function. It was a length process, but not very hard. At the end, I had my language-cocobasic syntax highlight covering all CoCo BASIC keywords. The product is available on Github for everybody to use.

Atom let you create your own extensions and publish it in the editor database, making it available to the users via Atom package manager. Because of that, you can install the language-cocobasic directly from Atom. First, you open Atom and select the Preferences options (the location varies on Windows and MacOS, but it is easy to find!). If you found it, you should see the following screen:

Next, select the option + Install – the last one from the menu displayed on the left bar. The next screen will allow you to search for packages to be installed. Just type language-cocobasic there and you should find my color syntax package.

The installation happens all automatically and at the end, the screen will inform you that it is properly installed. If you still have the BASIC listing available in another editor screen, now it will be displayed with all colors that our beloved language deserves!

The actual color of the functions, keywords, variables, numbers, and strings will be displayed depends on the color theme your Atom editor is configured with. You have dozens of them to choose from until you find that perfect color scheme you were looking for your whole life!

Again, the editor doesn’t check for any BASIC syntax or tell you about typos and errors, but at least now, typing in that old Rainbow game won’t be a burden like it was in the past!

I hope the language-cocobasic package will be useful to many CoCo programmers like it is for me. In a near future, I will show my toolchain configuration that allows me to launch the BASIC program directly from the Atom editor! Stay tuned!

Link: Atom Editor

Link: Language-CoCoBASIC Atom page