Syntax Highlighting for SPIN files on TextWrangler

pgbpsupgbpsu Posts: 460
edited 2009-02-09 - 19:45:11 in Propeller 1
Although I find the Propeller Tool to be great at everything I ask it to do, the one thing it requires is windows to be running first. Because I do almost everything else on a Mac, I'd like a an editor that runs natively on the Mac which would have many of the features of the Propeler Tool. I'm not looking for a compiler just an editor. There are lots of fine editors out that which would get one close to the highlighting of the Propeller Tool. One such editor is TextWrangler for the Mac. One of the things I like most about this editor is the ability to split the screen horizontally and see two different parts of the same file (or the same part twice, but I don't think that's very useful). Since prop files are just text TextWrangler can already be used to edit them. In fact, I'm sure some forum users already do this. And I could as well, I've just really grown to like the highlighting the Prop Tool does. What I want to do (and maybe some has already beaten me to it) is write the Codeless Language Module for TextWrangler/BBEdit that would at least give users highlighted reserved words. I followed the example in the TextWrangler manual but (at least the version I have) it never indicates where to save the new plist file. I've attached the plist file I put together in case anyone wants to try it. But I haven't actually gotten it to work. I'm not sure if it's a problem with the plist file, or where I'm saving it. I put my copy in

~/Library/Application Support/TextWrangler/Language Modules/spin.plist



If I can get this to work, I'll try to do block highlighting next. Anyone know where this file really belongs? Anyone already done this?

Regards,
pgb

p.s. I had to zip the spin.plist file to get the Attachment Manager to accept it.

I finally got this to work. Sort of. It recognizes all the reserved words in SPIN, but it fails to highlight := <>, etc. Basically it only gets the words. There's some re-exp that stuff that I'm missing, but it's a start. Anyone who would like to have basic syntax highlighting in TextWrangler or BBEdit can download the attached file zip file, uncompress it, and save it as:
~/Library/Application Support/TextWrangler/Language Modules/spin.plist

If anyone adds to this to increase/expand its functionality please post it back here so the rest of us can take advantage.

Post Edited (pgbpsu) : 10/21/2008 3:04:43 AM GMT

