-
Notifications
You must be signed in to change notification settings - Fork 86
/
uDM.pas
7403 lines (6756 loc) · 224 KB
/
uDM.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 uDM;
interface
uses
System.SysUtils, System.Classes, Vcl.Dialogs, Vcl.StdCtrls, System.Actions, Vcl.ActnList,
Vcl.XPStyleActnCtrls, Vcl.ActnMan, Vcl.ImgList, Vcl.Controls, Vcl.ComCtrls, uSharedGlobals,
uGroup, uProject, uProjectFile, VirtualTrees, uVisualMASMOptions, UITypes, SynEditHighlighter,
SynHighlighterAsmMASM, SynColors, SynMemo, SynCompletionProposal, SynEdit, SynHighlighterRC,
SynHighlighterBat, SynHighlighterCPM, SynHighlighterIni, Vcl.Graphics, SynUnicode,
SynHighlighterHashEntries, StrUtils, Contnrs, uVisualMASMFile, Windows, SynEditTypes,
SynEditRegexSearch, SynEditMiscClasses, SynEditSearch, uBundle, System.Generics.Collections,
Generics.Defaults, Vcl.WinHelpViewer, HTMLHelpViewer, System.IOUtils,
DesignIntf, Vcl.StdActns, uDebugger, uDebugSupportPlugin, Registry, System.TypInfo, Vcl.Menus,
uHTML, LMDDckSite, Vcl.Themes, LMDDckAlphaImages, d_frmEditor, Vcl.Forms, LMDDsgModule,
LMDIdeActns, LMDDsgDesigner, SynURIOpener, SynHighlighterURI, KHexEditor, KEditCommon,
uFrmExportFunctions, KControls;
type
TCommaPos = record
startX: integer;
endX: integer;
end;
// TDebugSupportPlugin = class(TSynEditPlugin)
// protected
// FEditor: TSynEdit;
// procedure AfterPaint(ACanvas: TCanvas; const AClip: TRect;
// FirstLine, LastLine: integer); override;
// procedure LinesInserted(FirstLine, Count: integer); override;
// procedure LinesDeleted(FirstLine, Count: integer); override;
// public
// constructor Create(editor: TSynEdit);
// end;
TScanKeywordThread = class(TThread)
private
fHighlighter: TSynCustomHighlighter;
FFunctions: TList<TFunctionData>;
FLabels: TList<TLabelData>;
fLastPercent: integer;
fScanEventHandle: THandle;
//fSource: string;
fSource: TStringList;
fSourceChanged: boolean;
FFileId: string;
procedure GetSource;
procedure SetResults;
// procedure ShowProgress;
protected
procedure Execute; override;
public
constructor Create;
destructor Destroy; override;
procedure SetModified;
procedure Shutdown;
end;
TFileAction = class(TAction)
private
FVisualMASMFile: TVisualMASMFile;
public
property VisualMASMFile: TVisualMASMFile read FVisualMASMFile write FVisualMASMFile;
end;
Tdm = class(TDataModule)
ActionManager1: TActionManager;
actOptions: TAction;
actFileNew32BitWindowsExeAppAddToGroup: TAction;
actAbout: TAction;
actNew32BitWindowsDllApp: TAction;
actNew64BitWindowsExeApp: TAction;
actNew64BitWindowsDllApp: TAction;
actNew16BitDOSComApp: TAction;
actSearchFind: TAction;
actFindInFiles: TAction;
actSearchReplace: TAction;
actSearchAgain: TAction;
actSearchPrevious: TAction;
actGoToLineNumber: TAction;
actWelcomePage: TAction;
actHelpInstallingVisualMASM: TAction;
actGettingStarted: TAction;
actHelloWorldMSDOS: TAction;
actHelloWorldWindows: TAction;
actAskQuestionsProvideFeedback: TAction;
actNew16BitDOSExeApp: TAction;
actNew16BitWindowsExeApp: TAction;
actNew16BitWindowsDllApp: TAction;
actResources: TAction;
actClosePage: TAction;
actAddNewAssemblyFile: TAction;
actViewProjectManager: TAction;
actViewOutput: TAction;
actViewCommandLine: TAction;
actProperties: TAction;
actNewOther: TAction;
actAddNewTextFile: TAction;
actAddToProject: TAction;
actAddNewBatchFile: TAction;
actNewProjectGroup: TAction;
actOpenProject: TAction;
actShowInExplorer: TAction;
actDOSPromnptHere: TAction;
actRemoveFromProject: TAction;
actDeleteFile: TAction;
actSave: TAction;
actAddNewProject: TAction;
actAddExistingProject: TAction;
actNew16BitDOSComAppAddToGroup: TAction;
actEditUndo: TAction;
actEditRedo: TAction;
actEditCut: TAction;
actEditCopy: TAction;
actEditPaste: TAction;
actCopyPath: TAction;
actReopenFile: TAction;
actAssembleFile: TAction;
actProjectBuild: TAction;
actProjectOptions: TAction;
actFileRename: TAction;
actProjectRename: TAction;
actGroupRename: TAction;
actProjectAssemble: TAction;
actProjectSave: TAction;
actProjectSaveAs: TAction;
actGroupSaveAs: TAction;
actFileSaveAs: TAction;
actGroupRemoveProject: TAction;
actGroupSave: TAction;
actProjectRun: TAction;
actFileSaveAll: TAction;
actEditDelete: TAction;
actEditCommentLine: TAction;
actEditSelectAll: TAction;
actFileOpen: TAction;
actProjectMakeActiveProject: TAction;
actFileClose: TAction;
actFileCloseAll: TAction;
actGroupAssembleAllProjects: TAction;
actGroupBuildAllProjects: TAction;
ImageList1: TImageList;
actGroupNewGroup: TAction;
synASMMASM: TSynAsmMASMSyn;
SynCompletionProposal1: TSynCompletionProposal;
SynAutoComplete1: TSynAutoComplete;
synRC: TSynRCSyn;
synBat: TSynBatSyn;
synIni: TSynIniSyn;
synCPP: TSynCPMSyn;
SynEditSearch1: TSynEditSearch;
SynEditRegexSearch1: TSynEditRegexSearch;
actSearchGoToFunction: TAction;
actSearchGoToLabel: TAction;
actEditHighlightWords: TAction;
actEditLowerCase: TAction;
actEditUpperCase: TAction;
actEditCamcelCase: TAction;
actHelpWin32Help: TAction;
actFileAddNewDialog: TAction;
imgDesigner: TImageList;
actAddNewRCFile: TAction;
actAddNewIncludeFile: TAction;
actToggleDialogAssembly: TAction;
actViewIncreaseFontSize: TAction;
actHelpMSProgrammersGuide: TAction;
actHelpMSREf: TAction;
actFileNew32BitWindowsConsoleApp: TAction;
actHelpVideosWhy: TAction;
scpParams: TSynCompletionProposal;
actHelpWinAPIIndex: TAction;
dlgSave: TSaveDialog;
dlgPath: TFileOpenDialog;
dlgOpen: TOpenDialog;
iml64x64Icons: TImageList;
iml32x32Icons: TImageList;
ActionImages: TLMDAlphaImageList;
iml128x128: TLMDAlphaImageList;
actDesignShowAlignPalette: TAction;
actDesignTestDialog: TAction;
RunTimeModule: TLMDModule;
LMDAlignToGrid1: TLMDAlignToGrid;
LMDAlignLeft1: TLMDAlignLeft;
LMDAlignRight1: TLMDAlignRight;
LMDAlignHSpaceEqually1: TLMDAlignHSpaceEqually;
LMDAlignHCenter1: TLMDAlignHCenter;
LMDAlignHCenterInWindow1: TLMDAlignHCenterInWindow;
LMDAlignTop1: TLMDAlignTop;
LMDAlignBottom1: TLMDAlignBottom;
LMDAlignVSpaceEqually1: TLMDAlignVSpaceEqually;
LMDAlignVCenter1: TLMDAlignVCenter;
LMDAlignVCenterInWindow1: TLMDAlignVCenterInWindow;
LMDDsgCut1: TLMDDsgCut;
LMDDsgCopy1: TLMDDsgCopy;
LMDDsgPaste1: TLMDDsgPaste;
LMDDsgSelectAll1: TLMDDsgSelectAll;
LMDDsgDelSelected1: TLMDDsgDelSelected;
LMDDsgClearLocks1: TLMDDsgClearLocks;
LMDDsgLockSelected1: TLMDDsgLockSelected;
LMDDsgBringToFront1: TLMDDsgBringToFront;
LMDDsgSendToBack1: TLMDDsgSendToBack;
LMDDsgTabOrderDlg1: TLMDDsgTabOrderDlg;
LMDDsgCreationOrderDlg1: TLMDDsgCreationOrderDlg;
iml64x64: TLMDAlphaImageList;
actProjectRunDebug: TAction;
actFileNew32BitWindowsDialogApp: TAction;
synURISyn: TSynURISyn;
synURIOpener: TSynURIOpener;
actFileOpenFileInProjectManager: TAction;
actFileCompile: TAction;
actGroupChangeProjectBuildOrder: TAction;
actExportFunctions: TAction;
actAddNewModuleDefinitionFile: TAction;
actEditIncreaseFontSize: TAction;
actEditDecreaseFontSize: TAction;
actHelpVideosSetup: TAction;
actHelpVideosHelloWorld: TAction;
actHelpVideosMsgBoxApp: TAction;
actHelpVideoDialogApp: TAction;
actHelpVideosConsoleApp: TAction;
actHelpVideosDLLs: TAction;
actHelpVideosLibrary: TAction;
actAddNewManifestFile: TAction;
procedure actAddNewAssemblyFileExecute(Sender: TObject);
procedure actGroupNewGroupExecute(Sender: TObject);
procedure actAddNewProjectExecute(Sender: TObject);
procedure DataModuleCreate(Sender: TObject);
procedure actAboutExecute(Sender: TObject);
procedure AssignColorsToEditor(memo: TSynMemo);
procedure actEditSelectAllExecute(Sender: TObject);
procedure actEditCopyExecute(Sender: TObject);
procedure actEditPasteExecute(Sender: TObject);
procedure actEditCutExecute(Sender: TObject);
procedure actEditUndoExecute(Sender: TObject);
procedure actEditRedoExecute(Sender: TObject);
procedure actEditDeleteExecute(Sender: TObject);
procedure actEditCommentLineExecute(Sender: TObject);
procedure actFileCloseAllExecute(Sender: TObject);
procedure actAddNewTextFileExecute(Sender: TObject);
procedure actAddNewBatchFileExecute(Sender: TObject);
procedure actNewOtherExecute(Sender: TObject);
procedure actAddToProjectExecute(Sender: TObject);
procedure actFileRenameExecute(Sender: TObject);
procedure actFileNew32BitWindowsExeAppAddToGroupExecute(Sender: TObject);
procedure actNew64BitWindowsExeAppExecute(Sender: TObject);
procedure actNew16BitDOSComAppExecute(Sender: TObject);
procedure actNew16BitDOSExeAppExecute(Sender: TObject);
procedure actSaveExecute(Sender: TObject);
procedure actAddExistingProjectExecute(Sender: TObject);
procedure actOpenProjectExecute(Sender: TObject);
procedure actReopenFileExecute(Sender: TObject);
procedure actShowInExplorerExecute(Sender: TObject);
procedure actGroupRemoveProjectExecute(Sender: TObject);
procedure actProjectRenameExecute(Sender: TObject);
procedure actCopyPathExecute(Sender: TObject);
procedure actDOSPromnptHereExecute(Sender: TObject);
procedure actProjectMakeActiveProjectExecute(Sender: TObject);
procedure actGroupSaveAsExecute(Sender: TObject);
procedure actProjectSaveAsExecute(Sender: TObject);
procedure actProjectSaveExecute(Sender: TObject);
procedure actFileSaveAsExecute(Sender: TObject);
procedure actFileSaveAllExecute(Sender: TObject);
procedure actGroupSaveExecute(Sender: TObject);
procedure actGroupRenameExecute(Sender: TObject);
procedure actRemoveFromProjectExecute(Sender: TObject);
procedure actDeleteFileExecute(Sender: TObject);
procedure actSearchFindExecute(Sender: TObject);
procedure actSearchAgainExecute(Sender: TObject);
procedure actSearchReplaceExecute(Sender: TObject);
procedure actSearchPreviousExecute(Sender: TObject);
procedure actGoToLineNumberExecute(Sender: TObject);
procedure actOptionsExecute(Sender: TObject);
procedure actProjectBuildExecute(Sender: TObject);
procedure actProjectAssembleExecute(Sender: TObject);
procedure actAssembleFileExecute(Sender: TObject);
procedure actProjectRunExecute(Sender: TObject);
procedure actProjectOptionsExecute(Sender: TObject);
procedure DataModuleDestroy(Sender: TObject);
procedure actSearchGoToFunctionExecute(Sender: TObject);
procedure actSearchGoToLabelExecute(Sender: TObject);
procedure actEditHighlightWordsExecute(Sender: TObject);
procedure actEditLowerCaseExecute(Sender: TObject);
procedure actEditUpperCaseExecute(Sender: TObject);
procedure actEditCamcelCaseExecute(Sender: TObject);
procedure actHelpWin32HelpExecute(Sender: TObject);
procedure actFileAddNewDialogExecute(Sender: TObject);
procedure actAddNewRCFileExecute(Sender: TObject);
procedure actAddNewIncludeFileExecute(Sender: TObject);
procedure actToggleDialogAssemblyExecute(Sender: TObject);
procedure actToggleDialogAssemblyUpdate(Sender: TObject);
procedure actHelpMSProgrammersGuideExecute(Sender: TObject);
procedure actHelpMSREfExecute(Sender: TObject);
procedure actFileNew32BitWindowsConsoleAppExecute(Sender: TObject);
procedure actHelpVideosWhyExecute(Sender: TObject);
procedure OnParamsExecute(Kind: SynCompletionType; Sender: TObject; var CurrentInput: string; var x, y: Integer;
var CanExecute: Boolean);
procedure actHelpWinAPIIndexExecute(Sender: TObject);
procedure actDesignShowAlignPaletteExecute(Sender: TObject);
procedure actDesignTestDialogExecute(Sender: TObject);
procedure actProjectRunDebugExecute(Sender: TObject);
procedure actFileOpenExecute(Sender: TObject);
procedure actGroupBuildAllProjectsExecute(Sender: TObject);
procedure actGroupAssembleAllProjectsExecute(Sender: TObject);
procedure actResourcesExecute(Sender: TObject);
procedure actFileNew32BitWindowsDialogAppExecute(Sender: TObject);
procedure actFileOpenFileInProjectManagerExecute(Sender: TObject);
procedure actFileCompileExecute(Sender: TObject);
procedure actGroupChangeProjectBuildOrderExecute(Sender: TObject);
procedure actNew32BitWindowsDllAppExecute(Sender: TObject);
procedure actNew64BitWindowsDllAppExecute(Sender: TObject);
procedure actNew16BitWindowsDllAppExecute(Sender: TObject);
procedure actExportFunctionsExecute(Sender: TObject);
procedure actAddNewModuleDefinitionFileExecute(Sender: TObject);
procedure actNew16BitWindowsExeAppExecute(Sender: TObject);
procedure actEditIncreaseFontSizeExecute(Sender: TObject);
procedure actEditDecreaseFontSizeExecute(Sender: TObject);
procedure actHelpVideosSetupExecute(Sender: TObject);
procedure actHelpVideosHelloWorldExecute(Sender: TObject);
procedure actHelpVideosMsgBoxAppExecute(Sender: TObject);
procedure actHelpVideoDialogAppExecute(Sender: TObject);
procedure actHelpVideosConsoleAppExecute(Sender: TObject);
procedure actHelpVideosDLLsExecute(Sender: TObject);
procedure actHelpVideosLibraryExecute(Sender: TObject);
procedure actAddNewManifestFileExecute(Sender: TObject);
private
FDesigner: TLMDDesigner;
FStatusBar: TStatusBar;
FNextDocId: integer;
FGroup: TGroup;
FVisualMASMOptions: TVisualMASMOptions;
// FHighlighterColorStrings: TStringList;
// FHighlighterStrings: TStringList;
// FSynColors: TSynColors;
FCodeCompletionList: TStringList;
FCodeCompletionInsertList: TStringList;
FParamLookupList: TStringList;
FParamList: TStringList;
FShuttingDown: boolean;
FLastTabIndex: integer;
FLastOpenDialogDirectory: string;
// FDebugSupportPlugins: TList<TDebugSupportPlugin>;
FWeHaveAssemblyErrors: boolean;
FPressingCtrl: boolean;
FToken: string;
FParamToken: string;
FAttributes: TSynHighlighterAttributes;
FSearchFromCaret: boolean;
FBundles: TStringList;
FWorkerThread: TThread;
FFunctions: TList<TFunctionData>;
FLabels: TList<TLabelData>;
FSearchKey: string;
FIgnoreAll: boolean;
FMnemonics: TStringList;
FRegisters: TStringList;
FDirectives: TStringList;
FOperators: TStringList;
FCommas: TList<TCommaPos>;
procedure CommentUncommentLine(memo: TSynMemo);
procedure CreateStatusBar(pnl: TLMDDockPanel);
function CreateMemo(projectFile: TProjectFile; pnl: TLMDDockPanel): TSynMemo;
function ProcessCommentText(text: string): string;
procedure FocusMemo(pnl: TLMDDockPanel);
function ReadWin32BitExeMasm32File: string;
function ReadWin64BitExeWinSDK64File: string;
function Read16BitDosCOMStub: string;
function Read16BitDosEXEStub: string;
procedure SynMemoOnEnter(sender: TObject);
procedure UpdatePageCaption(projectFile: TProjectFile);
procedure ClosePanelByProjectFileIntId(intId: integer);
procedure ClosePanelsByProject(project: TProject);
function GetSynMemoFromProjectFile(projectFile: TProjectFile): TSynMemo;
procedure AddExistingProject(title: string; addProject: boolean);
procedure OpenGroupOrProject(fileName: string; addProject: boolean);
procedure UpdateMenuWithLastUsedFiles(fileName: string = '');
function LoadProject(fileName: string): TProject;
procedure SetProjectName(project: TProject; oldName: string; name: string = '');
function SaveProject(project: TProject; fileName: string = ''): boolean;
function PromptForProjectFileName(project: TProject): string;
function StrippedOfNonAscii(const s: string): string;
function CreateProject(name: string; projectType: TProjectType = ptWin32): TProject;
function CreateProjectFile(name: string; fileType: TProjectFileType = pftASM): TProjectFile;
procedure FocusFileInTabs(id: string);
procedure RemoveTabsheet(projectFile: TProjectFile);
function GetCurrentFileInProjectExplorer: TProjectFile;
procedure SynMemoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure SynEditorStatusChange(Sender: TObject; Changes: TSynStatusChanges);
procedure StatusBarHintHandler(Sender: TObject);
procedure ShowSearchReplaceDialog(AReplace: boolean);
procedure DoSearchReplaceText(AReplace: boolean; ABackwards: boolean; memo: TSynMemo);
procedure HideWelcomePage;
procedure BuildProject(project: TProject; useActiveProject: boolean; debug: boolean);
function AssembleProject(project: TProject; useActiveProject: boolean; debug: boolean = false): boolean;
procedure LinkProject(project: TProject; debug: boolean = false);
procedure ExecuteCommandLines(executeStrings: string);
function AssembleFile(pf: TProjectFile; project: TProject; debug: boolean = false): boolean;
procedure ClearAssemblyErrors(pf: TProjectFile);
function ParseAssemblyOutput(output: string; projectFile: TProjectFile): boolean;
procedure PositionCursorToFirstError(projectFile: TProjectFile);
function CreateSwitchesCommandFile(project: TProject; finalFile: string; debug: boolean = false): string;
function CreateCommandFile(project: TProject; switches: string = ''): string;
procedure CleanupFiles(project: TProject);
procedure FocusTabWithAssemblyErrors(project: TProject);
procedure RunProject(project: TProject; useActiveProject: boolean = true; debug: boolean = false);
procedure LocateML;
procedure CreateBundles;
procedure SynEditorSpecialLineColors(Sender: TObject; Line: Integer; var Special: Boolean; var FG, BG: TColor);
procedure DoOnChangeSynMemo(sender: TObject);
procedure DoSynMemoDblClick(sender: TObject);
procedure DoOnPaintTransient(Sender: TObject; Canvas: TCanvas; TransientType: TTransientType);
procedure HighlightWords(memo: TSynMemo);
procedure DoChange(Sender: TObject);
function CamelCase(const s: string): string; var t1: integer; first: boolean;
procedure CheckForWin32HLP;
procedure UpdateStatusBarFor(regularText: string = '');
procedure ReadError(Reader: TReader; const Message: string; var Handled: Boolean);
procedure ReaderCreateComponent(Reader: TReader; ComponentClass: TComponentClass; var Component: TComponent);
function GetFormDesignerFromProjectFile(projectFile: TProjectFile): TfrmEditor;
procedure DoAcceptProperty(const PropEdit: IProperty; var PropName: WideString; var Accept: Boolean);
function ResourceCompileFile(pf: TProjectFile; project: TProject): boolean;
procedure DeleteProjectFileFromDebugPlugin(pf: TProjectFile);
procedure CheckEnvironmentVariable;
function FindMethod(const MethName: string): boolean;
// procedure GetParamList(ptData: PTypeData; SL: TStrings);
function GetMASMEndTokenLineNumber: integer;
procedure UpdateFunctionList(memo: TSynMemo);
procedure UpdateToggleUI;
procedure DoOnMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
procedure DoOnMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
procedure SynMemoMouseCursor(Sender: TObject; const aLineCharPos: TBufferCoord; var aCursor: TCursor);
// function RunAsAdminAndWaitForCompletion(hWnd: HWND; filename: string; Parameters: string): Boolean;
function VerifyFileLocations(project: TProject): boolean;
procedure HighlightFirstFileInProject(project: TProject);
procedure LoadParamterList;
function CountOccurences(const SubText: string; const Text: string): integer;
procedure DockAsTabbedDoc(APanel: TLMDDockPanel);
function GetActivePanel: TLMDDockPanel;
function AtLeastOneDocumentOpen: boolean;
function GetPanelByProjectFileIntId(id: integer): TLMDDockPanel;
function GetStatusBar: TStatusBar;
function GetProjectFileFromActivePanel: TProjectFile;
function GetDialogStyle(f: TForm): string;
function GetCommonProperties(left, top, width, height: integer): string;
function GetButtonStyle(btn: TButton): string;
procedure OnClosePanel(Sender: Tobject; var CloseAction: TLMDockPanelCloseAction);
procedure AdjustBasedOnTheme(theme: string);
procedure ApplyDarkHelp(theme: string);
procedure ApplyBrightHelp;
procedure LoadCodeCompletionList;
function FunctionExistsInSourceFile(functionName: string; pf: TProjectFile): boolean;
function GetFrmEditorFromActiveDesigner: TfrmEditor;
procedure UpdateActionItemsWithCurrentDesigner;
procedure UpdateRunMenu;
procedure MenuItemDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure OnRunDebugMenuItemClick(Sender: TObject);
procedure OnRunReleaseMenuItemClick(Sender: TObject);
procedure CreateOutputFiles(project: TProject; debug: boolean = false);
procedure ApplyBrightRCHighLighting;
procedure ApplyDarkRCHighLighting;
procedure ApplyBrightBATHighLighting;
procedure ApplyDarkBATHighLighting;
function GetCurrentProjectInProjectExplorer: TProject;
procedure CreateOutputFile(pf: TProjectFile; project: TProject; debug: boolean = false);
procedure ToggleTabs;
procedure FocusPanel(fileIntId: integer);
procedure HexEditorChange(Sender: TObject);
function GetHexEditorFromProjectFile(projectFile: TProjectFile): TKHexEditor;
function GetDefFileFromProject(project: TProject): TProjectFile;
procedure ParseModuleDefinitionFile(project: TProject);
procedure ApplyThemeToHexEditor(e: TKHexEditor);
procedure ApplyDarkSelectionColorForTrees;
procedure ClearAssembleErrorMarks(pf: TProjectFile = nil);
procedure DisplayErrorPanel(pf: TProjectFile);
procedure ParseDesignerFormsInProject(project: TProject);
function IsFileLoadedIntoPanel(pf: TProjectFile): boolean;
procedure GetDlus(dc: HDC; out HorizontalDluSize, VerticalDluSize: Real);
procedure GetDlgBaseUnits(handle: HWND; leftPixels, topPixels, widthPixels, heightPixels: integer;
out leftDLUs, topDLUs, widthDLUs, heightDLUs: integer);
procedure AssignManigestToResourceFile(project: TProject);
public
function GetMemo: TSynMemo;
procedure UpdateStatusBarForMemo(memo: TSynMemo; regularText: string = '');
procedure LoadGroup(fileName: string);
procedure CreateEditor(projectFile: TProjectFile);
procedure Initialize;
procedure SynchronizeProjectManagerWithGroup;
function SaveChanges: boolean;
property Group: TGroup read FGroup;
property VisualMASMOptions: TVisualMASMOptions read FVisualMASMOptions;
procedure SaveGroup(fileName: string);
procedure UpdateUI(highlightActiveNode: boolean);
procedure HighlightNode(intId: integer);
property ShuttingDown: boolean read FShuttingDown write FShuttingDown;
property LastTabIndex: integer read FLastTabIndex write FLastTabIndex;
procedure FocusPage(projectFile: TProjectFile; updateContent: boolean = false);
function OpenFile(dlgTitle: string; fileToOpen: string = ''): TProjectFile;
function AddFileToCurrentProject(dlgTitle: string): TProjectFile;
procedure CreateNewProject(projectType: TProjectType);
procedure CloseProjectFile(intId: integer);
procedure SaveFileContent(projectFile: TProjectFile);
function PromptForFileName(projectFile: TProjectFile): string;
procedure CheckIfChangesHaveBeenMadeAndPromptIfNecessary;
property Token: string read FToken write FToken;
procedure ToggleBookMark(bookmark: integer);
procedure GoToBookMark(bookmark: integer);
property Bundles: TStringList read FBundles write FBundles;
function GetBundle(mlMD5Hash: string): TBundle;
function PlatformString(platformType: TPlatformType): string;
procedure PromptForFile(fn: string; txtControl: TEdit);
procedure PromptForPath(caption: string; txtControl: TEdit);
property Functions: TList<TFunctionData> read FFunctions write FFunctions;
property Labels: TList<TLabelData> read FLabels write FLabels;
procedure SynchronizeFunctions;
procedure SynchronizeLabels;
procedure GoToFunctionOnLine(line: integer);
procedure ApplyTheme(name: string; updateTabs: boolean = true);
procedure LoadColors(theme: string);
procedure LoadDialog(projectFile: TProjectFile; pnl: TLMDDockPanel);
function GetMemoFromProjectFile(projectFile: TProjectFile): TSynMemo;
function CreateMethod(const MethName: string; fileId: string): Boolean;
function GetLineNumberForMethod(const MethName: string): integer;
procedure GoToMethod(const MethodName: string; fileId: string);
property StatusBar: TStatusBar read GetStatusBar write FStatusBar;
procedure FocusActiveFileAndMemo;
procedure Parse(c: TComponent; rcFile: TProjectFile = nil);
procedure CloseAllDialogsBeforeSwitchingTheme;
procedure AssignColorsToAllMemos(updateTabs: boolean = true);
property Designer: TLMDDesigner read FDesigner write FDesigner;
procedure SiteChanged;
procedure ResetProjectOutputFolder(project: TProject);
procedure UpdateProjectMenuItems;
function IsThemeBright: boolean;
procedure PrepareToOpenFileFromCommandLine;
procedure GoToLineNumber(IntId: integer; ln: integer);
end;
var
dm: Tdm;
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
uses
uFrmMain, uFrmNewItems, uFrmAbout, uTFile, uFrmRename,
WinApi.ShellApi, Messages, Vcl.Clipbrd, JsonDataObjects,
dlgConfirmReplace, dlgReplaceText, dlgSearchText, uFrmLineNumber,
uFrmOptions, uML, uFrmSetup, uFrmProjectOptions, uFrmDownload, uFrmVideo, uFrmProjectBuildOrder;
var
gbSearchBackwards: boolean;
gbSearchCaseSensitive: boolean;
gbSearchFromCaret: boolean;
gbSearchSelectionOnly: boolean;
// gbSearchTextAtCaret: boolean;
gbSearchWholeWords: boolean;
gbSearchRegex: boolean;
gsSearchText: string;
gsSearchTextHistory: string;
gsReplaceText: string;
gsReplaceTextHistory: string;
//constructor TDebugSupportPlugin.Create(editor: TSynEdit);
//begin
// inherited Create(editor);
// FEditor := editor;
//end;
//
//procedure TDebugSupportPlugin.AfterPaint(ACanvas: TCanvas; const AClip: TRect;
// FirstLine, LastLine: integer);
//begin
//// FEditor.PaintGutterGlyphs(ACanvas, AClip, FirstLine, LastLine);
//end;
//
//procedure TDebugSupportPlugin.LinesInserted(FirstLine, Count: integer);
//begin
//// Note: You will need this event if you want to track the changes to
//// breakpoints in "Real World" apps, where the editor is not read-only
//end;
//
//procedure TDebugSupportPlugin.LinesDeleted(FirstLine, Count: integer);
//begin
//// Note: You will need this event if you want to track the changes to
//// breakpoints in "Real World" apps, where the editor is not read-only
//end;
procedure Tdm.Initialize;
var
i: integer;
begin
FCommas := TList<TCommaPos>.Create;
//actViewIncreaseFontSize.ShortCut := Vcl.menus.ShortCut(VK_OEM_PLUS, [ssCtrl]);
// TextToShortCut('Ctrl') + VK_OEM_PLUS;
FDirectives := TStringList.Create;
FDirectives.Delimiter := ',';
FDirectives.DelimitedText := Directives;
FRegisters := TStringList.Create;
FRegisters.Delimiter := ',';
FRegisters.DelimitedText := Registers;
FMnemonics := TStringList.Create;
FMnemonics.Delimiter := ',';
FMnemonics.DelimitedText := Mnemonics;
FOperators := TStringList.Create;
FOperators.Delimiter := ',';
FOperators.DelimitedText := Operators;
FFunctions := TList<TFunctionData>.Create;
FLabels := TList<TLabelData>.Create;
FWorkerThread := TScanKeywordThread.Create;
FVisualMASMOptions := TVisualMASMOptions.Create;
FVisualMASMOptions.LoadFile;
for i := 0 to FVisualMASMOptions.LastFilesUsed.Count-1 do
begin
UpdateMenuWithLastUsedFiles(FVisualMASMOptions.LastFilesUsed[i].FileName);
end;
FCodeCompletionInsertList := TStringList.Create;
FCodeCompletionInsertList.LoadFromFile(FVisualMASMOptions.AppFolder+DATA_FOLDER+CODE_COMPLETION_INSERT_LIST_FILENAME);
SynCompletionProposal1.InsertList := FCodeCompletionInsertList;
FCodeCompletionList := TStringList.Create;
// counter := 0;
// for i := 0 to SynCompletionProposal1.ItemList.Count -1 do
// begin
// inc(counter);
// end;
LoadParamterList;
FGroup := TGroup.Create(DEFAULT_PROJECTGROUP_NAME);
LoadColors('');
// *************************************************
// Create list of available MASM files to search for
// *************************************************
CreateBundles;
LocateML;
// ************************************
// Check if we have the Win32.hlp file.
// If not, try to download it.
// ************************************
CheckForWin32HLP;
end;
procedure Tdm.CheckForWin32HLP;
//var
// fs: TFileStream;
begin
if not TFile.Exists(FVisualMASMOptions.AppFolder+WIN32_HLP_FILENAME) then
begin
// // try to download WIN32_HLP_FILENAME
// if MessageDlg('Can not find the Win32 API help file. Would you like Visual MASM to '+CRLF+
// 'download it for you?'+CRLF+CRLF+
// 'The Win32 API help file is required for context sensitive help when you press F1.',
// mtCustom,[mbYes,mbCancel], 0) = mrYes then
// begin
// try
// frmDownload.Show;
// frmDownload.Caption := 'Downloading win32.hlp';
// frmDownload.sGauge1.Progress := 0;
// Application.ProcessMessages;
//
// fs := TFileStream.Create(FVisualMASMOptions.AppFolder+WIN32_HLP_FILENAME_COMPRESSED, fmCreate);
// try
// httpDownloadNewVersion.OutputStream := fs;
// httpDownloadNewVersion.Get(WIN32_HLP_URL);
// finally
// fs.Free;
// if TFile.Exists(FVisualMASMOptions.AppFolder+WIN32_HLP_FILENAME_COMPRESSED) then
// begin
// frmDownload.Caption := 'Decompressing win32.hlp';
// Application.ProcessMessages;
// with CreateInArchive(CLSID_CFormat7z) do
// begin
// SetProgressCallback(nil, ProgressCallback);
// OpenFile(FVisualMASMOptions.AppFolder+WIN32_HLP_FILENAME_COMPRESSED);
// ExtractTo(FVisualMASMOptions.AppFolder);
// end;
// end;
// frmDownload.Hide;
// end;
// except
// on E : Exception do
// begin
// //error := E.Message;
// end;
// end;
// end;
// if TFile.Exists(FVisualMASMOptions.AppFolder+WIN32_HLP_FILENAME_COMPRESSED) then
// TFile.Delete(FVisualMASMOptions.AppFolder+WIN32_HLP_FILENAME_COMPRESSED);
end else begin
Application.HelpFile := dm.VisualMASMOptions.AppFolder+WIN32_HLP_FILENAME;
//HtmlHelp(0, Application.HelpFile, HH_DISPLAY_TOC, 0);
//Application.HelpKeyword('MessageBox');
//Application.HelpCommand(HELP_FINDER, 0);
//Application.HelpContext(1);
end;
end;
procedure Tdm.LoadColors(theme: string);
var
colorFileName: string;
SearchDir: string;
searchResults : TSearchRec;
begin
if theme <>'' then
begin
colorFileName := FVisualMASMOptions.AppFolder+'Colors\'+theme+'.json';
end else begin
if (length(FVisualMASMOptions.ThemeCodeEditor)>0) and (colorFileName='') then
colorFileName := FVisualMASMOptions.AppFolder+'Colors\'+FVisualMASMOptions.ThemeCodeEditor+'.json'
else
colorFileName := FVisualMASMOptions.AppFolder+'Colors\'+EDITOR_COLORS_FILENAME;
end;
if not FileExistsStripped(colorFileName)then
begin
synASMMASM.SynColors := TSynColors.Create;
synASMMASM.SaveFile(colorFileName);
end;
synASMMASM.LoadFile(colorFileName);
// synASMMASM.DirectivesAttri
AdjustBasedOnTheme(theme);
if startingUp then
begin
SearchDir := dm.VisualMASMOptions.AppFolder+STYLES_FOLDER;
if DirectoryExists(SearchDir) then begin
if FindFirst(SearchDir+'*.vsf',faAnyFile - faDirectory, searchResults) = 0 then
repeat
try
if TStyleManager.IsValidStyle(SearchDir+searchResults.Name) then
TStyleManager.LoadFromFile(SearchDir+searchResults.Name);
except
end;
until FindNext(searchResults) <> 0;
end;
try
TStyleManager.TrySetStyle(FVisualMASMOptions.Theme);
except
end;
end;
frmMain.memOutput.Font.Name := dm.VisualMASMOptions.OutputFontName;
frmMain.memOutput.Font.Size := dm.VisualMASMOptions.OutputFontSize;
end;
function Tdm.SaveChanges: boolean;
var
promptResult: integer;
begin
result := true;
if FGroup=nil then exit;
if FGroup.Modified then
begin
promptResult := MessageDlg('Save changes?',mtCustom,[mbYes,mbNo,mbCancel], 0);
if promptResult = mrYes then
SaveGroup(FGroup.FileName);
if promptResult = mrCancel then
result := false;
end;
end;
procedure Tdm.SynchronizeProjectManagerWithGroup;
var
project: TProject;
projectFile,childProjectFile: TProjectFile;
rootNode: PVirtualNode;
projectNode: PVirtualNode;
fileNode,childFileNode: PVirtualNode;
data: PProjectData;
// promptResult: integer;
begin
if FGroup=nil then exit;
if frmMain.vstProject = nil then exit;
frmMain.vstProject.BeginUpdate;
frmMain.vstProject.Clear;
// Add the root node
rootNode := frmMain.vstProject.AddChild(nil);
frmMain.vstProject.Expanded[rootNode] := true;
data := frmMain.vstProject.GetNodeData(rootNode);
data^.ProjectId := '';
data^.Name := FGroup.Name;
data^.Level := 0;
data^.FileId := '';
data^.FileSize := 0;
for project in FGroup.Projects.Values do
begin
// Project node
projectNode := frmMain.vstProject.AddChild(rootNode);
frmMain.vstProject.Expanded[projectNode] := true;
data := frmMain.vstProject.GetNodeData(projectNode);
data^.ProjectId := project.Id;
data^.Name := project.Name;
data^.Level := 1;
data^.FileId := '';
data^.FileSize := project.SizeInBytes;
data^.ProjectIntId := project.IntId;
data^.Build := project.Build;
// Project Files
for projectFile in project.ProjectFiles.Values do
begin
if projectFile.ChildFileRCId<>'' then begin
fileNode := frmMain.vstProject.AddChild(projectNode);
data := frmMain.vstProject.GetNodeData(fileNode);
data^.ProjectId := project.Id;
data^.ProjectIntId := project.IntId;
data^.Name := projectFile.Name;
data^.Level := 2;
data^.FileId := projectFile.Id;
data^.FileSize := projectFile.SizeInBytes;
data^.FileIntId := projectFile.IntId;
childProjectFile := FGroup.GetProjectFileById(projectFile.ChildFileRCId);
if childProjectFile <> nil then
begin
childFileNode := frmMain.vstProject.AddChild(fileNode);
data := frmMain.vstProject.GetNodeData(childFileNode);
data^.ProjectId := project.Id;
data^.ProjectIntId := project.IntId;
data^.Name := childProjectFile.Name;
data^.Level := 3;
data^.FileId := childProjectFile.Id;
data^.FileSize := childProjectFile.SizeInBytes;
data^.FileIntId := childProjectFile.IntId;
end;
if projectFile.ChildFileASMId<>'' then begin
childProjectFile := FGroup.GetProjectFileById(projectFile.ChildFileASMId);
if childProjectFile <> nil then
begin
childFileNode := frmMain.vstProject.AddChild(fileNode);
data := frmMain.vstProject.GetNodeData(childFileNode);
data^.ProjectId := project.Id;
data^.ProjectIntId := project.IntId;
data^.Name := childProjectFile.Name;
data^.Level := 3;
data^.FileId := childProjectFile.Id;
data^.FileSize := childProjectFile.SizeInBytes;
data^.FileIntId := childProjectFile.IntId;
end;
end;
end else begin
if projectFile.ParentFileId='' then begin
fileNode := frmMain.vstProject.AddChild(projectNode);
data := frmMain.vstProject.GetNodeData(fileNode);
data^.ProjectId := project.Id;
data^.ProjectIntId := project.IntId;
data^.Name := projectFile.Name;
data^.Level := 2;
data^.FileId := projectFile.Id;
data^.FileSize := projectFile.SizeInBytes;
data^.FileIntId := projectFile.IntId;
end;
end;
end;
end;
frmMain.vstProject.Refresh;
frmMain.vstProject.FullExpand;
frmMain.vstProject.EndUpdate;
end;
procedure Tdm.SynchronizeFunctions;
var
node: PVirtualNode;
data: PFunctionData;
i: integer;
begin
if frmMain.vstFunctions = nil then exit;
frmMain.vstFunctions.BeginUpdate;
frmMain.vstFunctions.Clear;
// Functions.Sort(TComparer<string>.Construct(
// function (const L, R: string): integer
// begin
// Result := L - R;
// end
// )) ;
for i:=0 to FFunctions.Count-1 do
begin
//node := frmMain.vstFunctions.AddChild(rootNode);
node := frmMain.vstFunctions.AddChild(nil);
frmMain.vstFunctions.Expanded[node] := true;
data := frmMain.vstFunctions.GetNodeData(node);
if Assigned(data) then
begin
data^.Name := FFunctions.Items[i].Name;
data^.Line := FFunctions.Items[i].Line;
end;
end;
frmMain.vstFunctions.Refresh;
frmMain.vstFunctions.FullExpand;
frmMain.vstFunctions.EndUpdate;
end;
procedure Tdm.SynchronizeLabels;
var
node: PVirtualNode;
data: PLabelData;
i: integer;
begin
if frmMain.vstLabels = nil then exit;
frmMain.vstLabels.BeginUpdate;
frmMain.vstLabels.Clear;
for i:=0 to FLabels.Count-1 do
begin
node := frmMain.vstLabels.AddChild(nil);
frmMain.vstLabels.Expanded[node] := true;
data := frmMain.vstLabels.GetNodeData(node);
data^.Name := FLabels.Items[i].Name;
data^.Line := FLabels.Items[i].Line;
end;
frmMain.vstLabels.Refresh;
frmMain.vstLabels.FullExpand;
frmMain.vstLabels.EndUpdate;
end;
procedure Tdm.SaveGroup(fileName: string);
var
project: TProject;
json, jGroup, jProjects, jBuildOrder: TJSONObject;
fileContent: TStringList;
i: Integer;
begin
if fileName = '' then exit;
FGroup.FileName := fileName;
UpdateMenuWithLastUsedFiles(fileName);
FGroup.Name := ChangeFileExt(ExtractFileName(fileName), '');
json := TJSONObject.Create();
json.I['Version'] := VISUALMASM_FILE_VERSION;
jGroup := json.O['Group'];
jGroup.S['Name'] := FGroup.Name;
jGroup.S['Id'] := FGroup.Id;
jGroup.S['Created'] := DateTimeToStr(FGroup.Created);
jGroup.S['FileName'] := FGroup.FileName;
if FGroup.ActiveProject <> nil then
jGroup.S['SelectedProjectId'] := FGroup.ActiveProject.Id
else
jGroup.S['SelectedProjectId'] := '';
if (FGroup.ActiveProject <> nil) and (FGroup.ActiveProject.ActiveFile <> nil) then
FGroup.LastFileOpenId := FGroup.ActiveProject.ActiveFile.Id;
jGroup.S['LastFileOpenId'] := FGroup.LastFileOpenId;
for project in FGroup.Projects.Values do
begin
SaveProject(project);
jProjects := jGroup.A['Projects'].AddObject;
jProjects.S['Id'] := project.Id;
jProjects.S['Name'] := project.Name;
jProjects.S['FileName'] := project.FileName;
end;
for i := 0 to FGroup.BuildOrder.Count-1 do
begin
jBuildOrder := jGroup.A['BuildOrder'].AddObject;
jBuildOrder.S['Id'] := FGroup.BuildOrder[i];
end;
FGroup.Modified := false;
fileContent := TStringList.Create;
fileContent.Text := json.ToJSON(false);
fileContent.SaveToFile(fileName);
SynchronizeProjectManagerWithGroup;
UpdateUI(true);
end;
function Tdm.SaveProject(project: TProject; fileName: string = ''): boolean;
var
f: TProjectFile;
json, jProject, jFiles, jFunctions: TJSONObject;