TextMate IDE for Pascal

Recently I took an entire week out of my life to work full time on a TextMate bundle that could act as a full IDE for Pascal and the results have been quite successful. Already after a single I have been able to port my most recent project to TextMate and compile, debug and run the application all using TextMate and Terminal.app.

The entire bundle is powered by a series of small PHP scripts and some JavaScripts/HTML for the GUI which is web based, running directly inside of TextMate. It did occur to me that the entire GUI could actually be a real Mac application invoked from PHP but the web based GUI works well and was extremely fast to make because it uses scripting languages and HTML all of which are faster than making real applications. In fact, the entire reason for making the bundle in the first place was to save time developing IDE’s and spending more time of commercial software that isn’t going to put in the poor house.

For the time being I’m going to develop my next app using TextMate and see how it feels for the long term. I don’t want to abandon PascalGladiator but the effort it takes to maintain the project is just not making sense for the little time I have. Since the huge problems I had porting WASTE to NSTextView under PasCocoa and now PasCocoa to Objective Pascal I’m all spent on massive over hauls. I also made a big mistake by changing the DataBrowser wrapper API I have  (for Warehouse) which is going to take some time to apply to PascalGladiator. And finally, I’m going to have to port the entire project to Cocoa eventually and I haven’t really even started to learn all the details of Cocoa of how to build a full app like PascalGladiator with it.  Crashing bugs need to be fixed and updates so iPhone targets work properly but I can’t even get the project to compile without a good month of full time work. Ughh…

Until I feel motivated I will keep working on TextMate and make it the most complete solution it can be. Right now I’m pretty confident it can do everything we need and it’s a well supported and stable base to work from. Furthermore, I really suggest this to users using Xcode which is a hack for Pascal and offers less features than TextMate.

Until I make a real site you can download the bundle and learn the features by reading the manual at pascal.thealchemistguild.org.

The strong points:

  • TextMate is extensible so users can add snippets an extend the functionality of the IDE themselves.
  • Has all the major features you would expect from an IDE (error console, targets, syntax styling etc…).
  • Better than Xcode because:  more complete syntax coloring, jump to definition works, code completion uses symbols from the project, built specifically for FPC so it doesn’t break as easily.
  • Excellent snippet system from TextMate.

The weak points:

  • The single biggest weak point in the TextMate syntax system is that it can not dynamically read selectors from other files. If it did we could add symbols to a syntax file after compiling and TextMate could style those so we know which symbols are part of our project. As it stands now I made a bunch of regex expressions which try to guess where symbols are but it’s impossible to make it perfect for Pascal syntax so often we get black text where there should be some color. I really hope this gets addressed in TextMate 2.0.
  • TextMate really let me down on this: it only supports monospaced fonts!!! This is really bad news and hurts my eyes but I guess I’ll have to suck it up until TextMate 2.0 is released which may support proportional width fonts. I think the developer spent too much time on the terminal as a kid but surely he respects peoples needs for choice considering how he developed the entire app around this principle! He should put his entire website up in the Monaco font  if he thinks it’s so great, but of course he won’t because it would look terrible.
  • If you want to search for whole words you need to perform a regex search which is annoying to type \b all the time.
  • I still think there’s a way to achieve this but I wasn’t able to launch the application executable using PHP so it must launch via Terminal.app instead of reporting errors in the console. This may be a preference for some but I would like to keep it all in TextMate if possible.
  • You have to pay $40 to the developer of TextMate instead of free like Xcode or PascalGladiator.

What’s left:

  • I still think the application can be launched inside of the TextMate and return output the console instead of using Terminal.app but this hasn’t been a huge issue yet so I’m going to sit on it for a while.
  • The jump to definition feature only finds the first symbol in the project but there should be a popup menu which lets you choose from multiple definitions. Another web based interface could be made but I think making  a custom popup menu app that could be controlled from PHP would be better and not too much work.
  • Could a web based debugger interface be made for GDB which could be controlled via PHP? I don’t know how to make PHP work as a pseudo terminal (should be possible using standard UNIX system functions but I’m not skilled enough there) but even if that doesn’t work an intermediate Pascal application could be used in concert with the PHP scripts to make a usable system. I already made a debugger interface for PascalGladiator but it was terribly complicated to integrate into the editor and ended up being discontinued.
  • I just learned that TextMate has a basic plugin API which is enough to at least give you access to the Cocoa environment which means a toolbar to the window or items in the menu bar could be added.  Maybe not worth the time and I’m certain I could get enough relevant information on the state of the editor to be effective but it could be fun to attempt.
  • Xcode has a really nice feature that lets you lookup symbols in the Apple developer documentation which I want to implement. Apple recently changed the format of the directory structure but it can still be parsed I think.
  • Syntax styling is a real pain to get correct in all areas so I’ll be adding to this all the time I suspect.

If anyone wants to contribute by making Pascal apps that are controlled from TextMate, command scripts in any language, snippets or modify the GUI HTML etc… let me know!