Postscript IDE
Volume Number: 17
Issue Number: 4
Column Tag: Programming Techniques
A Postscript IDE via a BBEdit Plug-In
By Larry Taylor
Using BBEdit + Distiller + Acrobat to create
postscript files with a minimum of fuss
Seven or eight years back, MacTech devoted an issue to the postscript page description
language and neat things that you could do with it (Vol. 9, 1993, Issue 4). This briefly
inspired me to try some things I'd wanted to do, but the lack of any sort of
programming environment was a real hindrance - sending your code to a printer and
waiting to see what happens is slow, frustrating and a big waste of paper. When Adobe
came out with Distiller, life improved some. You could write your code using a text
editor (such as BBEdit), open the file in Distiller and then read the resulting pdf file
using Reader. All in all, not too bad. This got me doing postscript programming again,
but it wasn't a true Mac experience. Ideally, I wanted to be able to type some code,
execute some key combination that compiles the code, and then execute another key
combination and have the results displayed.
In volume 14, 1998, Issue 6, MacTech had an article on BBEdit plug-ins by Steve
Sheets. I read the article with some interest, but as all of his examples dealt with
manipulating text in BBEdit windows, nothing clicked and I passed on, Then one day it
occurred to me that there must be commands for file manipulation as well. After all,
there is the old chestnut "Send Postscript" that I had first used to send my postscript
files to the printer. It ought to be possible to write a plug-in to mimic "Send
Postscript" but using Distiller and Acrobat instead of a printer: specifically, a plug-in
with the following behavior.
Take the text in the front window and find the associated file. Use some rule to associate
a pdf file to BBEdit file and find it. If the modification date on the pdf file is older than
that on the BBEdit file, send the BBEdit file to Distiller; otherwise send the pdf file to
Reader or Acrobat.
The rest of this article describes such a plug-in and how you can code it and get it
working. I will try to duplicate as little of Steve Sheets' article as possible, subject to
this article's being self-contained, so for a detailed discussion of how BBEdit plug-ins
work, go read Sheets' article.
Caveats and Quibbles
I have used this plug-in for several months but it is not a commercial quality
postscript development environment. It works quite well for small projects and I
recommend it for doing eps files. If you would like a postscript file to start on,
http://www.nd.edu/~taylor/ComputerStuff/Postscript/graphpaper.html will get you
a simple postscript program for graphing functions together with some additional
examples.
Here are a some minor annoyances and their work-arounds.
1. You have to invoke the plug-in twice to get from changes in your
postscript code to the displayed pdf file. Live with it.
2. If you leave the pdf file open in Acrobat and try to distill the BBEdit file
again, Distiller puts up an error message that it can't delete the pdf file and
halts. Just close the pdf file and try again.
3. When you invoke the plug-in the application being called comes to the
foreground. You need to get back to BBEdit to run the plug-in again. Since the
Distiller window is small, a simple mouse click will do the trick. Since any
error messages you may generate appear in the Distiller window, it is
actually a feature to have it foremost. The Acrobat window is usually large and
getting back to the BBEdit window may involve more than just a mouse click,
but this is also a feature since it encourages you to close the Acrobat window
before doing more work on your code, thus avoiding annoyance 2".
If you have never programmed in C before, this may not be a good initial project, but
if you are reasonably familiar with your C compiler you should be able to complete
this project. I use CodeWarrior as my C compiler so my remarks will apply precisely
to their setup but only minor modifications should be needed for other environments.
You need the BBEdit Extension SDK. This can be obtained from the BareBones website