n8blog
distraction in action

Like my work? Check out HexaLex, my game for iPhone & iPod Touch. It's a crossword game like Scrabble, but played with hexagonal tiles. http://www.hexalex.com

QLColorCode 0.4.1 is out now. I briefly released 0.4 but then realized that it was completely and utterly broken by an untested, last-minute, “this can’t possibly break anything” change. You think I would’ve learned by now…

The change list is short and sweet. I’ve added UTIs for a few more languages (Tcl, JSP, Lua) and improved some highlighting modes. But the nicest change IMHO is the ability to configure the highlighting parameters with “defaults write …” commands. This means I can finally use my slateGreen theme day-to-day without worrying that I’m going to accidentally push it out as the default theme for the next release. It also means you can enable line numbers, wrapping, etc. without hacking on files in the QLCC bundle and worrying about your changes being overwritten on the next update.

BTW, QLCC has been downloaded over 5,000 times since I first released it. If only I had a dollar for each download… ;)

Anyhow, get it at the project page.

  • Share/Bookmark

  Comments:

1. Oliver replies:

First off, thanks for the hard work.

Next up, a request: I’m no OS X maestro and I’m having a *miserable* time trying to get ActionScript (*.as) files previewed in QuickLook, let alone syntactically highlighted: all I get is the file icon.

The issues I seem to be up against are
a) I can’t find any UTTypeIdentifier information for ActionScript files in the info.plist under Adobe Flash CS3.app
b) Using
qlmanage -p [filepath].as 2>&1 | grep 'Generator used'
returns
Content type UTI: public.archive.applesingle. Generator used: None
Despite the fact that the info dialogue says that its Kind is “Adobe Flash ActionScript File”

As I say, I’m no expert where this sort of thing is concerned but hours of Googling to no avail mean that I’m throwing myself on your mercy (Highlight does support ActionScript BTW).

Many thanks again,

Oliver

2. n8 replies:

It looks like the system thinks .as is applesingle instead of actionscript. I’ll add a section for actionscript in the next release of QLCC. If you’re impatient you can edit the Info.plist file of QLCC and add a section for .as files. Just take a look at how the other file types are handled and you’ll see it’s not too hard. I’ll probably use “com.adobe.actionscript” as the type identifier.

3. Oliver replies:

Hi N8

That’s exactly my frustration: I edited the info.plist – duplicating a block and making the appropriate substitutions – both in QLCC contents and in Flash, used touch to update the UTI references, qlmanage -r to reload the QL database… all to no avail.

I agree with you that looks as though the misassociation of the .as extension with applesingle is screwing things up, but I don’t know how – short of repairing Flash via the installer – to fix this: as I say the Info pane for any .as file gives its kind as “Adobe Flash ActionScript File” not applesingle.

Any thoughts? Many thanks in advance.

4. Oliver replies:

[update]

I installed RCDefaultApp in an attempt to re-map “as” to a UTI of “com.adobe.flash.actionscript” and a MIME-type of “application/x-actionscript” but when I look at the extension “as” it is still firmly associated with “public.archive.applesingle” and “application/applefile” (respectively).

I’m still Googling furiously to try and the answer by myself, but if you have any ideas…?

5. Oliver replies:

[update2]

w00t! It turned out that I needed to refresh the LaunchServices database.

I used

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill

Hope that helps someone.

6. Oliver replies:

[update3]

Depressingly it doesn’t take too long for the problem to resurface: logging out or restarting has the effect of returning the UTI to public.archive.applesingle

Reinstalling (repairing) Flash had no effect either.

Please forgive the rash of comments, but I’m mainly leaving these updates in the hope that others won’t waste as much time as I have on this issue.

7. n8 replies:

Oliver: Don’t worry about commenting — I appreciate your willingness to share your experience. There’s basically no documentation on how conflicts are resolved in the UTI system so every bit of information is useful.

If there’s no UTTypeIdentifier in Adobe’s Info.plist file then they’re not even attempting to define a UTI so it’s not surprising that the system’s binding takes precedence. One more (slightly dangerous) thing to try: make a UTExportedTypeDeclarations section and put the .as UTI in that. It should be something like this (substituting square brackets for angle) and it should go at the same level as the current UTImportedTypeDeclarations element:

