Ludicrous Software

Corona Bundle for TextMate

(Update, 10 October 2010: The commands to run projects in the Corona Simulator has been updated; if you’ve already installed the bundle, see the info at the bottom of this post on how those commands work. If you haven’t installed the bundle yet, then just keep on reading!)

If you’re a Corona developer using TextMate, then this will hopefully be of use to you: I created a repository on GitHub containing a TextMate bundle that will hopefully make some of your Corona coding a little quicker/easier. There is already a Lua bundle for TextMate that you can get from TextMate’s svn repository of bundles (or from GitHub), and I’ve used that bundle as the basis for this one. So, all of the features in the bundle that specify code indenting rules, some general Lua snippets, and so on, are all straight from that bundle - they’ve saved me a ton of time, and hopefully the Corona bundle will be as helpful to you.

Some of the nifty features you’ll get include:

  1. Easily test your code in the Corona Simulator. Just hit command-R, and your app will load and run in the Simulator (assuming you’ve installed the SDK to the default location). Once you’re all done, you’ll get a new document in TextMate showing the results of any print() statements, error messages, etc. I’m planning to add support for Game Edition, as well as the ability to open a terminal window from TextMate, so that you can see the prints, etc. in real-time.
  2. Autocomplete for many common Corona keywords. Just start typing, then hit the ‘Esc’ key to cycle through the possibilities.
  3. Snippets for many common Corona statements.

Here’s a demo showing some of the bundle features:

You have two options for installing the bundle:

  1. Visit the GitHub page for the bundle (linked above). Click the ‘download source’ button up near the top-right corner to download a zip or tar file containing the bundle. Unzip/untar, then rename to resulting directory to “Corona SDK.tmbundle” (a TextMate bundle is just a directory containing a bunch of files). Copy the bundle to ~/Library/Application Support/TextMate/Bundles, and either (re)start TextMate or reload bundles in TextMate. You should see a bundle called ‘Corona SDK’ (or whatever name you chose) in the list of bundles.
  2. If you’re hip with git, then you can check out the repository to the Bundle directory listed above, and you should be good to go after reloading your TextMate bundles (or restarting, or whatever). The advantage of this is that you can easily update the repository to get the latest bundle as it evolves.

I’m adding more snippets and autocompletes to the bundle as I go along, and will be updating the repository on a regular basis. If you have any feedback or suggestions about what to add to the bundle, please let me know in the comments.

Update on the run script shortcuts: A couple of users of the bundle sent me some code to improve on my basic command to run a project in the Corona Simulator. Dan Rogers sent some code that launches the Terminal first, so you get any print/error messages in the Terminal. I’ve incorporated that, and then made a copy of it to give you the option to launch either the regular Corona SDK or the Game Edition. Now, when you hit Command-r to launch the Simulator, you’ll see a small pop-up asking you to press ‘1’ to launch the regular SDK, or ‘2’ to launch the Game Edition. As before, these assume you’ve installed the SDK(s) to the default location(s).

Also, Frank Siebenlist sent over a command that will reload the currently running Simulator. This works very well in conjunction with Dan’s code to launch the Simulator. So, after you’ve started a Simulator using Command-r, you can press Shift-Command-r to reload that Simulator. The only requirement for Frank’s command is that you have to enable access for assistive devices for the command to work. If you don’t have this enabled, you’ll be asked to do so the first time you use the Command.

Frank also had assed a number of Completions for Lua commands/functions, and I’ve added most of those to the bundle as well. Thanks to Dan and Frank!