forked from jrsoftware/issrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompForm.pas
5244 lines (4781 loc) · 181 KB
/
CompForm.pas
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
unit CompForm;
{
Inno Setup
Copyright (C) 1997-2020 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
Compiler form
}
{x$DEFINE STATICCOMPILER}
{ For debugging purposes, remove the 'x' to have it link the compiler code
into this program and not depend on ISCmplr.dll. Also see Compile's
STATICPREPROC. }
{$I VERSION.INC}
{$IFDEF IS_D6}
{$WARN SYMBOL_PLATFORM OFF}
{$ENDIF}
interface
uses
Windows, Messages, SysUtils, Classes, Contnrs, Graphics, Controls, Forms, Dialogs, CommDlg,
Generics.Collections, UIStateForm, StdCtrls, ExtCtrls, Menus, Buttons, ComCtrls, CommCtrl,
ScintInt, ScintEdit, ScintStylerInnoSetup, NewTabSet, ModernColors, CompScintEdit,
DebugStruct, CompInt, UxTheme, ImageList, ImgList, ToolWin, CompFunc,
VirtualImageList, BaseImageCollection, ImageCollection;
const
WM_StartCommandLineCompile = WM_USER + $1000;
WM_StartCommandLineWizard = WM_USER + $1001;
WM_StartNormally = WM_USER + $1002;
type
PDebugEntryArray = ^TDebugEntryArray;
TDebugEntryArray = array[0..0] of TDebugEntry;
PVariableDebugEntryArray = ^TVariableDebugEntryArray;
TVariableDebugEntryArray = array[0..0] of TVariableDebugEntry;
TStepMode = (smRun, smStepInto, smStepOver, smStepOut, smRunToCursor);
TDebugTarget = (dtSetup, dtUninstall);
const
DebugTargetStrings: array[TDebugTarget] of String = ('Setup', 'Uninstall');
type
TStatusMessageKind = (smkStartEnd, smkNormal, smkWarning, smkError);
TIncludedFile = class
Filename: String;
CompilerFileIndex: Integer;
LastWriteTime: TFileTime;
HasLastWriteTime: Boolean;
Memo: TCompScintFileEdit;
end;
TIncludedFiles = TObjectList<TIncludedFile>;
TFindResult = class
Filename: String;
Line, LineStartPos: Integer;
Range: TScintRange;
PrefixStringLength: Integer;
end;
TFindResults = TObjectList<TFindResult>;
TCompileForm = class(TUIStateForm)
MainMenu1: TMainMenu;
FMenu: TMenuItem;
FNewMainFile: TMenuItem;
FOpenMainFile: TMenuItem;
FSave: TMenuItem;
FSaveMainFileAs: TMenuItem;
N1: TMenuItem;
BCompile: TMenuItem;
N2: TMenuItem;
FExit: TMenuItem;
EMenu: TMenuItem;
EUndo: TMenuItem;
N3: TMenuItem;
ECut: TMenuItem;
ECopy: TMenuItem;
EPaste: TMenuItem;
EDelete: TMenuItem;
N4: TMenuItem;
ESelectAll: TMenuItem;
VMenu: TMenuItem;
EFind: TMenuItem;
EFindNext: TMenuItem;
EReplace: TMenuItem;
HMenu: TMenuItem;
HDoc: TMenuItem;
N6: TMenuItem;
HAbout: TMenuItem;
FMRUMainFilesSep: TMenuItem;
VCompilerOutput: TMenuItem;
FindDialog: TFindDialog;
ReplaceDialog: TReplaceDialog;
StatusPanel: TPanel;
CompilerOutputList: TListBox;
SplitPanel: TPanel;
HWebsite: TMenuItem;
VToolbar: TMenuItem;
N7: TMenuItem;
TOptions: TMenuItem;
HFaq: TMenuItem;
StatusBar: TStatusBar;
BodyPanel: TPanel;
VStatusBar: TMenuItem;
ERedo: TMenuItem;
RMenu: TMenuItem;
RStepInto: TMenuItem;
RStepOver: TMenuItem;
N5: TMenuItem;
RRun: TMenuItem;
RRunToCursor: TMenuItem;
N10: TMenuItem;
REvaluate: TMenuItem;
CheckIfRunningTimer: TTimer;
RPause: TMenuItem;
RParameters: TMenuItem;
ListPopupMenu: TPopupMenu;
PListCopy: TMenuItem;
HISPPSep: TMenuItem;
N12: TMenuItem;
BStopCompile: TMenuItem;
HISPPDoc: TMenuItem;
N13: TMenuItem;
EGoto: TMenuItem;
RTerminate: TMenuItem;
BMenu: TMenuItem;
BLowPriority: TMenuItem;
HDonate: TMenuItem;
N14: TMenuItem;
HPSWebsite: TMenuItem;
N15: TMenuItem;
RTargetSetup: TMenuItem;
RTargetUninstall: TMenuItem;
OutputTabSet: TNewTabSet;
DebugOutputList: TListBox;
VDebugOutput: TMenuItem;
VHide: TMenuItem;
N11: TMenuItem;
TMenu: TMenuItem;
TAddRemovePrograms: TMenuItem;
RToggleBreakPoint: TMenuItem;
HWhatsNew: TMenuItem;
TGenerateGUID: TMenuItem;
TSignTools: TMenuItem;
N16: TMenuItem;
HExamples: TMenuItem;
N17: TMenuItem;
BOpenOutputFolder: TMenuItem;
N8: TMenuItem;
VZoom: TMenuItem;
VZoomIn: TMenuItem;
VZoomOut: TMenuItem;
N9: TMenuItem;
VZoomReset: TMenuItem;
N18: TMenuItem;
ECompleteWord: TMenuItem;
N19: TMenuItem;
FSaveEncoding: TMenuItem;
FSaveEncodingAuto: TMenuItem;
FSaveEncodingUTF8: TMenuItem;
ToolBar: TToolBar;
NewMainFileButton: TToolButton;
OpenMainFileButton: TToolButton;
SaveButton: TToolButton;
ToolButton4: TToolButton;
CompileButton: TToolButton;
StopCompileButton: TToolButton;
ToolButton7: TToolButton;
RunButton: TToolButton;
PauseButton: TToolButton;
ToolButton10: TToolButton;
TargetSetupButton: TToolButton;
TargetUninstallButton: TToolButton;
ToolButton13: TToolButton;
HelpButton: TToolButton;
Bevel1: TBevel;
BuildImageList: TImageList;
TerminateButton: TToolButton;
LightToolBarImageCollection: TImageCollection;
DarkToolBarImageCollection: TImageCollection;
ToolBarVirtualImageList: TVirtualImageList;
PListSelectAll: TMenuItem;
DebugCallStackList: TListBox;
VDebugCallStack: TMenuItem;
TInsertMsgBox: TMenuItem;
ToolBarPanel: TPanel;
HMailingList: TMenuItem;
MemosTabSet: TNewTabSet; { First tab is the main memo, last tab is the preprocessor output memo }
FSaveAll: TMenuItem;
RStepOut: TMenuItem;
VNextTab: TMenuItem;
VPreviousTab: TMenuItem;
N20: TMenuItem;
HShortcutsDoc: TMenuItem;
N21: TMenuItem;
EFindPrevious: TMenuItem;
FindResultsList: TListBox;
VFindResults: TMenuItem;
EFindInFiles: TMenuItem;
FindInFilesDialog: TFindDialog;
FPrint: TMenuItem;
N22: TMenuItem;
PrintDialog: TPrintDialog;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FExitClick(Sender: TObject);
procedure FOpenMainFileClick(Sender: TObject);
procedure EUndoClick(Sender: TObject);
procedure EMenuClick(Sender: TObject);
procedure ECutClick(Sender: TObject);
procedure ECopyClick(Sender: TObject);
procedure EPasteClick(Sender: TObject);
procedure EDeleteClick(Sender: TObject);
procedure FSaveClick(Sender: TObject);
procedure ESelectAllClick(Sender: TObject);
procedure FNewMainFileClick(Sender: TObject);
procedure FNewMainFileUserWizardClick(Sender: TObject);
procedure HDocClick(Sender: TObject);
procedure BCompileClick(Sender: TObject);
procedure FMenuClick(Sender: TObject);
procedure FMRUClick(Sender: TObject);
procedure VCompilerOutputClick(Sender: TObject);
procedure HAboutClick(Sender: TObject);
procedure EFindClick(Sender: TObject);
procedure FindDialogFind(Sender: TObject);
procedure EReplaceClick(Sender: TObject);
procedure ReplaceDialogReplace(Sender: TObject);
procedure EFindNextOrPreviousClick(Sender: TObject);
procedure SplitPanelMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure VMenuClick(Sender: TObject);
procedure HWebsiteClick(Sender: TObject);
procedure VToolbarClick(Sender: TObject);
procedure TOptionsClick(Sender: TObject);
procedure HFaqClick(Sender: TObject);
procedure HPSWebsiteClick(Sender: TObject);
procedure HISPPDocClick(Sender: TObject);
procedure VStatusBarClick(Sender: TObject);
procedure ERedoClick(Sender: TObject);
procedure StatusBarResize(Sender: TObject);
procedure RStepIntoClick(Sender: TObject);
procedure RStepOverClick(Sender: TObject);
procedure RRunToCursorClick(Sender: TObject);
procedure RRunClick(Sender: TObject);
procedure REvaluateClick(Sender: TObject);
procedure CheckIfRunningTimerTimer(Sender: TObject);
procedure RPauseClick(Sender: TObject);
procedure RParametersClick(Sender: TObject);
procedure PListCopyClick(Sender: TObject);
procedure BStopCompileClick(Sender: TObject);
procedure HMenuClick(Sender: TObject);
procedure EGotoClick(Sender: TObject);
procedure RTerminateClick(Sender: TObject);
procedure BMenuClick(Sender: TObject);
procedure BLowPriorityClick(Sender: TObject);
procedure StatusBarDrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
procedure HDonateClick(Sender: TObject);
procedure RTargetClick(Sender: TObject);
procedure DebugOutputListDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure OutputTabSetClick(Sender: TObject);
procedure VHideClick(Sender: TObject);
procedure VDebugOutputClick(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure TAddRemoveProgramsClick(Sender: TObject);
procedure RToggleBreakPointClick(Sender: TObject);
procedure HWhatsNewClick(Sender: TObject);
procedure TGenerateGUIDClick(Sender: TObject);
procedure TSignToolsClick(Sender: TObject);
procedure HExamplesClick(Sender: TObject);
procedure BOpenOutputFolderClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure VZoomInClick(Sender: TObject);
procedure VZoomOutClick(Sender: TObject);
procedure VZoomResetClick(Sender: TObject);
procedure ECompleteWordClick(Sender: TObject);
procedure FSaveEncodingItemClick(Sender: TObject);
procedure CompilerOutputListDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure FormAfterMonitorDpiChanged(Sender: TObject; OldDPI,
NewDPI: Integer);
procedure PListSelectAllClick(Sender: TObject);
procedure DebugCallStackListDrawItem(Control: TWinControl; Index: Integer; Rect: TRect;
State: TOwnerDrawState);
procedure VDebugCallStackClick(Sender: TObject);
procedure HMailingListClick(Sender: TObject);
procedure TInsertMsgBoxClick(Sender: TObject);
procedure MemosTabSetClick(Sender: TObject);
procedure FSaveAllClick(Sender: TObject);
procedure RStepOutClick(Sender: TObject);
procedure TMenuClick(Sender: TObject);
procedure VNextTabClick(Sender: TObject);
procedure VPreviousTabClick(Sender: TObject);
procedure HShortcutsDocClick(Sender: TObject);
procedure VFindResultsClick(Sender: TObject);
procedure EFindInFilesClick(Sender: TObject);
procedure FindInFilesDialogFind(Sender: TObject);
procedure FindResultsListDrawItem(Control: TWinControl; Index: Integer; Rect: TRect;
State: TOwnerDrawState);
procedure FindResultsListDblClick(Sender: TObject);
procedure FPrintClick(Sender: TObject);
private
{ Private declarations }
FMemos: TList<TCompScintEdit>; { FMemos[0] is the main memo and FMemos[1] the preprocessor output memo - also see MemosTabSet comment above }
FMainMemo: TCompScintFileEdit; { Doesn't change }
FPreprocessorOutputMemo: TCompScintEdit; { Doesn't change }
FFileMemos: TList<TCompScintFileEdit>; { All memos except FPreprocessorOutputMemo }
FActiveMemo: TCompScintEdit; { Changes depending on user input }
FErrorMemo, FStepMemo: TCompScintFileEdit; { These change depending on user input }
FMemosStyler: TInnoSetupStyler; { Single styler for all memos }
FCompilerVersion: PCompilerVersionInfo;
FMRUMainFilesMenuItems: array[0..MRUListMaxCount-1] of TMenuItem;
FMRUMainFilesList: TStringList;
FMRUParametersList: TStringList;
FOptions: record
ShowStartupForm: Boolean;
UseWizard: Boolean;
Autosave: Boolean;
MakeBackups: Boolean;
FullPathInTitleBar: Boolean;
UndoAfterSave: Boolean;
PauseOnDebuggerExceptions: Boolean;
RunAsDifferentUser: Boolean;
AutoComplete: Boolean;
UseSyntaxHighlighting: Boolean;
ColorizeCompilerOutput: Boolean;
UnderlineErrors: Boolean;
CursorPastEOL: Boolean;
TabWidth: Integer;
UseTabCharacter: Boolean;
WordWrap: Boolean;
AutoIndent: Boolean;
IndentationGuides: Boolean;
LowPriorityDuringCompile: Boolean;
GutterLineNumbers: Boolean;
ThemeType: TThemeType;
ShowPreprocessorOutput: Boolean;
OpenIncludedFiles: Boolean;
end;
FOptionsLoaded: Boolean;
FTheme: TTheme;
FSignTools: TStringList;
FFindResults: TFindResults;
FCompiling: Boolean;
FCompileWantAbort: Boolean;
FBecameIdle: Boolean;
FModifiedAnySinceLastCompile, FModifiedAnySinceLastCompileAndGo: Boolean;
FDebugEntries: PDebugEntryArray;
FDebugEntriesCount: Integer;
FVariableDebugEntries: PVariableDebugEntryArray;
FVariableDebugEntriesCount: Integer;
FCompiledCodeText: AnsiString;
FCompiledCodeDebugInfo: AnsiString;
FDebugClientWnd: HWND;
FProcessHandle, FDebugClientProcessHandle: THandle;
FDebugTarget: TDebugTarget;
FCompiledExe, FUninstExe, FTempDir: String;
FPreprocessorOutput: String;
FIncludedFiles: TIncludedFiles;
FLoadingIncludedFiles: Boolean;
FDebugging: Boolean;
FStepMode: TStepMode;
FPaused, FPausedAtCodeLine: Boolean;
FRunToCursorPoint: TDebugEntry;
FReplyString: String;
FDebuggerException: String;
FRunParameters: String;
FLastFindOptions: TFindOptions;
FLastFindText: String;
FLastReplaceText: String;
FLastEvaluateConstantText: String;
FSavePriorityClass: DWORD;
FBuildAnimationFrame: Cardinal;
FLastAnimationTick: DWORD;
FProgress, FProgressMax: Cardinal;
FProgressThemeData: HTHEME;
FProgressChunkSize, FProgressSpaceSize: Integer;
FDebugLogListTimestampsWidth: Integer;
FOnPendingSquiggly: Boolean;
FPendingSquigglyCaretPos: Integer;
FCallStackCount: Cardinal;
FDevMode, FDevNames: HGLOBAL;
class procedure AppOnException(Sender: TObject; E: Exception);
procedure AppOnActivate(Sender: TObject);
procedure AppOnIdle(Sender: TObject; var Done: Boolean);
function AskToDetachDebugger: Boolean;
procedure BringToForeground;
procedure CheckIfTerminated;
procedure CompileFile(AFilename: String; const ReadFromFile: Boolean);
procedure CompileIfNecessary;
function ConfirmCloseFile(const PromptToSave: Boolean): Boolean;
procedure DebuggingStopped(const WaitForTermination: Boolean);
procedure DebugLogMessage(const S: String);
procedure DebugShowCallStack(const CallStack: String; const CallStackCount: Cardinal);
procedure DestroyDebugInfo;
procedure DetachDebugger;
function EvaluateConstant(const S: String; var Output: String): Integer;
function EvaluateVariableEntry(const DebugEntry: PVariableDebugEntry;
var Output: String): Integer;
procedure FindNext;
function FromCurrentPPI(const XY: Integer): Integer;
procedure Go(AStepMode: TStepMode);
procedure HideError;
procedure InitializeFindText(Dlg: TFindDialog);
function InitializeFileMemo(const Memo: TCompScintFileEdit; const PopupMenu: TPopupMenu): TCompScintFileEdit;
function InitializeMainMemo(const Memo: TCompScintFileEdit; const PopupMenu: TPopupMenu): TCompScintFileEdit;
function InitializeMemoBase(const Memo: TCompScintEdit; const PopupMenu: TPopupMenu): TCompScintEdit;
function InitializeNonFileMemo(const Memo: TCompScintEdit; const PopupMenu: TPopupMenu): TCompScintEdit;
procedure InitiateAutoComplete(const Key: AnsiChar);
procedure InvalidateStatusPanel(const Index: Integer);
procedure LoadKnownIncludedFilesAndUpdateMemos(const AFilename: String);
procedure MemoChange(Sender: TObject; const Info: TScintEditChangeInfo);
procedure MemoCharAdded(Sender: TObject; Ch: AnsiChar);
procedure MainMemoDropFiles(Sender: TObject; X, Y: Integer; AFiles: TStrings);
procedure MemoHintShow(Sender: TObject; var Info: TScintHintInfo);
procedure MemoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure MemoKeyPress(Sender: TObject; var Key: Char);
procedure MemoLinesDeleted(Memo: TCompScintFileEdit; FirstLine, Count, FirstAffectedLine: Integer);
procedure MemoLinesInserted(Memo: TCompScintFileEdit; FirstLine, Count: integer);
procedure MemoMarginClick(Sender: TObject; MarginNumber: Integer;
Line: Integer);
procedure MemoModifiedChange(Sender: TObject);
function MemoToTabIndex(const AMemo: TCompScintEdit): Integer;
procedure MemoUpdateUI(Sender: TObject);
procedure ModifyMRUMainFilesList(const AFilename: String; const AddNewItem: Boolean);
procedure ModifyMRUParametersList(const AParameter: String; const AddNewItem: Boolean);
procedure MoveCaretAndActivateMemo(const AMemo: TCompScintEdit; const LineNumber: Integer; const AlwaysResetColumn: Boolean);
procedure NewMainFile;
procedure NewMainFileUsingWizard;
procedure OpenFile(AMemo: TCompScintFileEdit; AFilename: String; const MainMemoAddToRecentDocs: Boolean);
procedure OpenMRUMainFile(const AFilename: String);
procedure ParseDebugInfo(DebugInfo: Pointer);
procedure ReadMRUMainFilesList;
procedure ReadMRUParametersList;
procedure ResetAllMemosLineState;
procedure StartProcess;
function SaveFile(const AMemo: TCompScintFileEdit; const SaveAs: Boolean): Boolean;
procedure SaveKnownIncludedFiles(const AFilename: String);
procedure SetErrorLine(const AMemo: TCompScintFileEdit; const ALine: Integer);
procedure SetStatusPanelVisible(const AVisible: Boolean);
procedure SetStepLine(const AMemo: TCompScintFileEdit; ALine: Integer);
procedure ShowOpenMainFileDialog(const Examples: Boolean);
procedure StatusMessage(const Kind: TStatusMessageKind; const S: String);
procedure StoreLastFindOptions(Sender: TObject);
procedure SyncEditorOptions;
procedure SyncZoom;
function ToCurrentPPI(const XY: Integer): Integer;
procedure ToggleBreakPoint(Line: Integer);
procedure UpdateAllMemosLineMarkers;
procedure UpdateBevel1Visibility;
procedure UpdateCaption;
procedure UpdateCaretPosPanel;
procedure UpdateCompileStatusPanels(const AProgress, AProgressMax: Cardinal;
const ASecondsRemaining: Integer; const ABytesCompressedPerSecond: Cardinal);
procedure UpdateEditModePanel;
procedure UpdatePreprocMemos;
procedure UpdateLineMarkers(const AMemo: TCompScintFileEdit; const Line: Integer);
procedure UpdateMemosTabSetVisibility;
procedure UpdateModifiedPanel;
procedure UpdateNewMainFileButtons;
procedure UpdateOutputTabSetListsItemHeightAndDebugTimeWidth;
procedure UpdateRunMenu;
procedure UpdateSaveMenuItemAndButton;
procedure UpdateTargetMenu;
procedure UpdateTheme;
procedure UpdateThemeData(const Close, Open: Boolean);
procedure UpdateStatusPanelHeight(H: Integer);
procedure WMCopyData(var Message: TWMCopyData); message WM_COPYDATA;
procedure WMDebuggerHello(var Message: TMessage); message WM_Debugger_Hello;
procedure WMDebuggerGoodbye(var Message: TMessage); message WM_Debugger_Goodbye;
procedure WMDebuggerQueryVersion(var Message: TMessage); message WM_Debugger_QueryVersion;
procedure GetMemoAndDebugEntryFromMessage(Kind, Index: Integer; var Memo: TCompScintFileEdit;
var DebugEntry: PDebugEntry);
procedure DebuggerStepped(var Message: TMessage; const Intermediate: Boolean);
procedure WMDebuggerStepped(var Message: TMessage); message WM_Debugger_Stepped;
procedure WMDebuggerSteppedIntermediate(var Message: TMessage); message WM_Debugger_SteppedIntermediate;
procedure WMDebuggerException(var Message: TMessage); message WM_Debugger_Exception;
procedure WMDebuggerSetForegroundWindow(var Message: TMessage); message WM_Debugger_SetForegroundWindow;
procedure WMDebuggerCallStackCount(var Message: TMessage); message WM_Debugger_CallStackCount;
procedure WMStartCommandLineCompile(var Message: TMessage); message WM_StartCommandLineCompile;
procedure WMStartCommandLineWizard(var Message: TMessage); message WM_StartCommandLineWizard;
procedure WMStartNormally(var Message: TMessage); message WM_StartNormally;
procedure WMSettingChange(var Message: TMessage); message WM_SETTINGCHANGE;
procedure WMThemeChanged(var Message: TMessage); message WM_THEMECHANGED;
{$IFDEF IS_D4}
protected
procedure WndProc(var Message: TMessage); override;
{$ENDIF}
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
{$IFDEF IS_D5}
function IsShortCut(var Message: TWMKey): Boolean; override;
{$ENDIF}
end;
var
CompileForm: TCompileForm;
CommandLineFilename, CommandLineWizardName: String;
CommandLineCompile: Boolean;
CommandLineWizard: Boolean;
implementation
uses
ActiveX, Clipbrd, ShellApi, ShlObj, IniFiles, Registry, Consts, Types, UITypes, Math,
PathFunc, CmnFunc, CmnFunc2, FileClass, CompMsgs, TmSchema, BrowseFunc,
HtmlHelpFunc, TaskbarProgressFunc,
{$IFDEF STATICCOMPILER} Compile, {$ENDIF}
CompOptions, CompStartup, CompWizard, CompSignTools, CompTypes, CompInputQueryCombo, CompMessageBoxDesigner;
{$R *.DFM}
const
{ Memos }
MaxMemos = 12; { Includes the main and preprocessor output memo's }
FirstIncludedFilesMemoIndex = 1; { This is an index into FFileMemos }
{ Status bar panel indexes }
spCaretPos = 0;
spModified = 1;
spEditMode = 2;
spCompileIcon = 3;
spCompileProgress = 4;
spExtraStatus = 5;
{ Output tab set indexes }
tiCompilerOutput = 0;
tiDebugOutput = 1;
tiDebugCallStack = 2;
tiFindResults = 3;
LineStateGrowAmount = 4000;
{ TCompileFormMemoPopupMenu }
type
TCompileFormMemoPopupMenu = class(TPopupMenu)
public
procedure Popup(X, Y: Integer); override;
end;
procedure TCompileFormMemoPopupMenu.Popup(X, Y: Integer);
var
Form: TCompileForm;
begin
{ Show the existing Edit menu }
Form := Owner as TCompileForm;
TrackPopupMenu(Form.EMenu.Handle, TPM_RIGHTBUTTON, X, Y, 0, Form.Handle, nil);
end;
{ TCompileForm }
function TCompileForm.InitializeMemoBase(const Memo: TCompScintEdit; const PopupMenu: TPopupMenu): TCompScintEdit;
begin
Memo.Align := alClient;
Memo.AutoCompleteFontName := Font.Name;
Memo.AutoCompleteFontSize := Font.Size;
Memo.CodePage := CP_UTF8;
Memo.Font.Name := 'Courier New';
Memo.Font.Size := 10;
Memo.ShowHint := True;
Memo.Styler := FMemosStyler;
Memo.PopupMenu := PopupMenu;
Memo.OnChange := MemoChange;
Memo.OnCharAdded := MemoCharAdded;
Memo.OnHintShow := MemoHintShow;
Memo.OnKeyDown := MemoKeyDown;
Memo.OnKeyPress := MemoKeyPress;
Memo.OnMarginClick := MemoMarginClick;
Memo.OnModifiedChange := MemoModifiedChange;
Memo.OnUpdateUI := MemoUpdateUI;
Memo.Parent := BodyPanel;
Memo.SetAutoCompleteSeparator(InnoSetupStylerWordListSeparator);
Memo.SetWordChars(Memo.GetDefaultWordChars+'#{}[]');
Memo.Theme := FTheme;
Memo.Visible := False;
Result := Memo;
end;
function TCompileForm.InitializeFileMemo(const Memo: TCompScintFileEdit; const PopupMenu: TPopupMenu): TCompScintFileEdit;
begin
InitializeMemoBase(Memo, PopupMenu);
Memo.CompilerFileIndex := UnknownCompilerFileIndex;
Memo.ErrorLine := -1;
Memo.StepLine := -1;
Result := Memo;
end;
function TCompileForm.InitializeMainMemo(const Memo: TCompScintFileEdit; const PopupMenu: TPopupMenu): TCompScintFileEdit;
begin
InitializeFileMemo(Memo, PopupMenu);
Memo.AcceptDroppedFiles := True;
Memo.CompilerFileIndex := -1;
Memo.OnDropFiles := MainMemoDropFiles;
Memo.Used := True;
Result := Memo;
end;
function TCompileForm.InitializeNonFileMemo(const Memo: TCompScintEdit; const PopupMenu: TPopupMenu): TCompScintEdit;
begin
InitializeMemoBase(Memo, PopupMenu);
Memo.ReadOnly := True;
Result := Memo;
end;
constructor TCompileForm.Create(AOwner: TComponent);
procedure ReadConfig;
var
Ini: TConfigIniFile;
WindowPlacement: TWindowPlacement;
I: Integer;
Memo: TCompScintEdit;
begin
Ini := TConfigIniFile.Create;
try
{ Menu check boxes state }
Toolbar.Visible := Ini.ReadBool('Options', 'ShowToolbar', True);
StatusBar.Visible := Ini.ReadBool('Options', 'ShowStatusBar', True);
FOptions.LowPriorityDuringCompile := Ini.ReadBool('Options', 'LowPriorityDuringCompile', False);
{ Configuration options }
FOptions.ShowStartupForm := Ini.ReadBool('Options', 'ShowStartupForm', True);
FOptions.UseWizard := Ini.ReadBool('Options', 'UseWizard', True);
FOptions.Autosave := Ini.ReadBool('Options', 'Autosave', False);
FOptions.MakeBackups := Ini.ReadBool('Options', 'MakeBackups', False);
FOptions.FullPathInTitleBar := Ini.ReadBool('Options', 'FullPathInTitleBar', False);
FOptions.UndoAfterSave := Ini.ReadBool('Options', 'UndoAfterSave', True);
FOptions.PauseOnDebuggerExceptions := Ini.ReadBool('Options', 'PauseOnDebuggerExceptions', True);
FOptions.RunAsDifferentUser := Ini.ReadBool('Options', 'RunAsDifferentUser', False);
FOptions.AutoComplete := Ini.ReadBool('Options', 'AutoComplete', True);
FOptions.UseSyntaxHighlighting := Ini.ReadBool('Options', 'UseSynHigh', True);
FOptions.ColorizeCompilerOutput := Ini.ReadBool('Options', 'ColorizeCompilerOutput', True);
FOptions.UnderlineErrors := Ini.ReadBool('Options', 'UnderlineErrors', True);
FOptions.CursorPastEOL := Ini.ReadBool('Options', 'EditorCursorPastEOL', True);
FOptions.TabWidth := Ini.ReadInteger('Options', 'TabWidth', 2);
FOptions.UseTabCharacter := Ini.ReadBool('Options', 'UseTabCharacter', False);
FOptions.WordWrap := Ini.ReadBool('Options', 'WordWrap', False);
FOptions.AutoIndent := Ini.ReadBool('Options', 'AutoIndent', True);
FOptions.IndentationGuides := Ini.ReadBool('Options', 'IndentationGuides', True);
FOptions.GutterLineNumbers := Ini.ReadBool('Options', 'GutterLineNumbers', False);
FOptions.ShowPreprocessorOutput := Ini.ReadBool('Options', 'ShowPreprocessorOutput', True);
FOptions.OpenIncludedFiles := Ini.ReadBool('Options', 'OpenIncludedFiles', True);
I := Ini.ReadInteger('Options', 'ThemeType', Ord(GetDefaultThemeType));
if (I >= 0) and (I <= Ord(High(TThemeType))) then
FOptions.ThemeType := TThemeType(I);
FMainMemo.Font.Name := Ini.ReadString('Options', 'EditorFontName', FMainMemo.Font.Name);
FMainMemo.Font.Size := Ini.ReadInteger('Options', 'EditorFontSize', FMainMemo.Font.Size);
FMainMemo.Font.Charset := Ini.ReadInteger('Options', 'EditorFontCharset', FMainMemo.Font.Charset);
FMainMemo.Zoom := Ini.ReadInteger('Options', 'Zoom', 0);
for Memo in FMemos do begin
if Memo <> FMainMemo then begin
Memo.Font := FMainMemo.Font;
Memo.Zoom := FMainMemo.Zoom;
end;
end;
SyncEditorOptions;
UpdateNewMainFileButtons;
UpdateTheme;
{ Window state }
WindowPlacement.length := SizeOf(WindowPlacement);
GetWindowPlacement(Handle, @WindowPlacement);
WindowPlacement.showCmd := SW_HIDE; { the form isn't Visible yet }
WindowPlacement.rcNormalPosition.Left := Ini.ReadInteger('State',
'WindowLeft', WindowPlacement.rcNormalPosition.Left);
WindowPlacement.rcNormalPosition.Top := Ini.ReadInteger('State',
'WindowTop', WindowPlacement.rcNormalPosition.Top);
WindowPlacement.rcNormalPosition.Right := Ini.ReadInteger('State',
'WindowRight', WindowPlacement.rcNormalPosition.Left + Width);
WindowPlacement.rcNormalPosition.Bottom := Ini.ReadInteger('State',
'WindowBottom', WindowPlacement.rcNormalPosition.Top + Height);
SetWindowPlacement(Handle, @WindowPlacement);
{ Note: Must set WindowState *after* calling SetWindowPlacement, since
TCustomForm.WMSize resets WindowState }
if Ini.ReadBool('State', 'WindowMaximized', False) then
WindowState := wsMaximized;
{ Note: Don't call UpdateStatusPanelHeight here since it clips to the
current form height, which hasn't been finalized yet }
StatusPanel.Height := ToCurrentPPI(Ini.ReadInteger('State', 'StatusPanelHeight',
(10 * FromCurrentPPI(DebugOutputList.ItemHeight) + 4) + FromCurrentPPI(OutputTabSet.Height)));
finally
Ini.Free;
end;
FOptionsLoaded := True;
end;
var
I: Integer;
NewItem: TMenuItem;
PopupMenu: TPopupMenu;
Memo: TCompScintEdit;
begin
inherited;
{$IFNDEF STATICCOMPILER}
FCompilerVersion := ISDllGetVersion;
{$ELSE}
FCompilerVersion := ISGetVersion;
{$ENDIF}
FModifiedAnySinceLastCompile := True;
InitFormFont(Self);
{ For some reason, if AutoScroll=False is set on the form Delphi ignores the
'poDefault' Position setting }
AutoScroll := False;
{ Append the shortcut key text to the Edit items. Don't actually set the
ShortCut property because we don't want the key combinations having an
effect when Memo doesn't have the focus. }
SetFakeShortCut(EUndo, Ord('Z'), [ssCtrl]);
SetFakeShortCut(ERedo, Ord('Y'), [ssCtrl]);
SetFakeShortCut(ECut, Ord('X'), [ssCtrl]);
SetFakeShortCut(ECopy, Ord('C'), [ssCtrl]);
SetFakeShortCut(EPaste, Ord('V'), [ssCtrl]);
SetFakeShortCut(ESelectAll, Ord('A'), [ssCtrl]);
SetFakeShortCut(EDelete, VK_DELETE, []);
SetFakeShortCut(ECompleteWord, VK_RIGHT, [ssAlt]);
SetFakeShortCutText(VZoomIn, SmkcCtrl + 'Num +'); { These zoom shortcuts are handled by Scintilla and only support the active memo, unlike the menu items which work on all memos }
SetFakeShortCutText(VZoomOut, SmkcCtrl + 'Num -');
SetFakeShortCutText(VZoomReset, SmkcCtrl + 'Num /');
{ Use fake Esc shortcut for Stop Compile so it doesn't conflict with the
editor's autocompletion list }
SetFakeShortCut(BStopCompile, VK_ESCAPE, []);
{$IFNDEF IS_D103RIO}
{ TStatusBar needs manual scaling before Delphi 10.3 Rio }
StatusBar.Height := ToPPI(StatusBar.Height);
for I := 0 to StatusBar.Panels.Count-1 do
StatusBar.Panels[I].Width := ToPPI(StatusBar.Panels[I].Width);
{$ENDIF}
PopupMenu := TCompileFormMemoPopupMenu.Create(Self);
FMemosStyler := TInnoSetupStyler.Create(Self);
FMemosStyler.ISPPInstalled := ISPPInstalled;
FTheme := TTheme.Create;
FMemos := TList<TCompScintEdit>.Create;
FMainMemo := InitializeMainMemo(TCompScintFileEdit.Create(Self), PopupMenu);
FMemos.Add(FMainMemo);
FPreprocessorOutputMemo := InitializeNonFileMemo(TCompScintEdit.Create(Self), PopupMenu);
FMemos.Add(FPreprocessorOutputMemo);
for I := FMemos.Count to MaxMemos-1 do
FMemos.Add(InitializeFileMemo(TCompScintFileEdit.Create(Self), PopupMenu));
FFileMemos := TList<TCompScintFileEdit>.Create;
for Memo in FMemos do
if Memo is TCompScintFileEdit then
FFileMemos.Add(TCompScintFileEdit(Memo));
FActiveMemo := FMainMemo;
FActiveMemo.Visible := True;
FErrorMemo := FMainMemo;
FStepMemo := FMainMemo;
FMemosStyler.Theme := FTheme;
UpdateOutputTabSetListsItemHeightAndDebugTimeWidth;
Application.HintShortPause := 0;
Application.OnException := AppOnException;
Application.OnActivate := AppOnActivate;
Application.OnIdle := AppOnIdle;
FMRUMainFilesList := TStringList.Create;
for I := 0 to High(FMRUMainFilesMenuItems) do begin
NewItem := TMenuItem.Create(Self);
NewItem.OnClick := FMRUClick;
FMenu.Insert(FMenu.IndexOf(FMRUMainFilesSep), NewItem);
FMRUMainFilesMenuItems[I] := NewItem;
end;
FMRUParametersList := TStringList.Create;
FSignTools := TStringList.Create;
FFindResults := TFindResults.Create;
FIncludedFiles := TIncludedFiles.Create;
UpdatePreprocMemos;
FDebugTarget := dtSetup;
UpdateTargetMenu;
UpdateCaption;
UpdateThemeData(False, True);
if CommandLineCompile then begin
ReadSignTools(FSignTools);
PostMessage(Handle, WM_StartCommandLineCompile, 0, 0)
end else if CommandLineWizard then begin
{ Stop Delphi from showing the compiler form }
Application.ShowMainForm := False;
{ Show wizard form later }
PostMessage(Handle, WM_StartCommandLineWizard, 0, 0);
end else begin
ReadConfig;
ReadSignTools(FSignTools);
PostMessage(Handle, WM_StartNormally, 0, 0);
end;
end;
destructor TCompileForm.Destroy;
procedure SaveConfig;
var
Ini: TConfigIniFile;
WindowPlacement: TWindowPlacement;
begin
Ini := TConfigIniFile.Create;
try
{ Theme state }
Ini.WriteInteger('Options', 'ThemeType', Ord(FOptions.ThemeType)); { Also see TOptionsClick }
{ Menu check boxes state }
Ini.WriteBool('Options', 'ShowToolbar', Toolbar.Visible);
Ini.WriteBool('Options', 'ShowStatusBar', StatusBar.Visible);
Ini.WriteBool('Options', 'LowPriorityDuringCompile', FOptions.LowPriorityDuringCompile);
{ Window state }
WindowPlacement.length := SizeOf(WindowPlacement);
GetWindowPlacement(Handle, @WindowPlacement);
Ini.WriteInteger('State', 'WindowLeft', WindowPlacement.rcNormalPosition.Left);
Ini.WriteInteger('State', 'WindowTop', WindowPlacement.rcNormalPosition.Top);
Ini.WriteInteger('State', 'WindowRight', WindowPlacement.rcNormalPosition.Right);
Ini.WriteInteger('State', 'WindowBottom', WindowPlacement.rcNormalPosition.Bottom);
Ini.WriteBool('State', 'WindowMaximized', WindowState = wsMaximized);
Ini.WriteInteger('State', 'StatusPanelHeight', FromCurrentPPI(StatusPanel.Height));
{ Zoom state }
Ini.WriteInteger('Options', 'Zoom', FMainMemo.Zoom); { Only saves the main memo's zoom }
finally
Ini.Free;
end;
end;
begin
UpdateThemeData(True, False);
Application.OnActivate := nil;
Application.OnIdle := nil;
if FOptionsLoaded and not (CommandLineCompile or CommandLineWizard) then
SaveConfig;
if FDevMode <> 0 then
GlobalFree(FDevMode);
if FDevNames <> 0 then
GlobalFree(FDevNames);
FTheme.Free;
DestroyDebugInfo;
FIncludedFiles.Free;
FFindResults.Free;
FSignTools.Free;
FMRUParametersList.Free;
FMRUMainFilesList.Free;
FFileMemos.Free;
FMemos.Free;
inherited;
end;
class procedure TCompileForm.AppOnException(Sender: TObject; E: Exception);
begin
AppMessageBox(PChar(AddPeriod(E.Message)), SCompilerFormCaption,
MB_OK or MB_ICONSTOP);
end;
procedure TCompileForm.FormAfterMonitorDpiChanged(Sender: TObject; OldDPI,
NewDPI: Integer);
begin
UpdateOutputTabSetListsItemHeightAndDebugTimeWidth;
UpdateStatusPanelHeight(StatusPanel.Height);
end;
procedure TCompileForm.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
if IsWindowEnabled(Application.Handle) then
CanClose := ConfirmCloseFile(True)
else
{ CloseQuery is also called by the VCL when a WM_QUERYENDSESSION message
is received. Don't display message box if a modal dialog is already
displayed. }
CanClose := False;
end;
procedure TCompileForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if ShortCut(Key, Shift) = VK_ESCAPE then begin
if BStopCompile.Enabled then
BStopCompileClick(Self);
end
else if (Key = VK_F6) and not(ssAlt in Shift) then begin
{ Toggle focus between panes }
Key := 0;
if ActiveControl <> FActiveMemo then
ActiveControl := FActiveMemo
else if StatusPanel.Visible then begin
case OutputTabSet.TabIndex of
tiCompilerOutput: ActiveControl := CompilerOutputList;
tiDebugOutput: ActiveControl := DebugOutputList;
tiDebugCallStack: ActiveControl := DebugCallStackList;
tiFindResults: ActiveControl := FindResultsList;
end;
end;
end;
end;
procedure TCompileForm.FormResize(Sender: TObject);
begin
{ Make sure the status panel's height is decreased if necessary in response
to the form's height decreasing }
if StatusPanel.Visible then
UpdateStatusPanelHeight(StatusPanel.Height);
end;
{$IFDEF IS_D4}
procedure TCompileForm.WndProc(var Message: TMessage);
begin
{ Without this, the status bar's owner drawn panels sometimes get corrupted and show
menu items instead. See:
http://groups.google.com/group/borland.public.delphi.vcl.components.using/browse_thread/thread/e4cb6c3444c70714 }
with Message do
case Msg of
WM_DRAWITEM:
with PDrawItemStruct(Message.LParam)^ do
if (CtlType = ODT_MENU) and not IsMenu(hwndItem) then
CtlType := ODT_STATIC;
end;
inherited
end;
{$ENDIF}
{$IFDEF IS_D5}
function TCompileForm.IsShortCut(var Message: TWMKey): Boolean;
begin
{ Key messages are forwarded by the VCL to the main form for ShortCut
processing. In Delphi 5+, however, this happens even when a TFindDialog
is active, causing Ctrl+V/Esc/etc. to be intercepted by the main form.
Work around this by always returning False when not Active. }
if Active then
Result := inherited IsShortCut(Message)
else
Result := False;
end;
{$ENDIF}
procedure TCompileForm.UpdateCaption;
var
NewCaption: String;
begin
if FMainMemo.Filename = '' then
NewCaption := GetFileTitle(FMainMemo.Filename)
else begin
if FOptions.FullPathInTitleBar then
NewCaption := FMainMemo.Filename
else
NewCaption := GetDisplayFilename(FMainMemo.Filename);
end;
NewCaption := NewCaption + ' - ' + SCompilerFormCaption + ' ' +
String(FCompilerVersion.Version);
if FCompiling then
NewCaption := NewCaption + ' [Compiling]'
else if FDebugging then begin
if not FPaused then
NewCaption := NewCaption + ' [Running]'
else
NewCaption := NewCaption + ' [Paused]';
end;
Caption := NewCaption;
if not CommandLineWizard then
Application.Title := NewCaption;
end;
procedure TCompileForm.UpdateNewMainFileButtons;
begin
if FOptions.UseWizard then begin
FNewMainFile.Caption := '&New...';
FNewMainFile.OnClick := FNewMainFileUserWizardClick;
NewMainFileButton.OnClick := FNewMainFileUserWizardClick;
end else begin
FNewMainFile.Caption := '&New';
FNewMainFile.OnClick := FNewMainFileClick;
NewMainFileButton.OnClick := FNewMainFileClick;
end;
end;