Monday, April 16, 2007

jEdit Flex Compiler Shell Integration

Last night I stumbled across a great little hack that's really been a missing piece of the Flex action for me. Flex Builder's zippy compilation is one of the best features of the commercial Flex product, and one I sorely missed. But now I've figured a way to integrate the Flex Compiler Shell into jEdit, and so now my text editor of choice works very well with my compiler of choice.

jEdit's Console plugin allows you to integrate a shell into the interface. This shell is scriptable via jEdit's quite extensible macros. So we have two macros, one to initialize the compiler shell, and another to re-compile once initialized.

First macro:

//Initiate the compiler
runCommandInConsole(view,"System","/path/to/fcsh");
runCommandInConsole(view,"System","mxmlc ... very long list of arguments for your compile :P ...");

Recompile macro, bound to Ctrl-Enter:

runCommandInConsole(view,"System","compile 1");

This makes me a very happy boy! I have verified that these instructions should work on Windows, too (as I'm doing this on Linux).

2 comments:

David said...

I made some makefiles for Flex, so you can do this...

jEdit.saveAllBuffers(view,false);
runCommandInConsole(view,"System","cd /work/game");
runCommandInConsole(view,"System","make sleep rundebug");

The 'sleep' target waits a second for the 'saveAllBuffers' to finish, as the script tends to run off without waiting for anything to happen.

The rundebug target updates the debug build and then invokes the debugger.

These are all available from here...
http://flex2cpp.sourceforge.net/

The actual project applies a C preprocessor to the sources, for all the evil fun that implies.

There are also instructions there for making jEdit recognize the errors and warnings and pop them up in the 'Error List' plugin automatically.

Chris Hill said...

Hi David,

Wow, that's some pretty nice stuff! I have thought a preprocessor for flex would come in handy sometime, and it feels good to see industrial-strength build tools being used in the Flash world!