Comments

  • AleAle Posts: 2,358
    edited 2008-10-20 - 08:21:27
    You can always use BradC's bst that runs on Mac, Linux and winblows. It can do everything PropTool can do maybe except and only for the time being, syntax highlight. It can also program propellers smile.gif. I gave up winblows in favor of it (also using Mac and Linux).
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-10-20 - 13:16:48
    I use Textmate, not TextWrangler. I have this spin bundle defined. It is not complete, but it makes spin files easy to read on a Mac.

    {    scopeName = 'source.spin';
        fileTypes = ( 'spin' );
        foldingStartMarker = 'con$';
        foldingStopMarker = 'pub$';
        patterns = (
            {    name = 'con.modifier.spin';
                begin = '\b(con|CON|pub|PUB|pri|PRI|var|VAR|obj|OBJ)\b';
                end = '$\n?';
            },
            {    name = 'comment.block.spin';
                begin = '\{\{';
                end = '\}\}';
                captures = { 0 = { name = 'punctuation.definition.comment.spin'; }; };
            },
            {    name = 'storage.modifier.spin';
                match = '\b(obj|con|var|pub|pri|dat)\b';
            },
            {    name = 'comment.line.spin';
                begin = "'";
                end = '$\n?';
                captures = { 0 = { name = 'punctuation.definition.comment.spin'; }; };
            },
            {    name = 'storage.type.spin';
                match = '\b(long|word|byte)\b';
            },
            {    name = 'keyword.control.spin';
                match = '\b(waitcnt|case|quit|default|while|else|repeat|if|return|while)\b';
                captures = { 0 = { name = 'punctuation.definition.keyword.spin'; }; };
            },
            {    name = 'string.quoted.double.spin';
                begin = '"';
                end = '"';
                patterns = (
                    {    name = 'constant.character.escape.spin';
                        match = '\\.';
                    },
                );
            },
        );
    }
    


    To use it, start TextMate and open the bundle editor and create a new bundle for Spin, then copy the code above into the bundle.
    -Chuck-
  • pgbpsupgbpsu Posts: 460
    edited 2008-10-20 - 13:40:57
    @Ale- I've been watching that thread. And it seems BradC has almost duplicated the entire PropTool on the Mac. That's very impressive. However, I'm looking for the only feature he hasn't yet implemented shakehead.gif Never satisfied....

    @Chuck-
    I've downloaded TextMate. Seems quite powerful and possibly worth the cost to buy, but I can't get your bundle code to do anything. Here's what I did:
    1. fire up textmate
    2. pull up the Bundle Editor
    3. add new language
    4. past your snippet over the code that was already there
    5. now I've got a new language called My Bundle with a subfolder named Spin. That's where your code went. I left the Activation Key and Scope Selector empty. When I quite TextMate and restart, then load a .SPIN file I get the spin file but without any highlighting save mis-spelled words.

    Does one need to register to get this feature?


    @Chuck-

    It's working now. I must not have quit TextMate, rather just closed the current window. I'll tinker around with this to see if I can get some of the other highlighting working. Nothing like procrastination....

    Thanks,
    pgb

    Post Edited (pgbpsu) : 10/20/2008 2:04:50 PM GMT
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-10-20 - 14:22:00
    Glad to hear that you got it working. Don't forget to install the "good" Parallax font. The standard one (from Parallax) shows all source code lines on top pof each other. The fixed one that is mentioned in the BST thread works great and allows you to see the spin diagrams.

    If you come up with an improved hilite scheme send a copy back my way! [noparse]:)[/noparse] -Chuck-
  • pgbpsupgbpsu Posts: 460
    edited 2008-10-20 - 14:25:33
    @Chuck-
    "If you come up with an improved hilite scheme send a copy back my way! [noparse]:)[/noparse] -Chuck-"

    Will do, however, I'm still leaning toward TextWrangler. I'm more familiar with it and it's free!

    p
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-10-20 - 21:57:19
    I also use BBedit, which is TextWrangler's older brother, so if you come up with a good Hilite scheme, that will be nice too.

    But TextMate is a better programmers editor. I use both, but tend to favor BBEdit for editing HTML pages and TextMate for source code. TextWrangler has support for many more languages than BBedit, even though BBedit is Much, MUCH older. All three (BBedit, TextWrangler, and TextMate are all good editors. A SPIN hilighter would be good for each.
  • pgbpsupgbpsu Posts: 460
    edited 2008-10-21 - 03:08:00
    @Chuck-

    I got something working with TextWrangler which should also work with BBEdit. One of the features that TextWrangler lacks that I believe is present in BBEdit and TextMate is "text folding" for collapsing blocks of code. I'm not sure this enough for me to buy either TextMate or BBEdit, but it would be nice. If only there was someway to add spin highlighting to XCode I'd be all set.

    Nonetheless, I edited the first post and replaced the uploaded file with the most recent. As the first post now indicates, the attached codeless language module should add reserved work and comment highlighting to TextWrangler and BBEdit. Unzip and place where indicated....

    pgb
  • Jay KickliterJay Kickliter Posts: 446
    edited 2009-02-08 - 22:09:54
    Chuck, have you done any more work on your Textmate bundle, or are you sticking with BST? I really like BST, but using Brad's compiler and loader with Textmate's UI would be really great.
  • Chuck RiceChuck Rice Posts: 210
    edited 2009-02-09 - 03:36:13
    I still use it sometimes, but I have not updated it. Too many projects. Too little time.
  • Jay KickliterJay Kickliter Posts: 446
    edited 2009-02-09 - 19:45:11
    Chuck, I understand. Too many projects. One day I may learn to finish one before starting another. I'll see if I can come up with anything. BST will probably always be better highlighting, but TextMate's rendering and user interface sure are nice. I'll see if I can get Brad's compiler/loader working with it.
Sign In or Register to comment.