TextWrangler 3.5 Release Notes

This page documents all feature enhancements and additions included in the TextWrangler 3.5 update.

For detailed information on using any of TextWrangler's features, please refer to the user manual (choose "User Manual" from TextWrangler's Help menu).

Requirements

TextWrangler 3.5 requires Mac OS X 10.5 or later (10.5.8, 10.6.7 or later recommended).

This version is a Universal application: it runs natively on both Intel-based and PowerPC-based Macs.

Additions

.
applicationDidFinishLaunching called when the application has completed startup
applicationShouldQuit called when the user has chosen "Quit" (or the application receives a quit event for some other reason
applicationDidQuit called when the application has finished shutting down and is about to exit
documentDidOpen called when a document has been opened and is ready for use. Note that TextWrangler supports multiple types of documents, and so you should be prepared for the argument to be a document of any type.
documentShouldClose called when the application is preparing to close a document.
documentDidClose called when the application has closed a document.
documentShouldSave called when the application is trying to determine whether a given document should be saved.
documentWillSave called when the application is about to begin saving a document. note that this will only be called after a successful return from a documentShouldSave.
documentDidSave called after a document has been saved successfully.
documentWillUnlock called when TextWrangler is going to make a document writeable (as when the pencil is clicked to unlock)
documentDidUnlock called when TextWrangler has successfully made a document writeable
documentWillLock called when TextWrangler is going to make a document read-only
documentDidLock called when TextWrangler has successfully made a document read-only

There's a new folder in the TextWrangler application support folder, "Attachment Scripts", which contains the script(s) to implement your custom event handlers. You can write one script to handle each attachment point, or you can write one script to handle the attachment points for an entire class of objects, or you can write one script to handle all of the attachment points for the entire application.

It's also possible to mix and match to specialize: for example, one script to implement a particular attachment point for documents, and one to handle the rest of them.

TextWrangler handles the association of scripts to attachment points by means of the script's file name. There are three ways to specify a script's role:

The first form is the most specific: the ObjectClass may be one of the following:

The entryPoint is one of the attachment points described above appropriate to the object class. So, for example, a script which implemented only the documentDidSave attachment point would have the file name Document.documentDidSave.scpt and contain a subroutine named documentDidSave, thus:

on documentDidSave

    --   do something useful and appropriate

end documentDidSave

Note that the file name suffix .scpt is not mandatory, but you should follow the current OS conventions as suggested when saving the script in the Apple script editor (or another script editor, such as the excellent Script Debugger).

The second form allows you to implement all of the attachment points for a single object class in a single script file, if desired. So, for the application (for example), create a script named Application.scpt, and it can contain subroutines for as many of the attachment points as you wish:

on applicationDidFinishLaunching

    -- do something relevant

end applicationDidFinishLaunching

on applicationDidWakeFromSleep

    -- do something useful

end applicationDidWakeFromSleep

on applicationShouldQuit

    -- hello world

    return (current date as string contains "day")

end applicationShouldQuit

To implement all of the attachment points for the Document class, you'd create a script named Document.scpt, and put subroutines in it for the document attachment points:

on documentDidSave

    ...

end documentDidSave

on documentWillClose

    ...

end documentWillClose

Finally, you can write one all-encompassing script which contains subroutines for all of the attachment points in the application. To do this, name the script TextWrangler.scpt and put whatever subroutines in it you wish to implement:

on applicationShouldQuit

    -- hello world

    return (current date as string contains "day")

end applicationShouldQuit

on documentWillClose

    ...

end documentWillClose

When figuring out which script to run, TextWrangler will first look for a script whose name exactly matches the attachment point, e.g. Document.documentShouldSave.scpt. If it is not found, TextWrangler will then look for a script whose name matches the object class at the attachment point; e.g. Document.scpt. Finally, if neither an exact or a class match is found, TextWrangler will look for an application-wide script: TextWrangler.scpt.

Note that you do not have to implement attachment subroutines for all attachment points, or for all classes -- only the ones you need. If there is no attachment script or subroutine, TextWrangler proceeds normally.

Changes

fin