]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - mac.c
We now have an event loop, albeit one which ignores everything going on
[PuTTY.git] / mac.c
1 /* $Id: mac.c,v 1.1.2.3 1999/02/19 23:51:21 ben Exp $ */
2 /*
3  * mac.c -- miscellaneous Mac-specific routines
4  */
5
6 #include <MacTypes.h>
7 #include <Quickdraw.h>
8 #include <Fonts.h>
9 #include <MacWindows.h>
10 #include <Menus.h>
11 #include <TextEdit.h>
12 #include <Dialogs.h>
13
14 #include <limits.h>
15 #include <stdarg.h>
16 #include <stdlib.h>             /* putty.h needs size_t */
17
18 #include "putty.h"
19
20 QDGlobals qd;
21
22 int cold = 1;
23
24 static void mac_startup(void);
25 static void mac_eventloop(void);
26
27 int main (int argc, char **argv) {
28
29     mac_startup();
30     mac_eventloop();
31 }
32
33 static void mac_startup(void) {
34     Handle menuBar;
35
36     /* Init QuickDraw */
37     InitGraf(&qd.thePort);
38     /* Init Font Manager */
39     InitFonts();
40     /* Init Window Manager */
41     InitWindows();
42     /* Init Menu Manager */
43     InitMenus();
44     /* Init TextEdit */
45     TEInit();
46     /* Init Dialog Manager */
47     InitDialogs(nil);
48     InitCursor();
49     cold = 0;
50     
51     menuBar = GetNewMBar(128);
52     if (menuBar == NULL)
53         fatalbox("Unable to create menu bar.");
54     SetMenuBar(menuBar);
55     AppendResMenu(GetMenuHandle(128), 'DRVR');
56     /* adjustmenus */
57     DrawMenuBar();
58 }
59
60 static void mac_eventloop(void) {
61     Boolean gotevent;
62     EventRecord event;
63     int i;
64
65     for (i = 0; i < 100; i++) {
66         gotevent = WaitNextEvent(everyEvent, &event, LONG_MAX, NULL);
67     }
68     fatalbox("I'm bored.");
69 }
70
71 void fatalbox(const char *fmt, ...) {
72     va_list ap;
73     Str255 stuff;
74     
75     va_start(ap, fmt);
76     /* We'd like stuff to be a Pascal string */
77     stuff[0] = vsprintf((char *)(&stuff[1]), fmt, ap);
78     va_end(ap);
79     ParamText(stuff, NULL, NULL, NULL);
80     StopAlert(128, nil);
81     exit(1);
82 }