X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/f8c9f9df8c6d537b3db60823b5920d78705b929b..3d9449a111194530856126f3dc89543d83fa0440:/macosx/osxwin.m diff --git a/macosx/osxwin.m b/macosx/osxwin.m index a54f771f..8166f913 100644 --- a/macosx/osxwin.m +++ b/macosx/osxwin.m @@ -207,6 +207,8 @@ { NSRect rect = { {0,0}, {0,0} }; + alert_ctx = NULL; + cfg = aCfg; /* structure copy */ init_ucs(&ucsdata, cfg.line_codepage, cfg.utf8_override, @@ -307,6 +309,7 @@ * terminal, the backend, the ldisc, the logctx, you name it. * Do so. */ + sfree(alert_ctx); [super dealloc]; } @@ -778,6 +781,23 @@ printf("n=%d c=U+%04x cm=U+%04x m=%08x\n", n, c, cm, m); 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 +{ + alert_callback(alert_ctx, returnCode); /* transfers ownership of ctx */ + alert_ctx = NULL; +} + @end int from_backend(void *frontend, int is_stderr, const char *data, int len)