Tads3 Syntax Highlighting on OS X w BBEdit/Textwrangler

I’ve adapted Zarf’s Inform plugin to work for Tads 3.

To install this plugin in BBEdit or Textwrangler, download it and extract it into your plugin directory. For Textwrangler this is “$home/Library/Application Support/TextWrangler/Language Modules” (where $home is your home directory).

It is quite simple at the moment - it colours strings and comments. I plan to add more highlighting and function scanning, it’s not difficult just painstaking to ensure each addition works properly.

Does anyone know a list of keywords for Tads? I added all the ones I could think of to Info.plist in the package.

Would it be better to use Workbench-like colours?
Tads3-LM.bblm.zip (14.6 KB)

I’ll take a look at this later today, and report any problems. Here’s a suggestion, which you may already have thought of (or not): A color for all of the library classes would be useful.

I’m also curious how some of the other plugins do code folding. Maybe I’ll be able to puzzle that out by looking at the code for those plugins.

Okay, it works here (OS 10.6.8, TextWrangler 4.0.1). The keywords are blue, comments are gray, single-quoted text is red, double-quoted text is blue-gray.

Curiously, none of the other languages that are supported seem to have this type of xml file. At least, I couldn’t find any such files. This leaves me in the dark about how they enable code folding, for instance, or how they set up various color schemes for various types of keywords.

If there’s no convenient way to set up a color scheme with more categories, I’d suggest perhaps adding all of the classes to the keyword list. And perhaps all of the library property and method names as well. That would make a loooong list, but I think it would be useful. For instance, if the author types theMame instead of theName, it wouldn’t be highlighted. Ideally, these types of items would be in, you know, green and purple or whatever, but blue would be okay.

The BBEdit SDK (you don’t need BBedit to use it) has example projects with source code and a PDF explaining how to do syntax colouring and code folding. My source project is a mess right now (the compiled file it generates is called “inform7” :blush: !) But I plan to put it online when I’ve straightened it out (the syntax highlighting code is fairly usable :slight_smile: ). I haven’t started on code folds yet but there is Zarf’s code for I7. PM me if you want the C++ source code anyway.

It is quite simple to colour a set of keywords, apparently any colour you like - I just need to write an efficient string matching algorithm (I don’t understand the built-in CFString/make dictionary callbacks) then each type of pre-defined data can be (optionally) distinguished by a different colour.

I happen to have a Smultron file with all the classes and defined terms scraped from the library reference (Smultron has two types of keywords). Unfortunately I know of no list of methods which is simple to import/screen-scrape into code. There might be a simple reflective program that would print “class/object:” the name of each class (or singleton object) and then the name of each property/method with method arguments - reflectionServices.formatStackFrame (in reflect.t) has that sort of code.

Latest BBEdit plugin update has correct handling of triple-strings.
tads3.plist.zip (12.4 KB)
Tads3-LM.bblm.zip (25.6 KB)

I was pretty much cribbing from the example projects myself.

Not quite up to highlighting description phrases using the BNR grammar?

It would be a cool project when I’ve got the Tads plugin going. Keywords are lower-hanging fruit e.g. “instead” at the start or end of a sentence.

It’s easier to parse multi-character codes with a forward scanner (last-character becomes intractable if there are escape codes). The iterator doesn’t seem to throw exceptions if you request characters past the end of the valid input.

The source code is online with more documentation. You can also download the latest version there. Brief summary of features: Syntax highlighting, code folding, spelling checking, online reference search.

This totally rocks. Many thanks! TextWrangler is now a better T3 code editor than Workbench, as Workbench lacks both line numbers and code folding.

That’s not to knock Workbench’s other strengths, such as Watch Expressions and project source searching, but for anybody who wants to use T3 on the Mac, life just got a lot easier.

Actually, that’s not quite true. There are options under the Edit menu of Workbench (possibly not the most obvious place) to show both line numbers and folding controls.

You’re totally right. My bad. I did check Workbench before posting the message, but I was looking in Tools > Options.