Logo

StickFigure Graphic Productions


Komodo Edit/IDE TorqueScript Plugin

Anyone who's developed for Torque on OS X knows how limited our options have been as far as a good programmer's text-editor for composing Torque Script files is concerned. Komodo Edit is a fantastic (and free, though it's IDE cousin is not) editor based on Scintilla, Python, and Mozilla. It supports both extensible syntax highlighting, extensible linting (syntax checking) and extensible code-sense (autocomplete). I have produced a plugin to allow Torque programmers to make use of these features. At the moment it only supports the UDL/syntax-highlighting portion of the features mentioned above, but I plan to keep hacking away at it. Also, for whatever reason SSLs have one additional color available as compared to CSL. If you just want to download it, click here and then drag-and-drop the downloaded file into the main editing window of Komodo Edit (or IDE), approve the installation, and restart. Then change the file associations and coloring to fit your needs and have fun.

Licensing:

Copyright 2012, by Thomas Dickerson, all rights reserved. You're free to use this, but it should be considered experimental, and while it is hoped to be useful, you are responsible for any damage that may occur to your computer or code base as the result of using it.

Documentation & Explanation:

Here we have examples of two different color schemes:
Color Scheme 1

Color Scheme 2
A couple things to note:
  • Komodo Edit supports C# development, so you'll have to change the file-extension/language association for *.cs in the preferences. You can use this as an opportunity to add associations for *.gui and *.mis as well.
  • The default color-scheme doesn't do anything special for variables or named identifiers, but you can change this to suit your fancy.
  • Tested on Komodo 6 - 7.1. Should work as far as back as version 4.
  • Tagged (single quoted) strings right now are color coded as regex tokens, since TS doesn't support regex syntax, by default. If you've added that somehow to your installation, let me know and it might motivate me to color it using the markup-tag colors instead.
  • I've also added rudimentary auto-indent/dedent code, and support for soft-characters.
TorqueScript allows a type specifier before the field declarations within an object, or datablock declaration. The parser needs to know what types are available to the console, in order to distinguish between them and a normal identifier, so here's some C++ code (to be incorporated into your Torque engine) to dump a python dictionary matching type names to their numeric IDs to the console. I put mine in console/dynamicTypes.cpp.
ConsoleFunction(dumpConsoleTypes, void, 1, 1, "dumpConsoleTypes")
{
    Con::printf("gConsoleTypeTable = {");
    ConsoleBaseType *walk = ConsoleBaseType::getListHead();
    while( walk != NULL )
    {
        Con::printf("    '%s' : %d,", walk->getTypeName(), walk->getTypeID());        
        walk = walk->getListNext();
    }
    Con::printf("}");
}
Sources:
Other Tools:
Made use of BYACC for the grammars for the Code Intelligence plugin. It had some issues with Python support, which I tried to correct, and I will publish the changes on this site. I attempted to contact the maintainer of the Sourceforge project, which has been inactive for close to a decade, in the hopes of contributing my changes back into the wild; however, he has been thus far unresponsive. I also used Plex to implement the associated tokenizers.

Finally, for fun, I rendered the AST generated by my parser. If you have GraphViz, you can check out several of the .dot files: It's fun to notice that control structures lead to deep trees (first example above), Code which is a mix of both ends up having some really fat portions and some really deep portions (second example above). and declarative statements lead to wide trees (third example above). And as might be expected, GUI code (fourth example above) has a very blocky hierarchical structure.

If you don't have GraphViz, it's okay - I've rendered a PNG of it, and uploaded it here. You'll have to download it, because it's ~7MB and 45000x9000 pixels, which makes the Google Drive image preview sad. It may also make your computer sad if you don't have enough RAM to open a picture that large.

Alternatively, here's a youtube video demonstrating it by hand: