f854b482 |
1 | /* $Id: mac.c,v 1.49 2003/02/15 16:22:15 ben Exp $ */ |
d082ac49 |
2 | /* |
f854b482 |
3 | * Copyright (c) 1999, 2003 Ben Harris |
d082ac49 |
4 | * All rights reserved. |
5 | * |
6 | * Permission is hereby granted, free of charge, to any person |
7 | * obtaining a copy of this software and associated documentation |
8 | * files (the "Software"), to deal in the Software without |
9 | * restriction, including without limitation the rights to use, |
10 | * copy, modify, merge, publish, distribute, sublicense, and/or |
11 | * sell copies of the Software, and to permit persons to whom the |
12 | * Software is furnished to do so, subject to the following |
13 | * conditions: |
14 | * |
15 | * The above copyright notice and this permission notice shall be |
16 | * included in all copies or substantial portions of the Software. |
17 | * |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR |
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
23 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
25 | * SOFTWARE. |
26 | */ |
27 | /* |
28 | * mac.c -- miscellaneous Mac-specific routines |
29 | */ |
30 | |
31 | #include <MacTypes.h> |
97cfddb2 |
32 | #include <AEDataModel.h> |
33 | #include <AppleEvents.h> |
d082ac49 |
34 | #include <Quickdraw.h> |
35 | #include <Fonts.h> |
36 | #include <MacWindows.h> |
37 | #include <Menus.h> |
38 | #include <TextEdit.h> |
39 | #include <Appearance.h> |
40 | #include <CodeFragments.h> |
41 | #include <Dialogs.h> |
42 | #include <Devices.h> |
43 | #include <DiskInit.h> |
44 | #include <Gestalt.h> |
bf873e8e |
45 | #include <LowMem.h> |
9ef3c1ca |
46 | #include <Navigation.h> |
d082ac49 |
47 | #include <Resources.h> |
36577dc9 |
48 | #include <Script.h> |
8768ce31 |
49 | #include <TextCommon.h> |
d082ac49 |
50 | #include <ToolUtils.h> |
8768ce31 |
51 | #include <UnicodeConverter.h> |
d082ac49 |
52 | |
53 | #include <assert.h> |
54 | #include <limits.h> |
55 | #include <stdarg.h> |
56 | #include <stdlib.h> /* putty.h needs size_t */ |
57 | #include <stdio.h> /* for vsprintf */ |
58 | |
59 | #define PUTTY_DO_GLOBALS |
60 | |
61 | #include "macresid.h" |
62 | #include "putty.h" |
0c4b7799 |
63 | #include "ssh.h" |
d082ac49 |
64 | #include "mac.h" |
65 | |
0c4b7799 |
66 | Session *sesslist; |
67 | |
d082ac49 |
68 | static int cold = 1; |
97cfddb2 |
69 | static int borednow = FALSE; |
d082ac49 |
70 | struct mac_gestalts mac_gestalts; |
71 | |
72 | static void mac_startup(void); |
73 | static void mac_eventloop(void); |
74 | #pragma noreturn (mac_eventloop) |
75 | static void mac_event(EventRecord *); |
76 | static void mac_contentclick(WindowPtr, EventRecord *); |
77 | static void mac_growwindow(WindowPtr, EventRecord *); |
78 | static void mac_activatewindow(WindowPtr, EventRecord *); |
79 | static void mac_activateabout(WindowPtr, EventRecord *); |
80 | static void mac_updatewindow(WindowPtr); |
ebd78b62 |
81 | static void mac_updatelicence(WindowPtr); |
d082ac49 |
82 | static void mac_keypress(EventRecord *); |
83 | static int mac_windowtype(WindowPtr); |
84 | static void mac_menucommand(long); |
ebd78b62 |
85 | static void mac_openlicence(void); |
d082ac49 |
86 | static void mac_adjustcursor(RgnHandle); |
87 | static void mac_adjustmenus(void); |
88 | static void mac_closewindow(WindowPtr); |
89 | static void mac_zoomwindow(WindowPtr, short); |
0c4b7799 |
90 | #pragma noreturn (cleanup_exit) |
d082ac49 |
91 | |
92 | struct mac_windows { |
93 | WindowPtr about; |
94 | WindowPtr licence; |
95 | }; |
96 | |
97 | struct mac_windows windows; |
98 | |
99 | int main (int argc, char **argv) { |
100 | |
101 | mac_startup(); |
102 | mac_eventloop(); |
103 | } |
104 | |
105 | #pragma noreturn (main) |
106 | |
107 | static void mac_startup(void) { |
108 | Handle menuBar; |
8768ce31 |
109 | TECInfoHandle ti; |
d082ac49 |
110 | |
fc34fbaf |
111 | #if !TARGET_API_MAC_CARBON |
d082ac49 |
112 | /* Init Memory Manager */ |
113 | MaxApplZone(); |
114 | /* Init QuickDraw */ |
115 | InitGraf(&qd.thePort); |
116 | /* Init Font Manager */ |
117 | InitFonts(); |
118 | /* Init Window Manager */ |
119 | InitWindows(); |
120 | /* Init Menu Manager */ |
121 | InitMenus(); |
122 | /* Init TextEdit */ |
123 | TEInit(); |
124 | /* Init Dialog Manager */ |
f3ab148c |
125 | InitDialogs(NULL); |
fc34fbaf |
126 | #endif |
d082ac49 |
127 | cold = 0; |
128 | |
56ed4cf7 |
129 | /* Get base system version (only used if there's no better selector) */ |
130 | if (Gestalt(gestaltSystemVersion, &mac_gestalts.sysvers) != noErr || |
6e1063b1 |
131 | (mac_gestalts.sysvers &= 0xffff) < 0x700) |
56ed4cf7 |
132 | fatalbox("PuTTY requires System 7 or newer"); |
d082ac49 |
133 | /* Find out if we've got Color Quickdraw */ |
134 | if (Gestalt(gestaltQuickdrawVersion, &mac_gestalts.qdvers) != noErr) |
135 | mac_gestalts.qdvers = gestaltOriginalQD; |
136 | /* ... and the Appearance Manager? */ |
137 | if (Gestalt(gestaltAppearanceVersion, &mac_gestalts.apprvers) != noErr) |
138 | if (Gestalt(gestaltAppearanceAttr, NULL) == noErr) |
139 | mac_gestalts.apprvers = 0x0100; |
140 | else |
141 | mac_gestalts.apprvers = 0; |
142 | #if TARGET_RT_MAC_CFM |
143 | /* Paranoia: Did we manage to pull in AppearanceLib? */ |
144 | if (&RegisterAppearanceClient == kUnresolvedCFragSymbolAddress) |
145 | mac_gestalts.apprvers = 0; |
146 | #endif |
1fc898ea |
147 | #if TARGET_CPU_68K |
148 | mac_gestalts.cntlattr = 0; |
149 | mac_gestalts.windattr = 0; |
150 | #else |
d082ac49 |
151 | /* Mac OS 8.5 Control Manager (proportional scrollbars)? */ |
1fc898ea |
152 | if (Gestalt(gestaltControlMgrAttr, &mac_gestalts.cntlattr) != noErr || |
153 | &SetControlViewSize == kUnresolvedCFragSymbolAddress) |
d082ac49 |
154 | mac_gestalts.cntlattr = 0; |
155 | /* Mac OS 8.5 Window Manager? */ |
1fc898ea |
156 | if (Gestalt(gestaltWindowMgrAttr, &mac_gestalts.windattr) != noErr || |
157 | &SetWindowContentColor == kUnresolvedCFragSymbolAddress) |
d082ac49 |
158 | mac_gestalts.windattr = 0; |
1fc898ea |
159 | #endif |
8768ce31 |
160 | /* Text Encoding Conversion Manager? */ |
161 | if ( |
162 | #if TARGET_RT_MAC_CFM |
163 | &TECGetInfo == kUnresolvedCFragSymbolAddress || |
164 | #else |
165 | InitializeUnicodeConverter(NULL) != noErr || |
166 | #endif |
167 | TECGetInfo(&ti) != noErr) |
168 | mac_gestalts.encvvers = 0; |
169 | else { |
170 | mac_gestalts.encvvers = (*ti)->tecVersion; |
379836ca |
171 | mac_gestalts.uncvattr = (*ti)->tecUnicodeConverterFeatures; |
8768ce31 |
172 | DisposeHandle((Handle)ti); |
173 | } |
9ef3c1ca |
174 | /* Navigation Services? */ |
175 | if (NavServicesAvailable()) |
176 | mac_gestalts.navsvers = NavLibraryVersion(); |
177 | else |
178 | mac_gestalts.navsvers = 0; |
97cfddb2 |
179 | |
f6fc0010 |
180 | sk_init(); |
2beb0fb0 |
181 | |
d082ac49 |
182 | /* We've been tested with the Appearance Manager */ |
183 | if (mac_gestalts.apprvers != 0) |
184 | RegisterAppearanceClient(); |
185 | |
186 | menuBar = GetNewMBar(128); |
187 | if (menuBar == NULL) |
188 | fatalbox("Unable to create menu bar."); |
189 | SetMenuBar(menuBar); |
190 | AppendResMenu(GetMenuHandle(mApple), 'DRVR'); |
191 | mac_adjustmenus(); |
192 | DrawMenuBar(); |
193 | InitCursor(); |
194 | windows.about = NULL; |
195 | windows.licence = NULL; |
196 | |
ffa79828 |
197 | default_protocol = be_default_protocol; |
198 | /* Find the appropriate default port. */ |
199 | { |
ffa79828 |
200 | int i; |
1adaeb2e |
201 | default_port = 0; /* illegal */ |
ffa79828 |
202 | for (i = 0; backends[i].backend != NULL; i++) |
203 | if (backends[i].protocol == default_protocol) { |
204 | default_port = backends[i].backend->default_port; |
205 | break; |
206 | } |
207 | } |
0c4b7799 |
208 | flags = FLAG_INTERACTIVE; |
209 | |
fc34fbaf |
210 | #if !TARGET_API_MAC_CARBON |
bf873e8e |
211 | { |
212 | short vol; |
213 | long dirid; |
214 | |
215 | /* Set the default directory for loading and saving settings. */ |
216 | /* XXX Should we create it? */ |
217 | if (get_session_dir(FALSE, &vol, &dirid) == noErr) { |
218 | LMSetSFSaveDisk(-vol); |
219 | LMSetCurDirStore(dirid); |
220 | } |
221 | } |
fc34fbaf |
222 | #endif |
97cfddb2 |
223 | |
224 | /* Install Apple Event handlers. */ |
d70e3b83 |
225 | AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, |
226 | NewAEEventHandlerUPP(&mac_aevt_oapp), 0, FALSE); |
227 | AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, |
228 | NewAEEventHandlerUPP(&mac_aevt_odoc), 0, FALSE); |
229 | AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, |
230 | NewAEEventHandlerUPP(&mac_aevt_pdoc), 0, FALSE); |
97cfddb2 |
231 | AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, |
232 | NewAEEventHandlerUPP(&mac_aevt_quit), 0, FALSE); |
d082ac49 |
233 | } |
234 | |
235 | static void mac_eventloop(void) { |
236 | Boolean gotevent; |
237 | EventRecord event; |
238 | RgnHandle cursrgn; |
239 | |
240 | cursrgn = NewRgn(); |
241 | for (;;) { |
242 | mac_adjustcursor(cursrgn); |
243 | gotevent = WaitNextEvent(everyEvent, &event, LONG_MAX, cursrgn); |
244 | mac_adjustcursor(cursrgn); |
245 | if (gotevent) |
246 | mac_event(&event); |
97cfddb2 |
247 | if (borednow) |
248 | cleanup_exit(0); |
f6fc0010 |
249 | sk_poll(); |
0c4b7799 |
250 | mac_pollterm(); |
d082ac49 |
251 | } |
252 | DisposeRgn(cursrgn); |
253 | } |
254 | |
255 | static void mac_event(EventRecord *event) { |
256 | short part; |
257 | WindowPtr window; |
d082ac49 |
258 | |
259 | switch (event->what) { |
260 | case mouseDown: |
261 | part = FindWindow(event->where, &window); |
262 | switch (part) { |
263 | case inMenuBar: |
264 | mac_adjustmenus(); |
265 | mac_menucommand(MenuSelect(event->where)); |
266 | break; |
fc34fbaf |
267 | #if !TARGET_API_MAC_CARBON |
d082ac49 |
268 | case inSysWindow: |
269 | SystemClick(event, window); |
270 | break; |
fc34fbaf |
271 | #endif |
d082ac49 |
272 | case inContent: |
273 | if (window != FrontWindow()) |
274 | /* XXX: check for movable modal dboxes? */ |
275 | SelectWindow(window); |
276 | else |
277 | mac_contentclick(window, event); |
278 | break; |
279 | case inGoAway: |
280 | if (TrackGoAway(window, event->where)) |
281 | mac_closewindow(window); |
282 | break; |
283 | case inDrag: |
284 | /* XXX: moveable modal check? */ |
fc34fbaf |
285 | #if TARGET_API_MAC_CARBON |
286 | { |
287 | BitMap screenBits; |
288 | |
289 | GetQDGlobalsScreenBits(&screenBits); |
290 | DragWindow(window, event->where, &screenBits.bounds); |
291 | } |
292 | #else |
d082ac49 |
293 | DragWindow(window, event->where, &qd.screenBits.bounds); |
fc34fbaf |
294 | #endif |
d082ac49 |
295 | break; |
296 | case inGrow: |
297 | mac_growwindow(window, event); |
298 | break; |
299 | case inZoomIn: |
300 | case inZoomOut: |
301 | if (TrackBox(window, event->where, part)) |
302 | mac_zoomwindow(window, part); |
303 | break; |
304 | } |
305 | break; |
306 | case keyDown: |
307 | case autoKey: |
308 | mac_keypress(event); |
309 | break; |
310 | case activateEvt: |
311 | mac_activatewindow((WindowPtr)event->message, event); |
312 | break; |
313 | case updateEvt: |
314 | mac_updatewindow((WindowPtr)event->message); |
315 | break; |
fc34fbaf |
316 | #if !TARGET_API_MAC_CARBON |
d082ac49 |
317 | case diskEvt: |
318 | if (HiWord(event->message) != noErr) { |
fc34fbaf |
319 | Point pt; |
320 | |
d082ac49 |
321 | SetPt(&pt, 120, 120); |
322 | DIBadMount(pt, event->message); |
323 | } |
324 | break; |
fc34fbaf |
325 | #endif |
97cfddb2 |
326 | case kHighLevelEvent: |
327 | AEProcessAppleEvent(event); /* errors? */ |
328 | break; |
d082ac49 |
329 | } |
330 | } |
331 | |
f854b482 |
332 | static void mac_contentclick(WindowPtr window, EventRecord *event) |
333 | { |
d082ac49 |
334 | |
f854b482 |
335 | if (mac_wininfo(window)->click != NULL) |
336 | (*mac_wininfo(window)->click)(window, event); |
d082ac49 |
337 | } |
338 | |
f854b482 |
339 | static void mac_growwindow(WindowPtr window, EventRecord *event) |
340 | { |
d082ac49 |
341 | |
f854b482 |
342 | if (mac_wininfo(window)->grow != NULL) |
343 | (*mac_wininfo(window)->grow)(window, event); |
d082ac49 |
344 | } |
345 | |
f854b482 |
346 | static void mac_activatewindow(WindowPtr window, EventRecord *event) |
347 | { |
d082ac49 |
348 | |
d082ac49 |
349 | mac_adjustmenus(); |
f854b482 |
350 | if (mac_wininfo(window)->activate != NULL) |
351 | (*mac_wininfo(window)->activate)(window, event); |
d082ac49 |
352 | } |
353 | |
fc34fbaf |
354 | static void mac_updatewindow(WindowPtr window) |
355 | { |
d082ac49 |
356 | |
f854b482 |
357 | if (mac_wininfo(window)->update != NULL) |
358 | (*mac_wininfo(window)->update)(window); |
d082ac49 |
359 | } |
360 | |
361 | /* |
362 | * Work out what kind of window we're dealing with. |
d082ac49 |
363 | */ |
347bfcd7 |
364 | static int mac_windowtype(WindowPtr window) |
365 | { |
366 | |
367 | #if !TARGET_API_MAC_CARBON |
368 | if (GetWindowKind(window) < 0) |
d082ac49 |
369 | return wDA; |
347bfcd7 |
370 | #endif |
371 | return ((WinInfo *)GetWRefCon(window))->wtype; |
d082ac49 |
372 | } |
373 | |
374 | /* |
375 | * Handle a key press |
376 | */ |
377 | static void mac_keypress(EventRecord *event) { |
378 | WindowPtr window; |
379 | |
380 | window = FrontWindow(); |
381 | /* |
382 | * Check for a command-key combination, but ignore it if it counts |
383 | * as a meta-key combination and we're in a terminal window. |
384 | */ |
385 | if (event->what == keyDown && (event->modifiers & cmdKey) /*&& |
386 | !((event->modifiers & cfg.meta_modifiers) == cfg.meta_modifiers && |
387 | mac_windowtype(window) == wTerminal)*/) { |
388 | mac_adjustmenus(); |
389 | mac_menucommand(MenuKey(event->message & charCodeMask)); |
390 | } else { |
f854b482 |
391 | if (mac_wininfo(window)->key != NULL) |
392 | (*mac_wininfo(window)->key)(window, event); |
d082ac49 |
393 | } |
394 | } |
395 | |
396 | static void mac_menucommand(long result) { |
397 | short menu, item; |
d082ac49 |
398 | WindowPtr window; |
fc34fbaf |
399 | #if !TARGET_API_MAC_CARBON |
400 | Str255 da; |
401 | #endif |
d082ac49 |
402 | |
403 | menu = HiWord(result); |
404 | item = LoWord(result); |
405 | window = FrontWindow(); |
406 | /* Things which do the same whatever window we're in. */ |
407 | switch (menu) { |
408 | case mApple: |
409 | switch (item) { |
410 | case iAbout: |
411 | mac_openabout(); |
412 | goto done; |
cc2be455 |
413 | #if !TARGET_API_MAC_CARBON |
d082ac49 |
414 | default: |
415 | GetMenuItemText(GetMenuHandle(mApple), item, da); |
416 | OpenDeskAcc(da); |
417 | goto done; |
cc2be455 |
418 | #endif |
d082ac49 |
419 | } |
420 | break; |
421 | case mFile: |
422 | switch (item) { |
423 | case iNew: |
424 | mac_newsession(); |
425 | goto done; |
ce283213 |
426 | case iOpen: |
427 | mac_opensession(); |
428 | goto done; |
d082ac49 |
429 | case iClose: |
430 | mac_closewindow(window); |
431 | goto done; |
b537dd42 |
432 | case iSave: |
433 | mac_savesession(); |
434 | goto done; |
435 | case iSaveAs: |
436 | mac_savesessionas(); |
437 | goto done; |
5211281f |
438 | case iDuplicate: |
439 | mac_dupsession(); |
440 | goto done; |
d082ac49 |
441 | case iQuit: |
0c4b7799 |
442 | cleanup_exit(0); |
d082ac49 |
443 | goto done; |
444 | } |
445 | break; |
446 | } |
447 | /* If we get here, handling is up to window-specific code. */ |
f854b482 |
448 | if (mac_wininfo(window)->menu != NULL) |
449 | (*mac_wininfo(window)->menu)(window, menu, item); |
450 | |
d082ac49 |
451 | done: |
452 | HiliteMenu(0); |
453 | } |
454 | |
d082ac49 |
455 | static void mac_closewindow(WindowPtr window) { |
456 | |
457 | switch (mac_windowtype(window)) { |
fc34fbaf |
458 | #if !TARGET_API_MAC_CARBON |
d082ac49 |
459 | case wDA: |
347bfcd7 |
460 | CloseDeskAcc(GetWindowKind(window)); |
d082ac49 |
461 | break; |
fc34fbaf |
462 | #endif |
f854b482 |
463 | default: |
464 | if (mac_wininfo(window)->close != NULL) |
465 | (*mac_wininfo(window)->close)(window); |
d082ac49 |
466 | break; |
467 | } |
468 | } |
469 | |
470 | static void mac_zoomwindow(WindowPtr window, short part) { |
471 | |
472 | /* FIXME: do something */ |
473 | } |
474 | |
475 | /* |
476 | * Make the menus look right before the user gets to see them. |
477 | */ |
fc34fbaf |
478 | #if TARGET_API_MAC_CARBON |
fc34fbaf |
479 | #define EnableItem EnableMenuItem |
480 | #define DisableItem DisableMenuItem |
481 | #endif |
d082ac49 |
482 | static void mac_adjustmenus(void) { |
483 | WindowPtr window; |
484 | MenuHandle menu; |
485 | |
486 | window = FrontWindow(); |
487 | menu = GetMenuHandle(mApple); |
488 | EnableItem(menu, 0); |
489 | EnableItem(menu, iAbout); |
490 | |
491 | menu = GetMenuHandle(mFile); |
492 | EnableItem(menu, 0); |
493 | EnableItem(menu, iNew); |
494 | if (window != NULL) |
495 | EnableItem(menu, iClose); |
496 | else |
497 | DisableItem(menu, iClose); |
498 | EnableItem(menu, iQuit); |
499 | |
f854b482 |
500 | if (mac_wininfo(window)->adjustmenus != NULL) |
501 | (*mac_wininfo(window)->adjustmenus)(window); |
502 | else { |
b537dd42 |
503 | DisableItem(menu, iSave); |
504 | DisableItem(menu, iSaveAs); |
5211281f |
505 | DisableItem(menu, iDuplicate); |
d082ac49 |
506 | menu = GetMenuHandle(mEdit); |
507 | DisableItem(menu, 0); |
7dcd1f87 |
508 | menu = GetMenuHandle(mWindow); |
509 | DisableItem(menu, 0); /* Until we get more than 1 item on it. */ |
d082ac49 |
510 | } |
511 | DrawMenuBar(); |
512 | } |
513 | |
514 | /* |
515 | * Make sure the right cursor's being displayed. |
516 | */ |
517 | static void mac_adjustcursor(RgnHandle cursrgn) { |
518 | Point mouse; |
519 | WindowPtr window, front; |
520 | short part; |
fc34fbaf |
521 | #if TARGET_API_MAC_CARBON |
522 | Cursor arrow; |
523 | RgnHandle visrgn; |
524 | #endif |
d082ac49 |
525 | |
526 | GetMouse(&mouse); |
527 | LocalToGlobal(&mouse); |
528 | part = FindWindow(mouse, &window); |
529 | front = FrontWindow(); |
530 | if (part != inContent || window == NULL || window != front) { |
531 | /* Cursor isn't in the front window, so switch to arrow */ |
fc34fbaf |
532 | #if TARGET_API_MAC_CARBON |
533 | GetQDGlobalsArrow(&arrow); |
534 | SetCursor(&arrow); |
535 | #else |
d082ac49 |
536 | SetCursor(&qd.arrow); |
fc34fbaf |
537 | #endif |
d082ac49 |
538 | SetRectRgn(cursrgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX); |
fc34fbaf |
539 | if (front != NULL) { |
540 | #if TARGET_API_MAC_CARBON |
541 | visrgn = NewRgn(); |
542 | GetPortVisibleRegion(GetWindowPort(front), visrgn); |
543 | DiffRgn(cursrgn, visrgn, cursrgn); |
544 | DisposeRgn(visrgn); |
545 | #else |
d082ac49 |
546 | DiffRgn(cursrgn, front->visRgn, cursrgn); |
fc34fbaf |
547 | #endif |
548 | } |
d082ac49 |
549 | } else { |
f854b482 |
550 | if (mac_wininfo(window)->adjustcursor != NULL) |
551 | (*mac_wininfo(window)->adjustcursor)(window, mouse, cursrgn); |
552 | else { |
fc34fbaf |
553 | #if TARGET_API_MAC_CARBON |
554 | GetQDGlobalsArrow(&arrow); |
555 | SetCursor(&arrow); |
556 | GetPortVisibleRegion(GetWindowPort(window), cursrgn); |
557 | #else |
d082ac49 |
558 | SetCursor(&qd.arrow); |
559 | CopyRgn(window->visRgn, cursrgn); |
fc34fbaf |
560 | #endif |
d082ac49 |
561 | } |
562 | } |
563 | } |
564 | |
d70e3b83 |
565 | pascal OSErr mac_aevt_quit(const AppleEvent *req, AppleEvent *reply, |
97cfddb2 |
566 | long refcon) |
567 | { |
d70e3b83 |
568 | DescType type; |
569 | Size size; |
570 | |
571 | if (AEGetAttributePtr(req, keyMissedKeywordAttr, typeWildCard, |
572 | &type, NULL, 0, &size) == noErr) |
573 | return errAEParamMissed; |
97cfddb2 |
574 | |
575 | borednow = 1; |
576 | return noErr; |
577 | } |
578 | |
0c4b7799 |
579 | void cleanup_exit(int status) |
580 | { |
d082ac49 |
581 | |
713b8b7a |
582 | #if !TARGET_RT_MAC_CFM |
8768ce31 |
583 | if (mac_gestalts.encvvers != 0) |
584 | TerminateUnicodeConverter(); |
713b8b7a |
585 | #endif |
27a3458f |
586 | sk_cleanup(); |
0c4b7799 |
587 | exit(status); |
d082ac49 |
588 | } |
589 | |
2beb0fb0 |
590 | /* This should only kill the current session, not the whole application. */ |
591 | void connection_fatal(void *fontend, char *fmt, ...) { |
592 | va_list ap; |
593 | Str255 stuff; |
594 | |
595 | va_start(ap, fmt); |
596 | /* We'd like stuff to be a Pascal string */ |
597 | stuff[0] = vsprintf((char *)(&stuff[1]), fmt, ap); |
598 | va_end(ap); |
599 | ParamText(stuff, NULL, NULL, NULL); |
600 | StopAlert(128, NULL); |
04b0fa02 |
601 | cleanup_exit(1); |
2beb0fb0 |
602 | } |
603 | |
0c4b7799 |
604 | /* Null SSH agent client -- never finds an agent. */ |
605 | |
606 | int agent_exists(void) |
607 | { |
608 | |
609 | return FALSE; |
610 | } |
611 | |
612 | void agent_query(void *in, int inlen, void **out, int *outlen) |
613 | { |
614 | |
615 | *out = NULL; |
616 | *outlen = 0; |
617 | } |
618 | |
619 | /* Temporary null routines for testing. */ |
620 | |
621 | void verify_ssh_host_key(void *frontend, char *host, int port, char *keytype, |
622 | char *keystr, char *fingerprint) |
623 | { |
624 | |
625 | } |
626 | |
627 | void askcipher(void *frontend, char *ciphername, int cs) |
628 | { |
629 | |
630 | } |
631 | |
632 | void old_keyfile_warning(void) |
633 | { |
634 | |
635 | } |
636 | |
e3c5b245 |
637 | FontSpec platform_default_fontspec(char const *name) |
5a9eb105 |
638 | { |
9a30e26b |
639 | FontSpec ret; |
a499fbf9 |
640 | long smfs; |
a499fbf9 |
641 | |
642 | if (!strcmp(name, "Font")) { |
643 | smfs = GetScriptVariable(smSystemScript, smScriptMonoFondSize); |
644 | if (smfs == 0) |
645 | smfs = GetScriptVariable(smRoman, smScriptMonoFondSize); |
646 | if (smfs != 0) { |
e3c5b245 |
647 | GetFontName(HiWord(smfs), ret.name); |
648 | if (ret.name[0] == 0) |
649 | memcpy(ret.name, "\pMonaco", 7); |
650 | ret.size = LoWord(smfs); |
9a30e26b |
651 | } else { |
e3c5b245 |
652 | memcpy(ret.name, "\pMonaco", 7); |
653 | ret.size = 9; |
9a30e26b |
654 | } |
e3c5b245 |
655 | ret.face = 0; |
9a30e26b |
656 | } else { |
e3c5b245 |
657 | ret.name[0] = 0; |
a499fbf9 |
658 | } |
9a30e26b |
659 | |
660 | return ret; |
661 | } |
662 | |
663 | Filename platform_default_filename(const char *name) |
664 | { |
665 | Filename ret; |
666 | if (!strcmp(name, "LogFileName")) |
02cf4001 |
667 | FSMakeFSSpec(0, 0, "\pputty.log", &ret.fss); |
9a30e26b |
668 | else |
02cf4001 |
669 | memset(&ret, 0, sizeof(ret)); |
9a30e26b |
670 | return ret; |
671 | } |
672 | |
673 | char *platform_default_s(char const *name) |
674 | { |
5a9eb105 |
675 | return NULL; |
676 | } |
677 | |
f5d2d791 |
678 | int platform_default_i(char const *name, int def) |
5a9eb105 |
679 | { |
a499fbf9 |
680 | |
5a9eb105 |
681 | /* Non-raw cut and paste of line-drawing chars works badly on the |
682 | * current Unix stub implementation of the Unicode functions. |
683 | * So I'm going to temporarily set the default to raw mode so |
684 | * that the failure mode isn't quite so drastically horrid. |
685 | * When Unicode comes in, this can all be put right. */ |
686 | if (!strcmp(name, "RawCNP")) |
687 | return 1; |
688 | return def; |
689 | } |
690 | |
e0e7dff8 |
691 | void platform_get_x11_auth(char *display, int *proto, |
692 | unsigned char *data, int *datalen) |
693 | { |
694 | /* SGT: I have no idea whether Mac X servers need anything here. */ |
695 | } |
696 | |
d082ac49 |
697 | /* |
698 | * Local Variables: |
699 | * c-file-style: "simon" |
700 | * End: |
701 | */ |