External Editor Interface for Project Builder

Martin Ott, TheCodingMonkeys

Open Document

Description Project Builder sends this event to the external editor to tell it to open a file.
Event Class kCoreEventClass
Event ID kAEOpenDocuments
Parameters This event has the following AppleEvent parameters:

Key Type Usage Description
keyDirectObject typeFSS required identifies the file to open
keyAEPosition typeChar optional structure that specifies the selection range

The optional structure has the following declaration:
    struct SelectionRange
    {
        short unused1; // 0 (not used)
        short lineNum; // line to select (<0 to specify range)
        long startRange; // start of selection range (if line < 0)
        long endRange; // end of selection range (if line < 0)
        long unused2; // 0 (not used)
        long theDate; // modification date/time
    };
    
The Metrowerks documentation states that you can use any names for the structure and its field.
It also states that the IDE (here Project Builder) uses 68K alignment when declaring this structure. The external editor must do so as well. For information on setting aligment see "Structure alignment".
Event Reply None
Remarks Metrowerks state in their documentation that the IDE (here Project Builder) uses the optional keyAEPosition parameter to tell the editor the selection range. If lineNum is zero or greater, scroll the text to the specified line. If lineNum is less than zero, use the values in startRange and endRange to select the specified characters. Scroll the text to display the selection. If lineNum, startRange and endRange are all negative, there is no selection range specified.


Modified Files

Description Project Builder sends this event to the external editor when it wants to know which open files in the editor have been modified.
Event Class 'KAHL'
Event ID 'MOD '
Parameters None
Event Reply This event sends the following reply:

Key Type Usage Description
keyDirectObject typeAEList required each element in the list is a structure of typeChar


The structure has the following declaration:
    struct ModificationInfo
    {
        FSSpec theFile; // identifies the file
        long theDate; // the date/time the file was last modified
        short saved; // set this to zero when replying
    };
    
The Metrowerks documentation states that you can use any names for the structure and its field.
It also states that the IDE (here Project Builder) uses 68K alignment when declaring this structure. The external editor must do so as well. For information on setting aligment see "Structure alignment".
Remarks When building the reply event, include one element in the list for each open file that has been modified.


Structure alignment

If you prefer to have a different default alignment for a target, you can modify the alignment before declaring the structures with:
#pragma options align=mac68k
After declaring the structures, use:
#pragma options align=reset
to restore the alignment to the target's default value.


References