diff options
Diffstat (limited to 'macosx/tkMacOSXHLEvents.c')
-rw-r--r-- | macosx/tkMacOSXHLEvents.c | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index 9c0f9d1..f5aeff0 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -33,7 +33,7 @@ typedef struct KillEvent { * Static functions used only in this file. */ -static void tkMacOSXProcessFiles(NSAppleEventDescriptor* event, +static void tkMacOSXProcessFiles(NSAppleEventDescriptor* event, NSAppleEventDescriptor* replyEvent, Tcl_Interp *interp, char* procedure); @@ -53,7 +53,7 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags); [self handleShowPreferencesEvent:Nil withReplyEvent:Nil]; } -- (void) handleQuitApplicationEvent: (NSAppleEventDescriptor *)event +- (void) handleQuitApplicationEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent { KillEvent *eventPtr; @@ -67,7 +67,7 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags); * quickly as possible. */ - eventPtr = (KillEvent*)ckalloc(sizeof(KillEvent)); + eventPtr = ckalloc(sizeof(KillEvent)); eventPtr->header.proc = ReallyKillMe; eventPtr->interp = _eventInterp; @@ -75,7 +75,7 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags); } } -- (void) handleOpenApplicationEvent: (NSAppleEventDescriptor *)event +- (void) handleOpenApplicationEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent { Tcl_Interp *interp = _eventInterp; @@ -85,12 +85,12 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags); int code = Tcl_EvalEx(_eventInterp, "::tk::mac::OpenApplication", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { - Tcl_BackgroundError(_eventInterp); + Tcl_BackgroundException(_eventInterp, code); } } } -- (void) handleReopenApplicationEvent: (NSAppleEventDescriptor *)event +- (void) handleReopenApplicationEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent { #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 @@ -104,12 +104,12 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags); int code = Tcl_EvalEx(_eventInterp, "::tk::mac::ReopenApplication", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK){ - Tcl_BackgroundError(_eventInterp); + Tcl_BackgroundException(_eventInterp, code); } } } -- (void) handleShowPreferencesEvent: (NSAppleEventDescriptor *)event +- (void) handleShowPreferencesEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent { if (_eventInterp && @@ -117,24 +117,24 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags); int code = Tcl_EvalEx(_eventInterp, "::tk::mac::ShowPreferences", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { - Tcl_BackgroundError(_eventInterp); + Tcl_BackgroundException(_eventInterp, code); } } } -- (void) handleOpenDocumentsEvent: (NSAppleEventDescriptor *)event +- (void) handleOpenDocumentsEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent { tkMacOSXProcessFiles(event, replyEvent, _eventInterp, "::tk::mac::OpenDocument"); } -- (void) handlePrintDocumentsEvent: (NSAppleEventDescriptor *)event +- (void) handlePrintDocumentsEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent { tkMacOSXProcessFiles(event, replyEvent, _eventInterp, "::tk::mac::PrintDocument"); } -- (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event +- (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent { OSStatus err; @@ -164,7 +164,7 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags); errString, strlen(errString)); return; } - + if (MissedAnyParameters((AppleEvent*)theDesc)) { sprintf(errString, "AEDoScriptHandler: extra parameters"); AEPutParamPtr((AppleEvent*)[replyEvent aeDesc], keyErrorString, typeChar, @@ -202,7 +202,7 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags); * The descriptor can be coerced to UTF8 text. Evaluate as Tcl, or * or pass the text as a string argument to ::tk::mac::DoScriptText * if that procedure exists. - */ + */ char *data = ckalloc(actual + 1); if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeUTF8Text, &type, data, actual, NULL)) { @@ -274,7 +274,7 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags); static void tkMacOSXProcessFiles( - NSAppleEventDescriptor* event, + NSAppleEventDescriptor* event, NSAppleEventDescriptor* replyEvent, Tcl_Interp *interp, char* procedure) @@ -298,12 +298,12 @@ tkMacOSXProcessFiles( if (!interp || !Tcl_FindCommand(interp, procedure, NULL, 0)) { return; } - + fileSpecDesc = [event aeDesc]; if (fileSpecDesc == nil ) { return; } - + /* * The AppleEvent's descriptor should either contain a value of * typeObjectSpecifier or typeAEList. In the first case, the descriptor @@ -312,23 +312,23 @@ tkMacOSXProcessFiles( * itself. Values in the list will be coerced into fileURL's if possible; * otherwise they will be ignored. */ - + /* Get a copy of the AppleEvent's descriptor. */ AEGetParamDesc(fileSpecDesc, keyDirectObject, typeWildCard, &contents); if (contents.descriptorType == typeAEList) { fileSpecDesc = &contents; } - + if (AECountItems(fileSpecDesc, &count) != noErr) { AEDisposeDesc(&contents); return; } - - /* + + /* * Construct a Tcl command which calls the procedure, passing the * paths contained in the AppleEvent as arguments. */ - + Tcl_DStringInit(&command); Tcl_DStringAppend(&command, procedure, -1); @@ -341,7 +341,7 @@ tkMacOSXProcessFiles( continue; } URLString[actual] = '\0'; - fileURL = [NSURL URLWithString:[NSString stringWithUTF8String:(char*)URLString]]; + fileURL = [NSURL URLWithString:[NSString stringWithUTF8String:(char*)URLString]]; if (fileURL == nil) { continue; } @@ -358,7 +358,7 @@ tkMacOSXProcessFiles( code = Tcl_EvalEx(interp, Tcl_DStringValue(&command), Tcl_DStringLength(&command), TCL_EVAL_GLOBAL); if (code != TCL_OK) { - Tcl_BackgroundError(interp); + Tcl_BackgroundException(interp, code); } Tcl_DStringFree(&command); return; @@ -473,8 +473,8 @@ TkMacOSXDoHLEvent( * * ReallyKillMe -- * - * This proc tries to kill the shell by running exit, called from an - * event scheduled by the "Quit" AppleEvent handler. + * This procedure tries to kill the shell by running exit, called from + * an event scheduled by the "Quit" AppleEvent handler. * * Results: * Runs the "exit" command which might kill the shell. @@ -484,14 +484,14 @@ TkMacOSXDoHLEvent( * *---------------------------------------------------------------------- */ + static int ReallyKillMe( Tcl_Event *eventPtr, int flags) { Tcl_Interp *interp = ((KillEvent *) eventPtr)->interp; - Tcl_CmdInfo dummy; - int quit = Tcl_GetCommandInfo(interp, "::tk::mac::Quit", &dummy); + int quit = Tcl_FindCommand(interp, "::tk::mac::Quit", NULL, 0)!=NULL; int code = Tcl_EvalEx(interp, quit ? "::tk::mac::Quit" : "exit", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { @@ -499,7 +499,7 @@ ReallyKillMe( * Should be never reached... */ - Tcl_BackgroundError(interp); + Tcl_BackgroundException(interp, code); } return 1; } @@ -533,6 +533,7 @@ MissedAnyParameters( return (err != errAEDescNotFound); } + /* * Local Variables: |