{
NSRect rect = { {0,0}, {0,0} };
+ alert_ctx = NULL;
+
cfg = aCfg; /* structure copy */
init_ucs(&ucsdata, cfg.line_codepage, cfg.utf8_override,
* terminal, the backend, the ldisc, the logctx, you name it.
* Do so.
*/
+ sfree(alert_ctx);
[super dealloc];
}
return term_data(term, is_stderr, data, len);
}
+- (void)startAlert:(NSAlert *)alert
+ withCallback:(void (*)(void *, int))callback andCtx:(void *)ctx
+{
+ alert_callback = callback;
+ alert_ctx = ctx; /* NB this is assumed to need freeing! */
+ [alert beginSheetModalForWindow:self modalDelegate:self
+ didEndSelector:@selector(alertSheetDidEnd:returnCode:contextInfo:)
+ contextInfo:NULL];
+}
+
+- (void)alertSheetDidEnd:(NSAlert *)alert returnCode:(int)returnCode
+ contextInfo:(void *)contextInfo
+{
+ [self performSelectorOnMainThread:
+ @selector(alertSheetDidFinishEnding:)
+ withObject:[NSNumber numberWithInt:returnCode]
+ waitUntilDone:NO];
+}
+
+- (void)alertSheetDidFinishEnding:(id)object
+{
+ int returnCode = [object intValue];
+ void (*this_callback)(void *, int);
+ void *this_ctx;
+
+ /*
+ * We must save the values of our alert_callback and alert_ctx
+ * fields, in case they are set up again by the callback
+ * function!
+ */
+ this_callback = alert_callback;
+ this_ctx = alert_ctx;
+ alert_ctx = NULL;
+
+ this_callback(this_ctx, returnCode); /* transfers ownership of ctx */
+}
+
@end
int from_backend(void *frontend, int is_stderr, const char *data, int len)