-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreation.p.txt
More file actions
750 lines (670 loc) · 24.1 KB
/
Copy pathCreation.p.txt
File metadata and controls
750 lines (670 loc) · 24.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
PROGRAM Creation;
USES MemTypes, QuickDraw, OSintf, Toolintf, Packintf, Traps, PrintTraps;
{Functions and procedures}
FUNCTION IsAppWindow(window: WindowPtr): BOOLEAN;
FORWARD;
FUNCTION GetSleep: LONGINT;
FORWARD;
PROCEDURE AboutDialog;
FORWARD;
PROCEDURE AdjustMenus;
FORWARD;
PROCEDURE DoActivate(becomingActive: BOOLEAN);
FORWARD;
PROCEDURE DoKey ;
FORWARD;
PROCEDURE DoMenu(result: LONGINT);
FORWARD;
PROCEDURE DoUpdate;
FORWARD;
PROCEDURE Initialize;
FORWARD;
PROCEDURE PrintDoc;
FORWARD;
PROCEDURE SetupMenus;
FORWARD;
PROCEDURE UpdateActive;
FORWARD;
PROCEDURE UpdateRects;
FORWARD;
PROCEDURE FatalError(error: INTEGER);
FORWARD;
PROCEDURE AlertUser(error: INTEGER);
FORWARD;
FUNCTION TrapAvailable(tNumber: INTEGER; tType: TrapType) : BOOLEAN;
FORWARD;
PROCEDURE EventLoop;
FORWARD;
PROCEDURE AdjustCursor;
FORWARD;
PROCEDURE DoCloseWindow;
FORWARD;
PROCEDURE DoOpenWindow;
FORWARD;
CONST
kSysEnvironsVersion = 1; {Tells SysEnvirons what kind of SysEnvRec we understand}
kOSEvent = app4Evt; {event used by MultiFinder}
kSuspendResumeMessage = 1; {high byte of suspend/resume event message}
kResumeMask = 1;
kMouseMovedMessage = $FA;
kMinHeap = 29 * 1024;
kMinSpace = 20 * 1024; {Minimum memory needed for app to run}
kErrStrings = 128; {Resource ID for STR# resource}
eWrongMachine = 1; {Indicies into STR# resources}
eSmallSize = 2;
eNoMemory = 3;
eNoSpacePaste = 8;
{*** Resources ***}
rMenuBar = 128; {application's menu bar} rUserAlert = 129; {user error alert}
{*** Menu constants ***}
mApple = 128; {Apple menu}
iAbout = 1;
mFile = 129; {File menu}
iNew = 1;
iOpen = 2;
iClose = 4;
iPageSetup = 9;
iPrint = 10;
iQuit = 12;
mEdit = 130; {Edit menu}
iUndo = 1;
iCut = 3;
iCopy = 4;
iPaste = 5;
iClear = 6;
iSelectAll = 8;
mFont = 131; {Font menu (program fills in)}
mSize = 132; {Size menu (program fills in)}
mStyle = 133; {Style menu}
iPlain = 1;
iBold = 2;
iItalic = 3;
iUnderline = 4;
iOutline = 5;
iShadow = 6;
VAR
gStyle: TextStyle;
gMenu: MenuHandle;
gMac: SysEnvRec; {set up by Initialize}
gHasWaitNextEvent: BOOLEAN; {set up by Initialize}
ginBackground: BOOLEAN; {maintained by Initialize and DoEvent}
quit: BOOLEAN;
shiftDown: BOOLEAN;
theChar: Char;
templ: LONGINT;
mousePt: Point;
dragRect: Rect;
textRect: Rect;
myEvent: EventRecord;
myWindow: WindowPtr;
theWindow: WindowPtr;
iBeamHdl: CursHandle;
textH: TEHandle;
printH: THPrint;
fontArray: ARRAY [1 .. 64] OF INTEGER;
sizeArray: ARRAY [1..32] OF INTEGER;
{ ********** EXECUTABLE CODE STARTS HERE ********** }
{$S Main}
PROCEDURE AboutDialog;
VAR
aRect: Rect;
oldPort: GrafPtr;
aWindow: WindowPtr;
BEGIN
GetPort(oldPort);
WITH aRect DO
BEGIN
left := (screenbits.bounds.right - screenbits.bounds.left) DIV 2 - 100;
right := left + 200;
top := (screenbits.bounds.bottom - screenbits.bounds.top) DIV 2 - 50;
bottom := top + 110;
END;
aWindow := NewWindow(NIL, aRect, '', TRUE, dBoxProc, Pointer( - 1), TRUE, 0);
SetPort(aWindow);
TextFont(systemFont);
MoveTo(10, 40);
Drawstring(' Welcome to Creation!');
MoveTo(24, 70);
DrawString('By [Put your name here]');
REPEAT
SystemTask
UNTIL Button;
DisposeWindow(aWindow);
SetPort(oldPort);
FlushEvents(mUpMask + mDownMask, 0);
END; {AboutDialog}
{$S Main}
PROCEDURE AdjustMenus;
VAR
flag: BOOLEAN;
i : INTEGER;
lineHeight: INTEGER;
fontAscent: INTEGER;
n : LONGINT;
curStyle: TextStyle;
name: Str255;
item: Styleitem;
mode: INTEGER; { current style }
BEGIN
{clear check marks from the text menus}
gMenu := GetMHandle(mFont);
FOR i := 1 TO CountMItems(gMenu) DO
CheckItem(gMenu, i, FALSE);
gMenu := GetMHandle(mSize);
FOR i := 1 TO CountMItems(gMenu) DO
CheckItem(gMenu, i, FALSE);
gMenu := GetMHandle(mStyle);
FOR i := 1 TO CountMItems(gMenu) DO
CheckItem(gMenu, i, FALSE);
gMenu := GetMHandle(mFont);
FOR i := 1 TO CountMItems(gMenu) DO
BEGIN
gMenu := GetMHandle(mFont);
IF fontArray[i] = gStyle.tsFont THEN
CheckItem(gMenu, i, TRUE);
END;
gMenu := GetMHandle(mSize);
FOR i := 1 TO CountMItems(gMenu) DO
BEGIN
gMenu := GetMHandle(mSize);
IF sizeArray[i] = gStyle.tsSize THEN
CheckItem(gMenu, i, TRUE);
END;
gMenu := GetMHandle(mStyle); mode := doFace;
IF TEContinuousStyle(mode, gStyle, textH) THEN
BEGIN
CheckItem(gMenu, iPlain, gStyle.tsface=[]);
CheckItem(gMenu, iBold, bold IN gStyle.tsface);
CheckItem(gMenu, iItalic, italic IN gStyle.tsface);
CheckItem(gMenu, iUnderline, underline IN gStyle.tsface);
CheckItem(gMenu, iOutline, outline IN gStyle.tsface);
CheckItem(gMenu, iShadow, shadow IN gStyle.tsface);
END
ELSE
BEGIN
CheckItem(gMenu, iPlain, FALSE);
CheckItem(gMenu, iBold, FALSE);
CheckItem(gMenu, iItalic, FALSE);
CheckItem(gMenu, iUnderline, FALSE);
CheckItem(gMenu, iOutline, FALSE);
CheckItem(gMenu, iShadow, FALSE);
END; { IF }
END; {AdjustMenus}
{$S Main}
PROCEDURE DoActivate(becomingActive: BOOLEAN);
BEGIN
IF WindowPtr(myEvent.message) = myWindow THEN
BEGIN
IF becomingActive THEN
BEGIN
TEActivate(textH);
gMenu := GetMHandle(mEdit);
DisableItem(gMenu, 1);
END
ELSE
BEGIN
TEDeactivate(textH);
gMenu := GetMHandle(mEdit);
EnableItem(gMenu, 1);
END;
END;
END; {DoActivate}
{$S Main}
PROCEDURE DoKey ;
BEGIN
IF myWindow = FrontWindow THEN
theChar := CHR(BAND(myEvent.message, charCodeMask));
TEKey(theChar, textH);
END; {DoKey}
{$S Main}
PROCEDURE DoMenu(result: LONGINT);
CONST
doToggle = 32; {requires system 6.0}
VAR
bool: BOOLEAN;
theItem: INTEGER;
theMenu: INTEGER;
temp: INTEGER;
name: Str255;
ht, ascnt: INTEGER;
hack: INTEGER;
BEGIN
theItem := LoWord(result);
theMenu := HiWord(result);
InitCursor;
CASE theMenu OF
mApple: {Apple menu}
IF (theItem = 1) THEN
AboutDialog
ELSE
BEGIN
gMenu := GetMHandle(mApple);
GetItem(gMenu, theItem, name);
temp := OpenDeskAcc(name);
SetPort(myWindow);
END;
mFile: {File menu}
CASE theItem OF
iOpen: DoOpenWindow;
iClose: DoCloseWindow;
iPageSetup: bool := PrStlDialog(printH);
iPrint: IF PrJobDialog(printH) THEN PrintDoc;
iQuit: quit := TRUE;
END;
mEdit: {Edit menu}
BEGIN
IF NOT SystemEdit(theItem - 1) THEN
CASE theItem OF
iCut:
BEGIN {Cut}
templ := ZeroScrap;
TECut(textH);
END;
iCopy:
BEGIN {Copy}
templ := ZeroScrap;
TECopy(textH);
END;
iPaste: TEStylPaste(textH); {Paste}
iClear: TEDelete(textH); {Clear}
iSelectAll: TESetSelect(0, 32767, textH);
END;
END;
mFont: {Font menu}
BEGIN
gMenu := GetMHandle(mFont);
GetItem(gMenu, theItem, name);
GetFNum(name, temp);
gStyle.tsFont := temp;
TESetStyle(doFont, gStyle, TRUE, textH) ;
END;
mSize: {Size menu}
BEGIN
gMenu := GetMHandle(mSize);
GetItem(gMenu, theItem, name);
StringToNum(name, templ);
gStyle.tsSize := templ;
TESetStyle(doSize, gStyle, TRUE, textH);
END;
mStyle: {Style menu}
BEGIN
HiliteMenu (6);
IF theItem = 1 THEN
BEGIN
gStyle.tsface := [];
TESetStyle(doFace, gStyle, TRUE,textH) ;
END
ELSE
BEGIN
gStyle.tsface := [];
BitSet(@gStyle.tsface, 9 - theItem);
TESetStyle(doFace + doToggle, gStyle, TRUE, textH);
END;
END;
END;
HiliteMenu(0);
END; {DoMenu}
{$S Main}
PROCEDURE DoCloseWindow;
BEGIN
HideWindow(myWindow);
gMenu := GetMHandle(mFile);
DisableItem(gMenu, iClose);
EnableItem(gMenu, iOpen);
END; {DoCloseWindow}
{$S Main}
PROCEDURE DoOpenWindow;
BEGIN
ShowWindow(myWindow);
gMenu := GetMHandle(mFile);
DisableItem(gMenu, iOpen);
EnableItem(gMenu, iClose);
END; {DoOpenWindow}
{$S Main}
PROCEDURE DoMouse;
VAR
thePart: INTEGER;
BEGIN
thePart := FindWindow(myEvent.where,theWindow) ;
CASE thePart OF
inMenuBar:
BEGIN
AdjustMenus;
DoMenu(MenuSelect(myEvent.where));
END;
inSysWindow: SystemClick(myEvent, theWindow);
inContent:
BEGIN
IF theWindow <> FrontWindow THEN
SelectWindow(theWindow)
ELSE IF theWindow = myWindow THEN
BEGIN
GlobalToLocal(myEvent.where);
shiftDown := BAND(myEvent.modifiers,shiftKey) <> 0;
TEClick(myEvent.where, shiftDown, textH) ;
END;
END;
inDrag: DragWindow(theWindow, myEvent.where, dragRect);
inGrow:
BEGIN
templ := GrowWindow(theWindow, myEvent.where, screenbits.bounds);
InvalRect(theWindow^.portRect);
SizeWindow(theWindow, LoWord(templ), HiWord(templ), FALSE);
UpdateActive;
END;
inGoAway:
IF TrackGoAway(theWindow, myEvent.where) THEN
DoCloseWindow;
inZoomIn, inZoomOut:
IF TrackBox(theWindow, myEvent.where, thePart) THEN
BEGIN
ZoomWindow(theWindow, thePart, FALSE);
UpdateActive;
END;
END;
END; {DoMouse}
{$S Main}
PROCEDURE AdjustCursor; {give time to DAs, set cursor, flash cursor}
BEGIN
IF (myWindow = FrontWindow) THEN
BEGIN
GetMouse(mousePt);
IF PtInRect(mousePt, textRect) THEN
SetCursor(iBeamHdl^^)
ELSE
SetCursor(arrow);
TEIdle (textH) ;
END;
END; {AdjustCursor}
{$S Main}
PROCEDURE DoUpdate;
BEGIN
theWindow := WindowPtr(myEvent.message);
IF theWindow = myWindow THEN
BEGIN
SetPort(theWindow);
BeginUpdate(theWindow);
EraseRect(theWindow^.portRect);
TEUpdate(theWindow^.portRect, textH); {draw the text}
DrawGrowIcon(theWindow);
EndUpdate(theWindow);
END;
END; {DoUpdate}
{$S Initialize}
FUNCTION TrapAvailable(tNumber: INTEGER; tType: TrapType) : BOOLEAN;
BEGIN
IF (tType = ToolTrap) & (gMac.machineType > envMachUnknown) & (gMac.machineType < envMacII) THEN
BEGIN {512KE, Plus, or SE}
tNumber := BAND(tNumber, $03FF);
IF tNumber > $01FF THEN {which means the tool traps}
tNumber := _Unimplemented; {only go to $01FF}
END;
TrapAvailable := NGetTrapAddress(tNumber, tType) <> GetTrapAddress(_Unimplemented);
END; {TrapAvailable}
PROCEDURE Initialize;
VAR
count, ignoreError: INTEGER;
menuBar: Handle;
total, contig: LONGINT;
ignoreResult: BOOLEAN;
event: EventRecord;
BEGIN
ginBackground := FALSE;
FlushEvents(everyEvent, 0);
InitGraf(@ thePort);
InitFonts;
InitWindows;
InitMenus;
TEinit;
InitDialogs(NIL);
InitCursor;
PrOpen;
printH := THPrint(newHandle(SizeOf(TPrint)));
IF printH = NIL THEN DebugStr('Not enough memory for print record.');
PrintDefault(printH);
FOR count := 1 TO 3 DO {allow alert default button to be outlined}
ignoreResult := EventAvail(everyEvent, event) ;
ignoreError := SysEnvirons (kSysEnvironsVersion, gMac);
{If the machine doesn't have at least 128K ROMs, exit.}
IF gMac.machineType < 0 THEN
FatalError (eWrongMachine);
gHasWaitNextEvent := TrapAvailable (_WaitNextEvent, ToolTrap);
IF ORD(GetApplLimit) - ORD(ApplicZone) < kMinHeap THEN
FatalError(eSmallSize);
{* ZeroScrap; *} {*** You can uncomment this--TEMPORARILY --for debugging***}
PurgeSpace(total, contig);
IF total < kMinSpace THEN
IF UnloadScrap <> noErr THEN
FatalError(eNoMemory)
ELSE
BEGIN
PurgeSpace(total, contig);
IF total < kMinSpace THEN FatalError(eNoMemory);
END;
{*****Now we set up our application's environment ******}
SetupMenus;
SetRect(dragRect, - 32767, - 32767, 32767, 32767);
{WITH screenBits.bounds DO SetRect(textRect, 4, 24, right-4, bottom-4);}
WITH screenbits.bounds DO SetRect(textRect, 2, 24, right - 2, bottom - 2);
{InsetRect(textRect, 5, 20);}
InsetRect(textRect, 5, 15);
myWindow := NewWindow(NIL, textRect, 'Creation', TRUE, zoomDocProc, Pointer( - 1), TRUE, 0);
SetPort(myWindow);
UpdateRects;
TextFont(times);
TextSize(18);
textH := TEStylNew(textRect, textRect);
TEAutoView(TRUE, textH);
iBeamHdl := GetCursor(iBeamCursor);
quit := FALSE;
END; {Initialize}
{$S Main}
PROCEDURE PrintDoc; {print 1 page of text with its styles}
VAR
aRect: Rect;
printTE: TEHandle; printPort: TPPrPort; status: TPrStatus;
BEGIN
aRect := printH^^.rPaper;
InsetRect(aRect, 72, 72);
printPort := PrOpenDoc(printH, NIL, NIL);
printTE := TEStylNew(aRect, aRect);
IF printTE =NIL THEN DebugStr('Not enough memory to print TERec.');
printTE^^.inPort := GrafPtr(printPort);
{copy and paste our text and styles for print mgr}
TESetSelect(0, 32767, textH);
TECopy(textH);
TESetSelect(0, 0, textH);
TESetSelect(0, 0, printTE);
TEStylPaste(printTE);
PrOpenPage(printPort, NIL);
TEUpdate(aRect, printTE); {draw text on the printer}
PrClosePage(printPort);
PrCloseDoc(printPort);
TEDispose(printTE);
IF printH^^.prJob.bJDocLoop = bSpoolLoop THEN
PrPicFile(printH, NIL, NIL, NIL, status);
END; {PrintDoc}
{$S Main}
PROCEDURE SetupMenus;
VAR
i , n : INTEGER;
l : LONGINT; s: Str255;
menuBar: Handle;
BEGIN
menuBar := GetNewMBar(rMenuBar); {read menus into menu bar}
IF menuBar = NIL THEN
FatalError(eNoMemory);
SetMenuBar(menuBar); {install menus}
DisposHandle(menuBar);
AddResMenu(GetMHandle(mApple), 'DRVR'); {add DA names to Apple menu}
DrawMenuBar;
gMenu := GetMHandle(mFont);
AddResMenu(gMenu, 'FONT');
FOR i := 1 TO CountMItems(gMenu) DO
BEGIN
gMenu := GetMHandle(mFont);
GetItem(gMenu, i, s);
GetFNum(s, n);
fontArray[i] := n;
END;
gMenu := GetMHandle(mSize);
FOR i := 1 TO CountMItems(gMenu) DO
BEGIN
gMenu := GetMHandle(mSize);
GetItem(gMenu, i, s);
StringToNum(s, l);
sizeArray[i] := l;
END;
gMenu := GetMHandle(mFont);
FOR i := 1 TO CountMItems(gMenu) DO
BEGIN
gMenu := GetMHandle(mFont);
GetItem(gMenu, i, s);
GetFNum(s, n);
fontArray[i] := n;
END;
gMenu := GetMHandle(mSize);
FOR i := 1 TO CountMItems(gMenu) DO
BEGIN
gMenu := GetMHandle(mSize);
GetItem(gMenu, i, s);
StringToNum(s, l);
sizeArray[i] := l;
END;
END; {SetupMenus}
{$S Main}
PROCEDURE UpdateActive;
BEGIN
InvalRect(myWindow^.portRect);
UpdateRects;
WITH textH^^ DO
BEGIN
destRect := textRect;
viewRect := textRect;
END;
TECalText(textH);
END; {UpdateActive}
{$S Main}
PROCEDURE UpdateRects;
BEGIN
textRect := thePort^.portRect; WITH textRect DO
BEGIN
left := left + 4;
right := right - 20;
bottom := bottom - 20;
END;
END; {UpdateRects}
{$S Main}
PROCEDURE FatalError(error: INTEGER);
BEGIN
AlertUser(error);
ExitToShell;
END; {FatalError}
{$S Main}
PROCEDURE AlertUser(error: INTEGER);
{ Display an alert dialog when an error occurs }
VAR
itemHit: INTEGER;
message: Str255;
BEGIN
SetCursor(arrow);
GetindString(message, kErrStrings, error);
ParamText (message, '', '', '');
itemHit := Alert(rUserAlert, NIL);
END; {AlertUser}
{$S Main}
PROCEDURE EventLoop;
VAR
cursorRgn: RgnHandle;
gotEvent: BOOLEAN;
ignoreResult: BOOLEAN;
mouse: Point;
key: Char;
BEGIN
cursorRgn := NewRgn; {we'll pass an empty region to WNE the first time thru}
REPEAT
IF gHasWaitNextEvent THEN
ignoreResult := WaitNextEvent (everyEvent, myEvent, GetSleep,cursorRgn)
ELSE
BEGIN
SystemTask;
gotEvent := GetNextEvent(everyEvent, myEvent);
END;
AdjustCursor;
CASE myEvent.what OF
mouseDown: DoMouse;
keyDown, autoKey:
BEGIN
key := CHR(BAND(myEvent.message, charCodeMask));
IF BAND(myEvent.modifiers, cmdKey) <> 0 THEN
BEGIN { Command key down }
IF myEvent.what = keyDown THEN
BEGIN
AdjustMenus;
DoMenu(MenuKey(key));
END; {IF}
END
ELSE
DoKey;
END; {keyDown}
activateEvt: DoActivate (BAND(myEvent.modifiers, activeFlag) <> 0);
updateEvt: DoUpdate;
nullEvent: IF (textH <> NIL) THEN
IF (FrontWindow = myWindow) THEN TEidle (textH) ;
kOSEvent:
CASE BAND(BROTL(myEvent.message, 8), $FF)OF
kMouseMovedMessage: TEidle(textH);
kSuspendResumeMessage:
BEGIN
ginBackground := BAND(myEvent.message, kResumeMask) = 0;
DoActivate(NOT ginBackground) ;
END;
END;
END;
UNTIL quit;
PrClose;
END; {EventLoop}
{$S Main}
FUNCTION GetSleep: LONGINT;
VAR
sleep: LONGINT;
window: WindowPtr;
BEGIN
sleep := MAXLONGINT; {default value for sleep}
IF NOT ginBackground THEN
BEGIN {if we are in front ... }
window := FrontWindow; {and the front window is ours ... }
IF IsAppWindow(window) THEN
BEGIN
WITH textH^^ DO
IF selStart = selEnd THEN {and the selection is an insertion point ... }
sleep := GetCaretTime; {we need to blink the insertion point}
END;
END;
GetSleep := sleep;
END; {GetSleep}
{$S Main}
FUNCTION IsAppWindow(window: WindowPtr): BOOLEAN;
BEGIN
IF window = NIL THEN
IsAppWindow := FALSE
ELSE {application windows have windowKinds
userKind (8)}
WITH WindowPeek(window)^ DO IsAppWindow := (windowKind = userKind);
END; {IsAppWindow}
{********** THIS IS THE MAIN SEGMENT **********}
PROCEDURE _Datainit;
EXTERNAL;
{This routine is automatically linked in by the MPW Linker. This external reference to it is done so that we can unload its segment, %A5Init.}
{$S Main}
BEGIN
UnloadSeg(@_Datainit); {note that Datainit must not be in Main!}
MaxApplZone; {expand the heap so code segments load at the top}
Initialize; {initialize the program} UnloadSeg(@Initialize); {note that Initialize must not be in Main!}
gStyle.tsFont := times;
gStyle.tsface := [];
gStyle.tsSize := 12;
TESetStyle(doAll, gStyle, FALSE, textH);
AdjustMenus;
EventLoop; {call the main event loop}
END.