[key]UTExportedTypeDeclarations[/key]
    [array]
        [dict]
            [key]UTTypeIdentifier[/key]
            [string]com.adobe.actionscript-source[/string]
            ...
        [/dict]
    [/array]

The idea is that exported UTIs are ones where you are the authoritative source for that UTI, whereas imported UTIs are those that don’t really belong to your app but that you might need to define if they don’t exist on the system.

I call this approach “dangerous” because if Adobe ever does decide to define a UTI and uses something besides “com.adobe.actionscript-source” for the type identifier then the QLCC definition may prevent those .as files from being associated with Adobe’s app. That’s why the UTIs in QLCC are all of the imported kind.

8. Oliver replies:

Hi N8

Thanks for your help and the explanation of how UTExportedTypeDeclarations works – I’ve been astounded at how little documentation there is on Quick Look as a whole.

I confess I cheated in the end and simply added public.archive.applesingle to the LSItemContentTypes array in the QLCC info.plist. So far nothing has blown up. :)

9. n8 replies:

Ha! I guess I never even thought of doing that. It should probably be fine — the odds of encountering a real .as applesingle file are amazingly, vanishingly, astronomically small.

10. Oliver replies:

That’s what I figured, glad you’re of the same opinion.

Thanks again for all the help.

11. yazrr replies:

Oliver, can you share your info how to get QL to show actionscript?

12. Oliver replies:

@yazrr

The answer is above (see reply no. 8), but to clarify, simply edit the LSItemContentTypes array in QLCC info.plist (I used TextMate rather than the default app for the sake of readability) and include public.archive.applesingle as one of the types to be picked up.

This is a *total* hack – basically it tricks Finder into thinking that files ending in .as (which are locked in association with the applesingle mime-type because Adobe don’t export a profile with their apps) *can* be previewed in QuickLook, whereas ordinarily they can’t (applesingle being a kind of archive file).

Hope that sheds some light… and hope that Adobe do something to make CS files (.ai, .as) previewable by default in the future. If not, let me know where you’re going wrong and I’ll try to help… although to be honest I’m no more of an expert than you: everything I know about it is what’s on here.

13. ck replies:

Thanks for sharing. I was looking for ages to get this working.

14. Nitesh replies:

Thanks a million Oliver and n8.. real life saver

[...] was good, but not good enough, so after a bit more of digging, this blog finally gave me the answer (and especially the 12th comment) at least for previewing the ActionScript [...]

[...] was good, but not good enough, so after a bit more of digging, this blog finally gave me the answer (and especially the 12th comment) at least for previewing the ActionScript [...]

17. Antti Kupila replies:

This is really awesome, thanks a lot! I had problems with actionscript too but comment #5 solved it.

18. ivan replies:

Hello guys,
about the actionscript thing :
On leopard, my .as files were rendering nice in quicklook without any plugin.
on snow leopard, it were not. So I googled, found your great plugin. But it was not rendering .as files, even with all the tricks you tell in the comments.
Finally I found the problem : now ( at least on my computer ) follow the comment n°12 but replace “public.archive.applesingle” with “com.apple.applesingle-archive”
I hope that will help someone.

19. russ replies:

evil.. haha.. omg I’m so glad I found this thread. It’s finally solved my quicklook problem. One that’s been crippling my speed for months. THANK YOU EVERYONE.. every single tip helped.. so all of you.. thanks seriously, especially the author! you all rule.

20. Ben replies:

Phew – After an hour of messing around with plist files, I finally noticed comment number 18. Adding “com.apple.applesingle-archive” to Info.plist was the solution for me to. Possibly a snow leopard thing?

22. tf replies:

This thread keeps proving its usefulness ..

The “com.apple.applesingle-archive” tweak listed in comment 18 works for me.

Spacebar now opens .mxml and .as

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Please type this word with the letters reversed: live

Like my work? Check out HexaLex, my game for iPhone & iPod Touch. It's a crossword game like Scrabble, but played with hexagonal tiles. http://www.hexalex.com