-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtia.backup
1967 lines (1741 loc) · 65.5 KB
/
tia.backup
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
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- text editor
with ada.text_io, -- for printing results in non-interactive modes
ada.command_line, -- for return result code
common,
os, -- clock and O/S stuff for Ken's windows
strings, -- Ken's string functions
userio, -- Ken's ASCII drawing stuff
controls, -- controls for Ken's windows
windows, -- Ken's windows
english,
tiacommon;
use common, os, strings, userio, controls, windows, english,
tiacommon;
Pragma Optimize( Space ); -- make program as small as possible
procedure tia is ---------------------------------------------------
-- Main Program ================================================
SourceBox : aliased ASourceEditList;
SourceBar : aliased AScrollBar;
Done : boolean := false; -- quitting program
Text2Find : str255 := NullStr255;
Text2Replace : str255 := NullStr255;
FindBackwards : boolean := false;
Replacing : boolean := false;
procedure EditMacros is
MacroList : Str255List.List;
MacrosToSave : Str255List.List;
WasChanges : boolean;
s : str255;
begin
if NotEmpty( To255( "$SYS/macro_file" ) ) then
LoadList( To255( "$SYS/macro_file" ), MacroList );
end if;
Str255List.Queue( MacroList, NullStr255 );
EditListInfo( "Macro List", 0, 0, 79, 24, MacroList, WasChanges );
if WasChanges then
while Str255List.length( MacroList ) > 0 loop
Str255List.Pull( MacroList, s );
if length( s ) > 0 then
Str255List.Push( MacrosToSave, s );
end if;
end loop;
SaveList( To255( "$SYS/macro_file" ), MacrosToSave );
if LastError = CoreOK then
NoteAlert( "Restart the program to see changes." );
else
SessionLog( "EditMacros: Error saving file", LastError );
StopAlert( "Error saving file: # " & AnErrorCode'image(
LastError ) );
end if;
Str255List.Clear( MacrosToSave );
end if;
Str255List.Clear( MacroList );
end EditMacros;
function FindDialog return boolean is
TextLine : aliased AnEditLine;
FindButton : aliased ASimpleButton;
CancelButton : aliased ASimpleButton;
BackwardsButton : aliased ACheckBox;
ReplaceButton : aliased ASimpleButton;
ReplaceLabel : aliased AStaticLine;
ReplaceLine : aliased AnEditLine;
DT : ADialogTaskRecord;
FindNotCancelled : boolean := true;
-- Text2Find is defined in encompasing procedure
begin
OpenWindow( To255( "Find/Replace Text" ), 10, 9, 70, 17, Normal );
Init( TextLine, 1, 2, 58, 2 );
SetText( TextLine, Text2Find );
AddControl( EditLine, TextLine'unchecked_access, false );
Init( ReplaceLabel, 1, 4, 9, 4 );
SetText( Replacelabel, To255( "Replace:" ) );
AddControl( StaticLine, ReplaceLabel'unchecked_access, false );
Init( ReplaceLine, 10, 4, 58, 4 );
SetText( ReplaceLine, Text2Replace );
AddControl( EditLine, ReplaceLine'unchecked_access, false );
Init( FindButton, 2, 6, 11, 6, s_Find_Hot );
SetText( FindButton, s_Find );
SetInstant( FindButton );
AddControl( SimpleButton, FindButton'unchecked_access, false );
Init( CancelButton, 17, 6, 26, 6, s_Cancel_Hot );
SetText( CancelButton, s_Cancel );
SetInstant( CancelButton );
AddControl( SimpleButton, CancelButton'unchecked_access, false );
Init( BackwardsButton, 31, 6, 40, 6, 'b' );
SetText( BackwardsButton, To255( "Back" ) );
SetCheck( BackwardsButton, FindBackwards );
AddControl( CheckBox, BackwardsButton'unchecked_access, false );
Init( ReplaceButton, 45, 6, 56, 6, 'r' );
SetText( ReplaceButton, To255( "Replace" ) );
SetInstant( ReplaceButton );
AddControl( SimpleButton, ReplaceButton'unchecked_access, false );
loop
DoDialog( DT );
case DT.control is
when 4 => Text2Find := GetText( TextLine );
Text2Replace := NullStr255;
FindBackwards := GetCheck( BackwardsButton );
Replacing := false;
exit;
when 5 => FindNotCancelled := false; -- find cancelled
Text2Find := NullStr255;
Text2Replace := NullStr255;
Replacing := false;
exit;
when 7 => Text2Find := GetText( TextLine );
Text2Replace := GetText( ReplaceLine );
FindBackwards := GetCheck( BackwardsButton );
Replacing := true;
exit;
when others => null;
end case;
end loop;
CloseWindow;
return FindNotCancelled;
end FindDialog;
procedure SaveSource( DoBackgroundUpdate : boolean := true;
ForcePrompt : boolean := false ) is
-- save the current source file
-- DoBackgroundUpdate - if on, will quietly compile in
-- background
-- ForcePrompt - to "save as" ... prompt for new filename
ProjectDir : str255;
TempHeader : str255list.list;
ssf : ASelectSaveFileRec;
begin
TempHeader := GetList( SourceBox );
if Str255List.length( TempHeader ) = 0 then
if length( SourcePath ) > 0 then -- if untitled, don't bother
NoteAlert( "Blank source file not saved" );
end if;
SessionLog( "Blank source file not saved" );
return;
elsif length( SourcePath ) = 0 or ForcePrompt then
ProjectDir := GetPath;
ssf.Prompt := To255( "Save as ..." );
ssf.Default := To255( "untitled.adb" );
SelectSaveFile( ssf );
-- ssf changes current path, but we want to stick to the
-- project directory by default. Get..Title will show
-- absolute path if source not in current (project) directory.
if ssf.replied then
SourcePath := ssf.path & "/" & ssf.fname;
SetPath( ProjectDir ); -- restore old path
end if;
if (not ssf.replied) or (length( SourcePath ) = 0) then
SessionLog( ssf.Prompt & " was cancelled" );
SetPath( ProjectDir ); -- restore old path
return;
end if;
end if;
--TempHeader := GetList( SourceBox );
SaveList( SourcePath, TempHeader );
if LastError = CoreOK then
SessionLog( "Saved as " & SourcePath );
else
SessionLog( "SaveSource: Error saving file", LastError );
StopAlert( "Error saving file: # " & AnErrorCode'image(
LastError ) );
end if;
if DoBackgroundUpdate then
BackgroundUpdate( SourcePath );
end if;
pragma Debug( SessionLog( "SaveSource: Before update source path is " & ToString( SourcePath ) ) );
UpdateQuickOpen( SourcePath,
GetCurrent( SourceBox ), GetPosition( SourceBox ) );
pragma Debug( SessionLog( "SaveSource: After update source path is " & ToString( SourcePath ) ) );
end SaveSource;
procedure ShowLineStats is
StatsLine : Str255;
Alloc : long_integer;
begin
Str255List.GetAllocation( alloc );
StatsLine := Str255List.AListIndex'image( GetCurrent( SourceBox ) ) &
To255( "/" & Str255List.AListIndex'image( GetLength( SourceBox ) ) &
" line(s) " & Str255List.AListIndex'image(
GetLength( SourceBox ) / 66 ) &
" pages " & long_integer'image( Alloc / 1024 ) &
" K used " & long_integer'image( Freemem / 1024 / 1024 ) &
" Meg total free" );
SetInfoText( StatsLine );
end ShowLineStats;
procedure CheckSource is
-- check source for syntax errors
ErrFile : Str255;
begin
SaveSource( DoBackgroundUpdate => false );
MakeTempFileName( ErrFile );
-- NOTE: if I add C support, don't forget -Wall
--
-- ShellOut( "gcc -O -c -gnatc " & SourcePath & " 2> " & ErrFile );
-- gnatf is supposed to be faster than gcc -gnatc, according to manual
-- -x2 produces spurious warnings in packages, so it's now -x1
--ShellOut( "gnatf -f -E -x1 -o " & SourcePath & " 2> " & ErrFile );
-- gnatf not included in 3.11 beta
if Proj_Egcs then
ShellOut( "egcs -O -c -gnatc -gnatf " & SourcePath & " " &
Proj_MakeOptions & " 2> " & ErrFile );
else
ShellOut( "gcc -O -c -gnatc -gnatf " & SourcePath & " " &
Proj_MakeOptions & " 2> " & ErrFile );
end if;
ClearGnatErrors;
LoadList( ErrFile, GnatErrors );
Erase( ErrFile );
if Str255List.Length( GnatErrors ) > 0 then
ShowListInfo( "Gnat Errors", 0, 1, 78, 23, GnatErrors );
else
NoteAlert( "File is OK" );
end if;
end CheckSource;
procedure StubSource is
-- produce a new package body from a spec using gnatstub
NewPath : Str255;
SPLen : natural;
begin
SPLen := length( SourcePath );
if Slice( SourcePath, SPLen-3, SPLen ) /= ".ads" then
CautionAlert( "You can only stub a package spec" );
SessionLog( "You can only stub a package spec" );
return;
end if;
NewPath := To255( Slice( SourcePath, 1, SPLen-4 ) & ".adb" );
if IsFile( NewPath ) then
if NoAlert( "Overwrite existing package body?", Warning ) then
SessionLog( "User decided not to overwrite body with stub" );
return;
end if;
SaveSource( DoBackgroundUpdate => false );
SessionLog( "Stubbing " & SourcePath );
if not UNIX( "gnatstub " & SourcePath ) then
StopAlert( "gnatstub reported problems" );
SessionLog( "gnatstub reported problems" );
end if;
end if;
end StubSource;
procedure XrefSource is
-- this should really use a radio list and allow goto
TempPath : Str255;
TempList : Str255List.List;
--RadioList : Str255List.List;
Filename : Str255;
begin
SessionLog( "XrefSource: crossreferencing " & SourcePath );
SplitPath( SourcePath, TempPath, Filename );
if length( Filename ) = 0 and length( TempPath ) = 0 then
Filename := SourcePath; -- kludge
elsif length( Filename ) = 0 then
Filename := TempPath;
end if;
MakeTempFileName( TempPath );
SaveSource( DoBackgroundUpdate => false );
SetInfoText( "Crossreferencing..." );
UNIX( "gnatxref -v " & SourcePath &
" | grep " & Filename &
" | sort > " & TempPath );
SetInfoText( "Sorting..." );
LoadList( TempPath, TempList );
Erase( TempPath );
ShowListInfo( "Crossrefences", 0, 1, DisplayInfo.H_Res-1,
DisplayInfo.V_Res-1, TempList );
SetInfoText( "" );
Str255List.Clear( TempList );
end XrefSource;
procedure OptionsWindow is
QuietBox : aliased ACheckBox; -- 1
OKButton : aliased ASimpleButton; -- 2
DT : ADialogTaskRecord;
begin
OpenWindow( To255( "Options" ), 1, 4, 78, 23, Normal );
Init( QuietBox, 42, 15, 61, 15, 'q' );
SetText( QuietBox, To255( "Quiet Updates" ) );
AddControl( CheckBox, QuietBox'unchecked_access, false );
Init( OKButton, 35, 17, 50, 17, 'o' );
SetText( OKButton, To255( "OK" ) );
AddControl( SimpleButton, OKButton'unchecked_access, false );
SetCheck( QuietBox, Opt_Quiet );
loop
DoDialog( DT );
case DT.control is
when 2 => exit;
when others => null;
end case;
end loop;
Opt_Quiet := GetCheck( QuietBox );
CloseWindow;
end OptionsWindow;
procedure ProjectParams is
-- edit project parameters
MakeLabel : aliased AStaticLine; -- 1
MakeLine : aliased AnEditLine; -- 2
LinkLabel : aliased AStaticLine; -- 3
LinkLine : aliased AnEditLine; -- 4
MainLabel : aliased AStaticLine; -- 5
MainLine : aliased AnEditLine; -- 6
OptLabel : aliased AStaticLine; -- 7
OptBox1 : aliased ARadioButton; -- 8
OptBox2 : aliased ARadioButton; -- 9
OptBox3 : aliased ARadioButton; -- 10
OptBox4 : aliased ARadioButton; -- 11
CPULabel : aliased AStaticLine; -- 12
CPUBox1 : aliased ARadioButton; -- 13
CPUBox2 : aliased ARadioButton; -- 14
CPUBox3 : aliased ARadioButton; -- 15
CPUBox4 : aliased ARadioButton; -- 16
DebugLabel: aliased AStaticLine; -- 17
DebugBox1 : aliased ARadioButton; -- 18
DebugBox2 : aliased ARadioButton; -- 19
DebugBox3 : aliased ARadioButton; -- 20
KindLabel : aliased AStaticLine; -- 21
KindBox1 : aliased ARadioButton; -- 22
KindBox2 : aliased ARadioButton; -- 23
KindBox3 : aliased ARadioButton; -- 24
KindBox4 : aliased ARadioButton; -- 25
BuildLabel: aliased AStaticLine; -- 26
BuildBox1 : aliased ARadioButton; -- 27
BuildBox2 : aliased ARadioButton; -- 28
BuildBox3 : aliased ARadioButton; -- 29
StaticBox : aliased ACheckBox; -- 30
EgcsBox : aliased ACheckBox; -- 31
QuietBox : aliased ACheckBox; -- 32
OKButton : aliased ASimpleButton; -- 33
DT : ADialogTaskRecord;
begin
OpenWindow( To255( "Project Parameters" ), 1, 4, 78, 23, Normal );
Init( MakeLabel, 1, 2, 10, 2 );
SetText( MakeLabel, To255( "Compiling:" ) );
SetStyle( MakeLabel, Bold );
SetColour( MakeLabel, Yellow );
AddControl( StaticLine, MakeLabel'unchecked_access, false );
Init( MakeLine, 11, 2, 75, 2 );
SetText( MakeLine, Proj_MakeOptions );
AddControl( EditLine, MakeLine'unchecked_access, false );
Init( LinkLabel, 1, 4, 10, 4 );
SetText( LinkLabel, To255( "Linking:" ) );
SetStyle( LinkLabel, Bold );
SetColour( LinkLabel, Yellow );
AddControl( StaticLine, LinkLabel'unchecked_access, false );
Init( LinkLine, 11, 4, 75, 4 );
SetText( LinkLine, Proj_LinkOptions );
AddControl( EditLine, LinkLine'unchecked_access, false );
Init( MainLabel, 1, 6, 10, 6 );
SetText( MainLabel, To255( "Program:" ) );
SetStyle( MainLabel, Bold );
SetColour( MainLabel, Yellow );
AddControl( StaticLine, MainLabel'unchecked_access, false );
Init( MainLine, 11, 6, 75, 6 );
SetText( MainLine, Proj_Main );
AddControl( EditLine, MainLine'unchecked_access, false );
Init( OptLabel, 1, 8, 10, 8 );
SetText( OptLabel, To255( "Optimize:" ) );
SetStyle( OptLabel, Bold );
SetColour( OptLabel, Yellow );
AddControl( StaticLine, OptLabel'unchecked_access, false );
Init( OptBox1, 11, 8, 25, 8, 1 );
SetText( OptBox1, To255( "None" ) );
AddControl( RadioButton, OptBox1'unchecked_access, false );
Init( OptBox2, 26, 8, 41, 8, 1 );
SetText( OptBox2, To255( "Basic" ) );
AddControl( RadioButton, OptBox2'unchecked_access, false );
Init( OptBox3, 42, 8, 57, 8, 1 );
SetText( OptBox3, To255( "Size" ) );
AddControl( RadioButton, OptBox3'unchecked_access, false );
Init( OptBox4, 58, 8, 73, 8, 1 );
SetText( OptBox4, To255( "Speed" ) );
AddControl( RadioButton, OptBox4'unchecked_access, false );
Init( CPULabel, 1, 9, 10, 9 );
SetText( CPULabel, To255( "CPU:" ) );
SetStyle( CPULabel, Bold );
SetColour( CPULabel, Yellow );
AddControl( StaticLine, CPULabel'unchecked_access, false );
Init( CPUBox1, 11, 9, 25, 9, 2 );
SetText( CPUBox1, To255( "386" ) );
AddControl( RadioButton, CPUBox1'unchecked_access, false );
Init( CPUBox2, 26, 9, 41, 9, 2 );
SetText( CPUBox2, To255( "486" ) );
AddControl( RadioButton, CPUBox2'unchecked_access, false );
Init( CPUBox3, 42, 9, 57, 9, 2 );
SetText( CPUBox3, To255( "Pentium" ) );
AddControl( RadioButton, CPUBox3'unchecked_access, false );
Init( CPUBox4, 58, 9, 73, 9, 2 );
SetText( CPUBox4, To255( "Pentium II" ) );
AddControl( RadioButton, CPUBox4'unchecked_access, false );
Init( DebugLabel, 1, 10, 10, 10 );
SetText( DebugLabel, To255( "Debug:" ) );
SetStyle( DebugLabel, Bold );
SetColour( DebugLabel, Yellow );
AddControl( StaticLine, DebugLabel'unchecked_access, false );
Init( DebugBox1, 11, 10, 25, 10, 3 );
SetText( DebugBox1, To255( "Release" ) );
AddControl( RadioButton, DebugBox1'unchecked_access, false );
Init( DebugBox2, 26, 10, 41, 10, 3 );
SetText( DebugBox2, To255( "Alpha/Beta" ) );
AddControl( RadioButton, DebugBox2'unchecked_access, false );
Init( DebugBox3, 58, 10, 73, 10, 3 );
SetText( DebugBox3, To255( "Prerelease" ) );
AddControl( RadioButton, DebugBox3'unchecked_access, false );
Init( KindLabel, 1, 11, 10, 11 );
SetText( KindLabel, To255( "Kind:" ) );
SetStyle( KindLabel, Bold );
SetColour( KindLabel, Yellow );
AddControl( StaticLine, KindLabel'unchecked_access, false );
Init( KindBox1, 11, 11, 25, 11, 4 );
SetText( KindBox1, To255( "Program" ) );
AddControl( RadioButton, KindBox1'unchecked_access, false );
Init( KindBox2, 26, 11, 41, 11, 4 );
SetText( KindBox2, To255( "Package" ) );
AddControl( RadioButton, KindBox2'unchecked_access, false );
Init( KindBox3, 42, 11, 57, 11, 4 );
SetText( KindBox3, To255( "Static Lib" ) );
AddControl( RadioButton, KindBox3'unchecked_access, false );
Init( KindBox4, 58, 11, 73, 11, 4 );
SetText( KindBox4, To255( "Shared Lib" ) );
SetStatus( KindBox4, Off );
AddControl( RadioButton, KindBox4'unchecked_access, false );
Init( BuildLabel, 1, 12, 10, 12 );
SetText( BuildLabel, To255( "Builder:" ) );
SetStyle( BuildLabel, Bold );
SetColour( BuildLabel, Yellow );
AddControl( StaticLine, BuildLabel'unchecked_access, false );
Init( BuildBox1, 11, 12, 25, 12, 5 );
SetText( BuildBox1, To255( "Gnatmake" ) );
AddControl( RadioButton, BuildBox1'unchecked_access, false );
Init( BuildBox2, 26, 12, 41, 12, 5 );
SetText( BuildBox2, To255( "Make" ) );
AddControl( RadioButton, BuildBox2'unchecked_access, false );
Init( BuildBox3, 42, 12, 57, 12, 5 );
SetText( BuildBox3, To255( "Cook" ) );
AddControl( RadioButton, BuildBox3'unchecked_access, false );
Init( StaticBox, 1, 15, 21, 15, 's' );
SetText( StaticBox, To255( "Static Linking" ) );
AddControl( CheckBox, StaticBox'unchecked_access, false );
Init( EgcsBox, 22, 15, 41, 15, 'e' );
SetText( EgcsBox, To255( "Egcs compiler" ) );
AddControl( CheckBox, EgcsBox'unchecked_access, false );
Init( QuietBox, 42, 15, 61, 15, 'q' );
SetText( QuietBox, To255( "Quiet Updates" ) );
AddControl( CheckBox, QuietBox'unchecked_access, false );
Init( OKButton, 35, 17, 50, 17, 'o' );
SetText( OKButton, To255( "OK" ) );
AddControl( SimpleButton, OKButton'unchecked_access, false );
SetCheck( OptBox1, false );
SetCheck( OptBox2, false );
SetCheck( OptBox3, false );
SetCheck( OptBox4, false );
if Proj_Opt = 1 then
SetCheck( OptBox1, true );
elsif Proj_Opt = 2 then
SetCheck( OptBox2, true );
elsif Proj_Opt = 3 then
SetCheck( OptBox3, true );
else
SetCheck( OptBox4, true );
end if;
SetCheck( CPUBox1, false );
SetCheck( CPUBox2, false );
SetCheck( CPUBox3, false );
SetCheck( CPUBox4, false );
if Proj_CPU = 1 then
SetCheck( CPUBox1, true );
elsif Proj_CPU = 2 then
SetCheck( CPUBox2, true );
elsif Proj_CPU = 3 then
SetCheck( CPUBox3, true );
else
SetCheck( CPUBox4, true );
end if;
SetCheck( DebugBox1, false );
SetCheck( DebugBox2, false );
SetCheck( DebugBox3, false );
if Proj_Debug = 1 then
SetCheck( DebugBox1, true );
elsif Proj_Debug = 2 then
SetCheck( DebugBox2, true );
else
SetCheck( DebugBox3, true );
end if;
SetCheck( KindBox1, false );
SetCheck( KindBox2, false );
SetCheck( KindBox3, false );
SetCheck( KindBox4, false );
if Proj_Kind = 1 then
SetCheck( KindBox1, true );
elsif Proj_Kind = 2 then
SetCheck( KindBox2, true );
elsif Proj_Kind = 3 then
SetCheck( KindBox3, true );
else
SetCheck( KindBox4, true );
end if;
SetCheck( BuildBox1, false );
SetCheck( BuildBox2, false );
SetCheck( BuildBox3, false );
if Proj_Builder = 1 then
SetCheck( BuildBox1, true );
elsif Proj_Builder = 2 then
SetCheck( BuildBox2, true );
else
SetCheck( BuildBox3, true );
end if;
SetCheck( StaticBox, Proj_Static );
SetCheck( EgcsBox, Proj_Egcs );
--SetCheck( QuietBox, Proj_Quiet );
SetStatus( QuietBox, off );
loop
DoDialog( DT );
case DT.control is
when 33 => -- OK
if GetCheck( OptBox1 ) then
Proj_Opt := 1;
elsif GetCheck( OptBox2 ) then
Proj_Opt := 2;
elsif GetCheck( OptBox3 ) then
Proj_Opt := 3;
else
Proj_Opt := 4;
end if;
if GetCheck( CPUBox1 ) then
Proj_CPU := 1;
elsif GetCheck( CPUBox2 ) then
Proj_CPU := 2;
elsif GetCheck( CPUBox3 ) then
Proj_CPU := 3;
else
Proj_CPU := 4;
end if;
if GetCheck( DebugBox1 ) then
Proj_Debug := 1;
elsif GetCheck( DebugBox2 ) then
Proj_Debug := 2;
else
Proj_Debug := 3;
end if;
if GetCheck( KindBox1 ) then
Proj_Kind := 1;
elsif GetCheck( KindBox2 ) then
Proj_Kind := 2;
elsif GetCheck( KindBox3 ) then
Proj_Kind := 3;
else
Proj_Kind := 4;
end if;
if GetCheck( BuildBox1 ) then
Proj_Builder := 1;
elsif GetCheck( BuildBox2 ) then
Proj_Builder := 2;
else
Proj_Builder := 3;
end if;
Proj_MakeOptions := GetText( MakeLine );
Proj_LinkOptions := GetText( LinkLine );
Proj_Main := GetText( MainLine );
Proj_Static := GetCheck( StaticBox );
Proj_Egcs := GetCheck( EgcsBox );
--Proj_Quiet := GetCheck( QuietBox );
exit;
when others => null;
end case;
end loop;
CloseWindow;
end ProjectParams;
procedure GotoLine is
TextLine : aliased ALongIntEditLine;
GotoButton : aliased ASimpleButton;
CancelButton : aliased ASimpleButton;
MarkButton : aliased ASimpleButton;
DT : ADialogTaskRecord;
Line2Goto : long_integer;
begin
OpenWindow( To255( "Goto" ), 10, 10, 70, 16, Normal );
Init( TextLine, 1, 2, 58, 2 );
SetText( TextLine, NullStr255 );
AddControl( LongIntEditLine, TextLine'unchecked_access, false );
Init( GotoButton, 2, 4, 11, 4, 'g' );
SetText( GotoButton, To255( "Goto" ) );
SetInstant( GotoButton );
AddControl( SimpleButton, GotoButton'unchecked_access, false );
Init( CancelButton, 22, 4, 31, 4, 'l' );
SetText( CancelButton, To255( "Cancel" ) );
SetInstant( CancelButton );
AddControl( SimpleButton, CancelButton'unchecked_access, false );
Init( MarkButton, 42, 4, 51, 4, 'm' );
SetText( MarkButton, To255( "Mark" ) );
SetInstant( MarkButton );
AddControl( SimpleButton, MarkButton'unchecked_access, false );
loop
DoDialog( DT );
case DT.control is
when 2 => Line2Goto := GetValue( TextLine );
if Line2Goto > 0 then
if Line2Goto > GetLength( SourceBox ) then
Line2Goto := GetLength( SourceBox );
end if;
MoveCursor( SourceBox, 0,
Line2Goto - GetCurrent( SourceBox ) );
end if;
exit;
when 3 => exit;
when 4 => Line2Goto := GetMark( SourceBox );
if Line2Goto > 0 then
MoveCursor( SourceBox, 0,
Line2Goto - GetCurrent( SourceBox ) );
else
NoteAlert( "No mark set" );
end if;
exit;
when others => null;
end case;
end loop;
CloseWindow;
end GotoLine;
procedure AboutProgram is
ch : character;
begin
OpenWindow( To255( "About TIA 0.9" ), 5, 5, 70, 18, Status, false );
MoveToGlobal( 6, 6 );
SetTextStyle( Title );
SetPenColour( White );
Draw( "Tiny IDE for Ada (TIA) 0.9" );
MoveToGlobal( 6, 7 );
SetPenColour( Red );
Draw( "Tiny IDE for Ada (TIA) 0.9" );
MoveToGlobal( 6, 8 );
SetTextStyle( Normal );
Draw( "Tiny IDE for Ada (TIA) 0.9" );
SetTextStyle( Normal );
SetPenColour( White );
MoveToGlobal( 6, 10 );
Draw( "The 48 hour IDE." );
MoveToGlobal( 6, 11 );
Draw( "For internal use only." );
MoveToGlobal( 6, 13 );
Draw( "Copyright (c) 1998, 1999 PegaSoft Canada." );
MoveToGlobal( 6, 14 );
Draw( "Read accompanying documentation for more information" );
MoveToGlobal( 6, 15 );
Draw( "or visit our web site at http://www.vaxxine.com/pegasoft." );
SetPenColour( White );
MoveToGlobal( 6, 17 );
Draw( "Press any key to continue" );
GetKey( ch );
CloseWindow;
end AboutProgram;
procedure BuildProject is
CompileLine : Str255;
LinkLine : Str255;
ShellLine : Str255;
ErrFile : Str255;
LinkErrFile : Str255;
ScriptFile : Str255;
Script : Str255List.List;
LinkErrs : Str255List.List;
begin
--if YesAlert( "Save source before building?", status ) then
SaveSource( DoBackgroundUpdate => false );
if IsBackgroundUpdate then
SetInfoText( "Waiting for background update to finish..." );
while IsBackgroundUpdate loop
Wait( 1.0 );
end loop;
end if;
SetInfoText( "" );
--end if;
--
-- these aren't finished
--
if Proj_Builder = 2 then -- make
UNIX( "make" );
ClearGnatErrors;
elsif Proj_Builder = 3 then -- cook
UNIX( "cook" );
ClearGnatErrors;
end if;
-- Proj_Build = 1 -- gnatmake
MakeTempFileName( ScriptFile );
ErrFile := ScriptFile & "_ce";
LinkErrFile := ScriptFile & "_be";
Str255List.Queue( Script, To255( "#!/bin/sh" ) );
Str255List.Queue( Script, To255( "#automatically created by TIA" ) );
Str255List.Queue( Script, To255( "echo" ) );
Str255List.Queue( Script, To255( "echo building project..." ) );
CompileLine := To255( "gnatmake -c -i -q " );
-- c = don't link and bind because we'll do that separately
-- i = save files in the same directory where you found source
-- q = quiet - don't list units as you compile them
if Proj_Opt = 1 then
null; -- nothing special for no optimize
elsif Proj_Opt = 2 then
CompileLine := CompileLine & "-O ";
elsif Proj_Opt = 3 then
CompileLine := CompileLine & "-O2 ";
else
CompileLine := CompileLine & "-O3 ";
end if;
-- egcs will use different options
if Proj_CPU = 1 then
CompileLine := CompileLine & "-mno-486 ";
elsif Proj_CPU = 2 then
CompileLine := CompileLine & "-m486 ";
else -- Pentium or P2
CompileLine := CompileLine & "-m486 -malign-loops=2 -malign-jumps=2"
& " -malign-functions=2 -fno-strength-reduce ";
end if;
-- debug
-- gnat 3.11 -gnatwu omitted for rebuild
if Proj_Debug = 1 then
CompileLine := CompileLine & "-gnatp ";
elsif Proj_Debug = 2 then
CompileLine := CompileLine & "-gnata -gnatf ";
elsif Proj_Debug = 3 then
CompileLine := CompileLine & "-gnata -gnato -gnatE -gnatf ";
end if;
if Proj_Kind = 4 then -- shared library
CompileLine := CompileLine & "-fPIC -shared ";
end if;
CompileLine := CompileLine & Proj_MakeOptions & " ";
-- and put in main program
CompileLine := CompileLine & Proj_Main & ".adb ";
Str255List.Queue( Script, "echo '" & CompileLine & "'" );
CompileLine := CompileLine & "2> " & ErrFile;
Str255List.Queue( Script, CompileLine );
Str255List.Queue( Script, To255( "if [ $? -ne 0 ] ; then" ) );
Str255List.Queue( Script, To255( " exit 1" ) );
Str255List.Queue( Script, To255( "fi;" ) );
-- bind and link (if application)
if Proj_Kind = 1 then
Str255List.Queue( Script, To255( "echo binding project..." ) );
Str255List.Queue( Script, "gnatbind -xf " &
Proj_MakeOptions & " " &
Proj_Main & ".ali 2> " & LinkErrFile );
Str255List.Queue( Script, To255( "if [ $? -ne 0 ] ; then" ) );
Str255List.Queue( Script, To255( " exit 2" ) );
Str255List.Queue( Script, To255( "fi;" ) );
LinkLine := "gnatlink " & Proj_Main & ".ali " &
Proj_LinkOptions & " ";
if Proj_Static then
LinkLine := LinkLine & " -static ";
end if;
LinkLine := LinkLine & " 2> " & LinkErrFile;
Str255List.Queue( Script, To255( "echo linking project..." ) );
Str255List.Queue( Script, LinkLine );
Str255List.Queue( Script, To255( "if [ $? -ne 0 ] ; then" ) );
Str255List.Queue( Script, To255( " exit 3" ) );
Str255List.Queue( Script, To255( "fi;" ) );
end if;
SaveList( ScriptFile, Script );
if LastError /= CoreOK then
SessionLog( "BuildProject: Error saving file", LastError );
StopAlert( "Error saving file: # " & AnErrorCode'image(
LastError ) );
end if;
ShellLine := "sh " & ScriptFile & " ; echo done";
ShellOut( ShellLine );
Erase( ScriptFile );
ClearGnatErrors;
LoadList( ErrFile, GnatErrors );
Erase( ErrFile );
LoadList( LinkErrFile, LinkErrs );
Erase( LinkErrFile );
Str255List.Clear( Script );
if Str255List.Length( GnatErrors ) > 0 then
ShowListInfo( "Gnat Errors", 0, 1, 78, 23, GnatErrors );
elsif Str255List.Length( LinkErrs ) > 0 then
ShowListInfo( "Bind and Link Errors", 0, 1, 78, 23, LinkErrs );
elsif not NoAlert( "Ready. Run exeuctable?", kind => success ) then
ShellOut( Proj_Main );
end if;
Str255List.Clear( LinkErrs );
end BuildProject;
procedure OpenSource is
procedure BrowseOpenSource( NewFilename : out str255 ) is
ProjectDir : str255;
sof : ASelectOpenFileRec;
begin
ProjectDir := GetPath;
sof.prompt := To255( "Open which source file?" );
sof.direct := false;
sof.suffix := NullStr255;
SelectOpenFile( sof );
if sof.replied then
NewFilename := sof.path & "/" & sof.fname;
else
NewFilename := NullStr255;
end if;
-- sof may change path but we want to stay in project directory
SetPath( ProjectDir );
end BrowseOpenSource;
TextLine : aliased AnEditLine;
NewButton : aliased ASimpleButton;
OpenButton : aliased ASimpleButton;
CancelButton : aliased ASimpleButton;
BrowseButton : aliased ASimpleButton;
OneButton : aliased ASimpleButton;
TwoButton : aliased ASimpleButton;
ThreeButton : aliased ASimpleButton;
FourButton : aliased ASimpleButton;
NewFilename : str255;
DT : ADialogTaskRecord;
procedure SwitchToNewFile is
-- procedure SwitchToNewFile( path : str255 ) is
-- was path, but gnat was screwing up local variable
-- so trying it with NewFilename directly
begin
SaveSource;
if IsFile( NewFilename ) then
SourcePath := NewFilename;
Str255List.Clear( SourceText );
LoadList( SourcePath, SourceText );
SetList( SourceBox, SourceText );
SetThumb( SourceBar, 1 );
else
StopAlert( ToString( NewFilename ) & " doesn't exist" );
end if;
end SwitchToNewFile;
procedure SwitchToNewFile( sr : ASourceReference ) is
TempSave : ASourceReference;
-- kludge: gnat 3.10 mangled sr during return from SaveSource call
begin
TempSave := sr;
SaveSource;
if IsFile( TempSave.path ) then
SourcePath := TempSave.path;
Str255List.Clear( SourceText );
LoadList( SourcePath, SourceText );
SetList( SourceBox, SourceText );
SetCursor( SourceBox, TempSave.Posn, TempSave.Line );
SetThumb( SourceBar, long_integer( TempSave.Posn ) );
else
StopAlert( ToString( SourcePath ) & " doesn't exist" );
end if;
end SwitchToNewFile;
begin
OpenWindow( To255( "Open/New Source" ), 10, 6, 70, 18, Normal, true );
Init( TextLine, 1, 2, 58, 2 );
SetText( TextLine, NullStr255 );
SetInfo( TextLine, To255( "Path of file to load" ) );
AddControl( LongIntEditLine, TextLine'unchecked_access, false );
Init( OpenButton, 2, 4, 13, 4, 'o' );
SetText( OpenButton, "Open" );
SetInfo( OpenButton, To255( "Open file you named" ) );
SetInstant( OpenButton );
AddControl( SimpleButton, OpenButton'unchecked_access, false );
Init( CancelButton, 14, 4, 25, 4, 'l' );
SetText( CancelButton, "Cancel" );
SetInfo( CancelButton, To255( "Cancel" ) );
SetInstant( CancelButton );
AddControl( SimpleButton, CancelButton'unchecked_access, false );
Init( BrowseButton, 26, 4, 41, 4, 'b' );
SetText( BrowseButton, "Browse..." );
SetInfo( BrowseButton, To255( "Look for the file to open" ) );
SetInstant( BrowseButton );
AddControl( SimpleButton, BrowseButton'unchecked_access, false );
Init( NewButton, 41, 4, 52, 4, 'n' );
SetText( NewButton, "New" );
SetInfo( NewButton, To255( "Start a new file" ) );
SetInstant( NewButton );
AddControl( SimpleButton, NewButton'unchecked_access, false );
Init( OneButton, 1, 6, 58, 6, '1' );
SetText( OneButton, "1 " & QuickOpen1.path );
SetInfo( OneButton, To255( "Open this file" ) );
SetInstant( OneButton );
if length( QuickOpen1.path ) = 0 then
SetStatus( OneButton, off );
SetText( OneButton, "1 - " );
end if;
AddControl( SimpleButton, OneButton'unchecked_access, false );
Init( TwoButton, 1, 7, 58, 7, '2' );
SetText( TwoButton, "2 " & QuickOpen2.path );
SetInfo( TwoButton, To255( "Open this file" ) );
SetInstant( TwoButton );
if length( QuickOpen2.path ) = 0 then
SetStatus( TwoButton, off );
SetText( TwoButton, "2 - " );
end if;
AddControl( SimpleButton, TwoButton'unchecked_access, false );
Init( ThreeButton, 1, 8, 58, 8, '3' );
SetText( ThreeButton, "3 " & QuickOpen3.path );
SetInfo( ThreeButton, To255( "Open this file" ) );
SetInstant( ThreeButton );
if length( QuickOpen3.path ) = 0 then
SetText( ThreeButton, "3 - " );
SetStatus( ThreeButton, off );
end if;
AddControl( SimpleButton, ThreeButton'unchecked_access, false );
Init( FourButton, 1, 9, 58, 9, '4' );
SetText( FourButton, "4 " & QuickOpen4.path );
SetInfo( FourButton, To255( "Open this file" ) );
SetInstant( FourButton );
if length( QuickOpen4.path ) = 0 then
SetText( FourButton, "4 - " );