Add a Change Settings dialogue box. Doesn't do anything yet.
[u/mdw/putty] / mac / mac.c
1 /* $Id$ */
2 /*
3 * Copyright (c) 1999, 2003 Ben Harris
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>
32 #include <AEDataModel.h>
33 #include <AppleEvents.h>
34 #include <Controls.h>
35 #include <Quickdraw.h>
36 #include <Fonts.h>
37 #include <MacWindows.h>
38 #include <Menus.h>
39 #include <TextEdit.h>
40 #include <Appearance.h>
41 #include <CodeFragments.h>
42 #include <Dialogs.h>
43 #include <Devices.h>
44 #include <DiskInit.h>
45 #include <Gestalt.h>
46 #include <LowMem.h>
47 #include <Navigation.h>
48 #include <Resources.h>
49 #include <Script.h>
50 #include <TextCommon.h>
51 #include <ToolUtils.h>
52 #include <UnicodeConverter.h>
53
54 #include <assert.h>
55 #include <limits.h>
56 #include <stdarg.h>
57 #include <stdlib.h> /* putty.h needs size_t */
58 #include <stdio.h> /* for vsprintf */
59
60 #define PUTTY_DO_GLOBALS
61
62 #include "macresid.h"
63 #include "putty.h"
64 #include "ssh.h"
65 #include "terminal.h"
66 #include "mac.h"
67
68 Session *sesslist;
69
70 static int cold = 1;
71 static int borednow = FALSE;
72 struct mac_gestalts mac_gestalts;
73 UInt32 sleeptime;
74 static long timing_next_time;
75
76 static void mac_startup(void);
77 static void mac_eventloop(void);
78 #pragma noreturn (mac_eventloop)
79 static void mac_event(EventRecord *);
80 static void mac_contentclick(WindowPtr, EventRecord *);
81 static void mac_growwindow(WindowPtr, EventRecord *);
82 static void mac_activatewindow(WindowPtr, EventRecord *);
83 static void mac_suspendresume(EventRecord *);
84 static void mac_activateabout(WindowPtr, EventRecord *);
85 static void mac_updatewindow(WindowPtr);
86 static void mac_updatelicence(WindowPtr);
87 static void mac_keypress(EventRecord *);
88 static int mac_windowtype(WindowPtr);
89 static void mac_menucommand(long);
90 static void mac_openlicence(void);
91 static void mac_adjustcursor(RgnHandle);
92 static void mac_adjustmenus(void);
93 static void mac_closewindow(WindowPtr);
94 static void mac_zoomwindow(WindowPtr, short);
95 #pragma noreturn (cleanup_exit)
96
97 struct mac_windows {
98 WindowPtr about;
99 WindowPtr licence;
100 };
101
102 struct mac_windows windows;
103
104 int main (int argc, char **argv) {
105
106 mac_startup();
107 mac_eventloop();
108 }
109
110 #pragma noreturn (main)
111
112 static void mac_startup(void) {
113 Handle menuBar;
114 TECInfoHandle ti;
115
116 #if !TARGET_API_MAC_CARBON
117 /* Init Memory Manager */
118 MaxApplZone();
119 /* Init QuickDraw */
120 InitGraf(&qd.thePort);
121 /* Init Font Manager */
122 InitFonts();
123 /* Init Window Manager */
124 InitWindows();
125 /* Init Menu Manager */
126 InitMenus();
127 /* Init TextEdit */
128 TEInit();
129 /* Init Dialog Manager */
130 InitDialogs(NULL);
131 #endif
132 cold = 0;
133
134 /* Get base system version (only used if there's no better selector) */
135 if (Gestalt(gestaltSystemVersion, &mac_gestalts.sysvers) != noErr ||
136 (mac_gestalts.sysvers &= 0xffff) < 0x700)
137 fatalbox("PuTTY requires System 7 or newer");
138 /* Find out if we've got Color Quickdraw */
139 if (Gestalt(gestaltQuickdrawVersion, &mac_gestalts.qdvers) != noErr)
140 mac_gestalts.qdvers = gestaltOriginalQD;
141 /* ... and the Appearance Manager? */
142 if (Gestalt(gestaltAppearanceVersion, &mac_gestalts.apprvers) != noErr)
143 if (Gestalt(gestaltAppearanceAttr, NULL) == noErr)
144 mac_gestalts.apprvers = 0x0100;
145 else
146 mac_gestalts.apprvers = 0;
147 #if TARGET_RT_MAC_CFM
148 /* Paranoia: Did we manage to pull in AppearanceLib? */
149 if (&RegisterAppearanceClient == kUnresolvedCFragSymbolAddress)
150 mac_gestalts.apprvers = 0;
151 #endif
152 #if TARGET_CPU_68K
153 mac_gestalts.cntlattr = 0;
154 mac_gestalts.windattr = 0;
155 #else
156 /* Mac OS 8.5 Control Manager (proportional scrollbars)? */
157 if (Gestalt(gestaltControlMgrAttr, &mac_gestalts.cntlattr) != noErr ||
158 &SetControlViewSize == kUnresolvedCFragSymbolAddress)
159 mac_gestalts.cntlattr = 0;
160 /* Mac OS 8.5 Window Manager? */
161 if (Gestalt(gestaltWindowMgrAttr, &mac_gestalts.windattr) != noErr ||
162 &SetWindowContentColor == kUnresolvedCFragSymbolAddress)
163 mac_gestalts.windattr = 0;
164 /* Mac OS 8.5 Menu Manager? */
165 if (Gestalt(gestaltMenuMgrAttr, &mac_gestalts.menuattr) != noErr)
166 mac_gestalts.menuattr = 0;
167 #endif
168 /* Text Encoding Conversion Manager? */
169 if (
170 #if TARGET_RT_MAC_CFM
171 &TECGetInfo == kUnresolvedCFragSymbolAddress ||
172 #else
173 InitializeUnicodeConverter(NULL) != noErr ||
174 #endif
175 TECGetInfo(&ti) != noErr)
176 mac_gestalts.encvvers = 0;
177 else {
178 mac_gestalts.encvvers = (*ti)->tecVersion;
179 mac_gestalts.uncvattr = (*ti)->tecUnicodeConverterFeatures;
180 DisposeHandle((Handle)ti);
181 }
182 /* Navigation Services? */
183 if (NavServicesAvailable())
184 mac_gestalts.navsvers = NavLibraryVersion();
185 else
186 mac_gestalts.navsvers = 0;
187
188 sk_init();
189
190 /* We've been tested with the Appearance Manager */
191 if (mac_gestalts.apprvers != 0)
192 RegisterAppearanceClient();
193
194 menuBar = GetNewMBar(128);
195 if (menuBar == NULL)
196 fatalbox("Unable to create menu bar.");
197 SetMenuBar(menuBar);
198 AppendResMenu(GetMenuHandle(mApple), 'DRVR');
199 if (mac_gestalts.menuattr & gestaltMenuMgrAquaLayoutMask) {
200 DeleteMenuItem(GetMenuHandle(mFile), iQuit);
201 /* Also delete the separator above the Quit item. */
202 DeleteMenuItem(GetMenuHandle(mFile), iQuit - 1);
203 }
204 mac_adjustmenus();
205 DrawMenuBar();
206 InitCursor();
207 windows.about = NULL;
208 windows.licence = NULL;
209
210 default_protocol = be_default_protocol;
211 /* Find the appropriate default port. */
212 {
213 int i;
214 default_port = 0; /* illegal */
215 for (i = 0; backends[i].backend != NULL; i++)
216 if (backends[i].protocol == default_protocol) {
217 default_port = backends[i].backend->default_port;
218 break;
219 }
220 }
221 flags = FLAG_INTERACTIVE;
222
223 #if !TARGET_API_MAC_CARBON
224 {
225 short vol;
226 long dirid;
227
228 /* Set the default directory for loading and saving settings. */
229 /* XXX Should we create it? */
230 if (get_session_dir(FALSE, &vol, &dirid) == noErr) {
231 LMSetSFSaveDisk(-vol);
232 LMSetCurDirStore(dirid);
233 }
234 }
235 #endif
236
237 /* Install Apple Event handlers. */
238 AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
239 NewAEEventHandlerUPP(&mac_aevt_oapp), 0, FALSE);
240 AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
241 NewAEEventHandlerUPP(&mac_aevt_odoc), 0, FALSE);
242 AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
243 NewAEEventHandlerUPP(&mac_aevt_pdoc), 0, FALSE);
244 AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
245 NewAEEventHandlerUPP(&mac_aevt_quit), 0, FALSE);
246 }
247
248 void timer_change_notify(long next)
249 {
250 timing_next_time = next;
251 }
252
253 static void mac_eventloop(void) {
254 Boolean gotevent;
255 EventRecord event;
256 RgnHandle cursrgn;
257 long next;
258 long ticksleft;
259
260 cursrgn = NewRgn();
261 sleeptime = 0;
262 for (;;) {
263 mac_adjustcursor(cursrgn);
264 ticksleft=timing_next_time-GETTICKCOUNT();
265 if (sleeptime > ticksleft && ticksleft >=0)
266 sleeptime=ticksleft;
267 gotevent = WaitNextEvent(everyEvent, &event, sleeptime, cursrgn);
268 if (timing_next_time <= GETTICKCOUNT()) {
269 if (run_timers(timing_next_time, &next)) {
270 timer_change_notify(next);
271 }
272 }
273
274 /*
275 * XXX For now, limit sleep time to 1/10 s to work around
276 * wake-before-sleep race in MacTCP code.
277 */
278 sleeptime = 6;
279 mac_adjustcursor(cursrgn);
280 if (gotevent) {
281 /* Ensure we get a null event when the real ones run out. */
282 sleeptime = 0;
283 mac_event(&event);
284 if (borednow)
285 cleanup_exit(0);
286 }
287 if (!gotevent)
288 sk_poll();
289 mac_pollterm();
290 if (mac_gestalts.apprvers >= 0x100 && mac_frontwindow() != NULL)
291 IdleControls(mac_frontwindow());
292 }
293 DisposeRgn(cursrgn);
294 }
295
296 static void mac_event(EventRecord *event) {
297 short part;
298 WindowPtr window;
299
300 switch (event->what) {
301 case mouseDown:
302 part = FindWindow(event->where, &window);
303 switch (part) {
304 case inMenuBar:
305 mac_adjustmenus();
306 mac_menucommand(MenuSelect(event->where));
307 break;
308 #if !TARGET_API_MAC_CARBON
309 case inSysWindow:
310 SystemClick(event, window);
311 break;
312 #endif
313 case inContent:
314 if (window != FrontWindow())
315 /* XXX: check for movable modal dboxes? */
316 SelectWindow(window);
317 else
318 mac_contentclick(window, event);
319 break;
320 case inGoAway:
321 if (TrackGoAway(window, event->where))
322 mac_closewindow(window);
323 break;
324 case inDrag:
325 /* XXX: moveable modal check? */
326 #if TARGET_API_MAC_CARBON
327 {
328 BitMap screenBits;
329
330 GetQDGlobalsScreenBits(&screenBits);
331 DragWindow(window, event->where, &screenBits.bounds);
332 }
333 #else
334 DragWindow(window, event->where, &qd.screenBits.bounds);
335 #endif
336 break;
337 case inGrow:
338 mac_growwindow(window, event);
339 break;
340 case inZoomIn:
341 case inZoomOut:
342 if (TrackBox(window, event->where, part))
343 mac_zoomwindow(window, part);
344 break;
345 }
346 break;
347 case keyDown:
348 case autoKey:
349 mac_keypress(event);
350 break;
351 case activateEvt:
352 mac_activatewindow((WindowPtr)event->message, event);
353 break;
354 case updateEvt:
355 mac_updatewindow((WindowPtr)event->message);
356 break;
357 #if !TARGET_API_MAC_CARBON
358 case diskEvt:
359 if (HiWord(event->message) != noErr) {
360 Point pt;
361
362 SetPt(&pt, 120, 120);
363 DIBadMount(pt, event->message);
364 }
365 break;
366 #endif
367 case osEvt:
368 switch ((event->message & osEvtMessageMask) >> 24) {
369 case suspendResumeMessage:
370 mac_suspendresume(event);
371 break;
372 }
373 break;
374 case kHighLevelEvent:
375 AEProcessAppleEvent(event); /* errors? */
376 break;
377 }
378 }
379
380 static void mac_contentclick(WindowPtr window, EventRecord *event)
381 {
382
383 if (mac_wininfo(window)->click != NULL)
384 (*mac_wininfo(window)->click)(window, event);
385 }
386
387 static void mac_growwindow(WindowPtr window, EventRecord *event)
388 {
389
390 if (mac_wininfo(window)->grow != NULL)
391 (*mac_wininfo(window)->grow)(window, event);
392 }
393
394 static void mac_activatewindow(WindowPtr window, EventRecord *event)
395 {
396
397 mac_adjustmenus();
398 if (mac_wininfo(window)->activate != NULL)
399 (*mac_wininfo(window)->activate)(window, event);
400 }
401
402 static void mac_updatewindow(WindowPtr window)
403 {
404
405 if (mac_wininfo(window)->update != NULL)
406 (*mac_wininfo(window)->update)(window);
407 }
408
409 /*
410 * Work out what kind of window we're dealing with.
411 */
412 static int mac_windowtype(WindowPtr window)
413 {
414
415 #if !TARGET_API_MAC_CARBON
416 if (GetWindowKind(window) < 0)
417 return wDA;
418 #endif
419 return ((WinInfo *)GetWRefCon(window))->wtype;
420 }
421
422 /*
423 * Handle a key press
424 */
425 static void mac_keypress(EventRecord *event) {
426 WindowPtr window;
427
428 window = mac_frontwindow();
429 /*
430 * Check for a command-key combination, but ignore it if it counts
431 * as a meta-key combination and we're in a terminal window.
432 */
433 if (event->what == keyDown && (event->modifiers & cmdKey) /*&&
434 !((event->modifiers & cfg.meta_modifiers) == cfg.meta_modifiers &&
435 mac_windowtype(window) == wTerminal)*/) {
436 mac_adjustmenus();
437 mac_menucommand(MenuKey(event->message & charCodeMask));
438 } else {
439 if (window != NULL && mac_wininfo(window)->key != NULL)
440 (*mac_wininfo(window)->key)(window, event);
441 }
442 }
443
444 static void mac_menucommand(long result) {
445 short menu, item;
446 WindowPtr window;
447 #if !TARGET_API_MAC_CARBON
448 Str255 da;
449 #endif
450
451 menu = HiWord(result);
452 item = LoWord(result);
453 window = mac_frontwindow();
454 /* Things which do the same whatever window we're in. */
455 switch (menu) {
456 case mApple:
457 switch (item) {
458 case iAbout:
459 mac_openabout();
460 goto done;
461 #if !TARGET_API_MAC_CARBON
462 default:
463 GetMenuItemText(GetMenuHandle(mApple), item, da);
464 OpenDeskAcc(da);
465 goto done;
466 #endif
467 }
468 break;
469 case mFile:
470 switch (item) {
471 case iNew:
472 mac_newsession();
473 goto done;
474 case iOpen:
475 mac_opensession();
476 goto done;
477 case iChange:
478 mac_reconfig();
479 goto done;
480 case iClose:
481 mac_closewindow(window);
482 goto done;
483 case iSave:
484 mac_savesession();
485 goto done;
486 case iSaveAs:
487 mac_savesessionas();
488 goto done;
489 case iDuplicate:
490 mac_dupsession();
491 goto done;
492 case iQuit:
493 cleanup_exit(0);
494 goto done;
495 }
496 break;
497 }
498 /* If we get here, handling is up to window-specific code. */
499 if (window != NULL && mac_wininfo(window)->menu != NULL)
500 (*mac_wininfo(window)->menu)(window, menu, item);
501
502 done:
503 HiliteMenu(0);
504 }
505
506 static void mac_closewindow(WindowPtr window) {
507
508 switch (mac_windowtype(window)) {
509 #if !TARGET_API_MAC_CARBON
510 case wDA:
511 CloseDeskAcc(GetWindowKind(window));
512 break;
513 #endif
514 default:
515 if (mac_wininfo(window)->close != NULL)
516 (*mac_wininfo(window)->close)(window);
517 break;
518 }
519 }
520
521 static void mac_suspendresume(EventRecord *event)
522 {
523 WindowPtr front;
524 EventRecord fakeevent;
525
526 /*
527 * We're called either before we're suspended or after we're
528 * resumed, so we're the front application at this point.
529 */
530 front = FrontWindow();
531 if (front != NULL) {
532 fakeevent.what = activateEvt;
533 fakeevent.message = (UInt32)front;
534 fakeevent.when = event->when;
535 fakeevent.where = event->where;
536 fakeevent.modifiers =
537 (event->message & resumeFlag) ? activeFlag : 0;
538 mac_activatewindow(front, &fakeevent);
539 }
540 }
541
542 static void mac_zoomwindow(WindowPtr window, short part) {
543
544 /* FIXME: do something */
545 }
546
547 /*
548 * Make the menus look right before the user gets to see them.
549 */
550 #if TARGET_API_MAC_CARBON
551 #define EnableItem EnableMenuItem
552 #define DisableItem DisableMenuItem
553 #endif
554 static void mac_adjustmenus(void) {
555 WindowPtr window;
556 MenuHandle menu;
557
558 window = mac_frontwindow();
559 menu = GetMenuHandle(mApple);
560 EnableItem(menu, 0);
561 EnableItem(menu, iAbout);
562
563 menu = GetMenuHandle(mFile);
564 EnableItem(menu, 0);
565 EnableItem(menu, iNew);
566 if (window != NULL)
567 EnableItem(menu, iClose);
568 else
569 DisableItem(menu, iClose);
570 EnableItem(menu, iQuit);
571
572 if (window != NULL && mac_wininfo(window)->adjustmenus != NULL)
573 (*mac_wininfo(window)->adjustmenus)(window);
574 else {
575 DisableItem(menu, iChange);
576 DisableItem(menu, iSave);
577 DisableItem(menu, iSaveAs);
578 DisableItem(menu, iDuplicate);
579 menu = GetMenuHandle(mEdit);
580 DisableItem(menu, 0);
581 menu = GetMenuHandle(mWindow);
582 DisableItem(menu, 0); /* Until we get more than 1 item on it. */
583 }
584 DrawMenuBar();
585 }
586
587 /*
588 * Make sure the right cursor's being displayed.
589 */
590 static void mac_adjustcursor(RgnHandle cursrgn) {
591 Point mouse;
592 WindowPtr window, front;
593 short part;
594 #if TARGET_API_MAC_CARBON
595 Cursor arrow;
596 RgnHandle visrgn;
597 #endif
598
599 GetMouse(&mouse);
600 LocalToGlobal(&mouse);
601 part = FindWindow(mouse, &window);
602 front = FrontWindow();
603 if (part != inContent || window == NULL || window != front) {
604 /* Cursor isn't in the front window, so switch to arrow */
605 #if TARGET_API_MAC_CARBON
606 GetQDGlobalsArrow(&arrow);
607 SetCursor(&arrow);
608 #else
609 SetCursor(&qd.arrow);
610 #endif
611 SetRectRgn(cursrgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX);
612 if (front != NULL) {
613 #if TARGET_API_MAC_CARBON
614 visrgn = NewRgn();
615 GetPortVisibleRegion(GetWindowPort(front), visrgn);
616 DiffRgn(cursrgn, visrgn, cursrgn);
617 DisposeRgn(visrgn);
618 #else
619 DiffRgn(cursrgn, front->visRgn, cursrgn);
620 #endif
621 }
622 } else {
623 if (mac_wininfo(window)->adjustcursor != NULL)
624 (*mac_wininfo(window)->adjustcursor)(window, mouse, cursrgn);
625 else {
626 #if TARGET_API_MAC_CARBON
627 GetQDGlobalsArrow(&arrow);
628 SetCursor(&arrow);
629 GetPortVisibleRegion(GetWindowPort(window), cursrgn);
630 #else
631 SetCursor(&qd.arrow);
632 CopyRgn(window->visRgn, cursrgn);
633 #endif
634 }
635 }
636 }
637
638 pascal OSErr mac_aevt_quit(const AppleEvent *req, AppleEvent *reply,
639 long refcon)
640 {
641 DescType type;
642 Size size;
643
644 if (AEGetAttributePtr(req, keyMissedKeywordAttr, typeWildCard,
645 &type, NULL, 0, &size) == noErr)
646 return errAEParamMissed;
647
648 borednow = 1;
649 return noErr;
650 }
651
652 void cleanup_exit(int status)
653 {
654
655 #if !TARGET_RT_MAC_CFM
656 if (mac_gestalts.encvvers != 0)
657 TerminateUnicodeConverter();
658 #endif
659 sk_cleanup();
660 exit(status);
661 }
662
663 /* This should only kill the current session, not the whole application. */
664 void connection_fatal(void *fontend, char *fmt, ...) {
665 va_list ap;
666 Str255 stuff;
667
668 va_start(ap, fmt);
669 /* We'd like stuff to be a Pascal string */
670 stuff[0] = vsprintf((char *)(&stuff[1]), fmt, ap);
671 va_end(ap);
672 ParamText(stuff, NULL, NULL, NULL);
673 StopAlert(128, NULL);
674 cleanup_exit(1);
675 }
676
677 /* Null SSH agent client -- never finds an agent. */
678
679 int agent_exists(void)
680 {
681
682 return FALSE;
683 }
684
685 int agent_query(void *in, int inlen, void **out, int *outlen,
686 void (*callback)(void *, void *, int), void *callback_ctx)
687 {
688
689 *out = NULL;
690 *outlen = 0;
691 return 1;
692 }
693
694 /* Temporary null routines for testing. */
695
696 void verify_ssh_host_key(void *frontend, char *host, int port, char *keytype,
697 char *keystr, char *fingerprint)
698 {
699 Str255 stuff;
700 Session *s = frontend;
701
702 /*
703 * This function is horribly wrong. For one thing, the alert
704 * shouldn't be modal, it should be movable modal, or a sheet in
705 * Aqua. Also, PuTTY might be in the background, in which case we
706 * should use the Notification Manager to wake up the user. In
707 * any case, we shouldn't hold up processing of other connections'
708 * data just because this one's waiting for the user. It should
709 * also handle a host key cache, of course, and see the note below
710 * about closing the connection. All in all, a bit of a mess
711 * really.
712 */
713
714 stuff[0] = sprintf((char *)(&stuff[1]),
715 "The server's key fingerprint is: %s\n"
716 "Continue connecting?", fingerprint);
717 ParamText(stuff, NULL, NULL, NULL);
718 if (CautionAlert(wQuestion, NULL) == 2) {
719 /*
720 * User chose "Cancel". Unfortunately, if I tear the
721 * connection down here, Bad Things happen when I return. I
722 * think this function should actually return something
723 * telling the SSH code to abandon the connection.
724 */
725 }
726 }
727
728 void askalg(void *frontend, const char *algtype, const char *algname)
729 {
730
731 }
732
733 void old_keyfile_warning(void)
734 {
735
736 }
737
738 FontSpec platform_default_fontspec(char const *name)
739 {
740 FontSpec ret;
741 long smfs;
742
743 if (!strcmp(name, "Font")) {
744 smfs = GetScriptVariable(smSystemScript, smScriptMonoFondSize);
745 if (smfs == 0)
746 smfs = GetScriptVariable(smRoman, smScriptMonoFondSize);
747 if (smfs != 0) {
748 GetFontName(HiWord(smfs), ret.name);
749 if (ret.name[0] == 0)
750 memcpy(ret.name, "\pMonaco", 7);
751 ret.size = LoWord(smfs);
752 } else {
753 memcpy(ret.name, "\pMonaco", 7);
754 ret.size = 9;
755 }
756 ret.face = 0;
757 } else {
758 ret.name[0] = 0;
759 }
760
761 return ret;
762 }
763
764 Filename platform_default_filename(const char *name)
765 {
766 Filename ret;
767 if (!strcmp(name, "LogFileName"))
768 FSMakeFSSpec(0, 0, "\pputty.log", &ret.fss);
769 else
770 memset(&ret, 0, sizeof(ret));
771 return ret;
772 }
773
774 char *platform_default_s(char const *name)
775 {
776 return NULL;
777 }
778
779 int platform_default_i(char const *name, int def)
780 {
781
782 /* Non-raw cut and paste of line-drawing chars works badly on the
783 * current Unix stub implementation of the Unicode functions.
784 * So I'm going to temporarily set the default to raw mode so
785 * that the failure mode isn't quite so drastically horrid.
786 * When Unicode comes in, this can all be put right. */
787 if (!strcmp(name, "RawCNP"))
788 return 1;
789 return def;
790 }
791
792 void platform_get_x11_auth(char *display, int *proto,
793 unsigned char *data, int *datalen)
794 {
795 /* SGT: I have no idea whether Mac X servers need anything here. */
796 }
797
798 void update_specials_menu(void *frontend)
799 {
800 Session *s = frontend;
801 WindowPtr front;
802
803 front = mac_frontwindow();
804 if (front != NULL && mac_windowsession(front) == s)
805 mac_adjustmenus();
806 }
807
808 void notify_remote_exit(void *fe) { /* XXX anything needed here? */ }
809
810 /*
811 * Local Variables:
812 * c-file-style: "simon"
813 * End:
814 */