1 | unit FormMain;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
|
---|
7 | ComCtrls, ExtCtrls, SynEdit, SynHighlighterPas, Registry, Project, FileUtil,
|
---|
8 | Menus, ActnList, DateUtils, FormTargetCode, FormCodeTree, RegistryEx,
|
---|
9 | FormMessages, FormSourceCode, FormProject, FormTargetProject, FormTargets,
|
---|
10 | FormExternalProducerOutput;
|
---|
11 |
|
---|
12 | type
|
---|
13 |
|
---|
14 | { TFormMain }
|
---|
15 |
|
---|
16 | TFormMain = class(TForm)
|
---|
17 | ABuild: TAction;
|
---|
18 | AHelp: TAction;
|
---|
19 | ARunToCursor: TAction;
|
---|
20 | AStepOut: TAction;
|
---|
21 | AStepIn: TAction;
|
---|
22 | AStepOver: TAction;
|
---|
23 | AReset: TAction;
|
---|
24 | APause: TAction;
|
---|
25 | AStop: TAction;
|
---|
26 | AViewTargets: TAction;
|
---|
27 | AViewCompiledSoruce: TAction;
|
---|
28 | AViewCodeTree: TAction;
|
---|
29 | AViewOptions: TAction;
|
---|
30 | AViewMessages: TAction;
|
---|
31 | AViewSourceEditor: TAction;
|
---|
32 | AViewObjectInspector: TAction;
|
---|
33 | AViewProject: TAction;
|
---|
34 | AHomepage: TAction;
|
---|
35 | ARun: TAction;
|
---|
36 | AAbout: TAction;
|
---|
37 | AExit: TAction;
|
---|
38 | AProjectNew: TAction;
|
---|
39 | AProjectOpen: TAction;
|
---|
40 | AProjectSave: TAction;
|
---|
41 | AProjectSaveAs: TAction;
|
---|
42 | AProjectClose: TAction;
|
---|
43 | ActionList1: TActionList;
|
---|
44 | ComboBoxTarget: TComboBox;
|
---|
45 | ImageList1: TImageList;
|
---|
46 | MainMenu: TMainMenu;
|
---|
47 | MenuItem1: TMenuItem;
|
---|
48 | MenuItem10: TMenuItem;
|
---|
49 | MenuItem11: TMenuItem;
|
---|
50 | MenuItem12: TMenuItem;
|
---|
51 | MenuItem13: TMenuItem;
|
---|
52 | MenuItem14: TMenuItem;
|
---|
53 | MenuItem15: TMenuItem;
|
---|
54 | MenuItem16: TMenuItem;
|
---|
55 | MenuItem17: TMenuItem;
|
---|
56 | MenuItem18: TMenuItem;
|
---|
57 | MenuItem19: TMenuItem;
|
---|
58 | MenuItem2: TMenuItem;
|
---|
59 | MenuItem20: TMenuItem;
|
---|
60 | MenuItem21: TMenuItem;
|
---|
61 | MenuItem22: TMenuItem;
|
---|
62 | MenuItem23: TMenuItem;
|
---|
63 | MenuItem24: TMenuItem;
|
---|
64 | MenuItem25: TMenuItem;
|
---|
65 | MenuItem26: TMenuItem;
|
---|
66 | MenuItem27: TMenuItem;
|
---|
67 | MenuItem28: TMenuItem;
|
---|
68 | MenuItem29: TMenuItem;
|
---|
69 | MenuItem30: TMenuItem;
|
---|
70 | MenuItem31: TMenuItem;
|
---|
71 | MenuItem32: TMenuItem;
|
---|
72 | MenuItem33: TMenuItem;
|
---|
73 | MenuItemProducer: TMenuItem;
|
---|
74 | MenuItem3: TMenuItem;
|
---|
75 | MenuItem4: TMenuItem;
|
---|
76 | MenuItem5: TMenuItem;
|
---|
77 | MenuItem6: TMenuItem;
|
---|
78 | MenuItem7: TMenuItem;
|
---|
79 | MenuItem8: TMenuItem;
|
---|
80 | MenuItem9: TMenuItem;
|
---|
81 | MenuItemOpenRecent: TMenuItem;
|
---|
82 | OpenDialogProject: TOpenDialog;
|
---|
83 | PageControlMain: TPageControl;
|
---|
84 | PageControlRight: TPageControl;
|
---|
85 | PageControlBottom: TPageControl;
|
---|
86 | PopupMenu1: TPopupMenu;
|
---|
87 | SaveDialogProject: TSaveDialog;
|
---|
88 | Splitter1: TSplitter;
|
---|
89 | Splitter2: TSplitter;
|
---|
90 | Splitter3: TSplitter;
|
---|
91 | TabSheetExternalProducer: TTabSheet;
|
---|
92 | TabSheetProject: TTabSheet;
|
---|
93 | TabSheetCodeTree: TTabSheet;
|
---|
94 | TabSheetMessages: TTabSheet;
|
---|
95 | TabSheetBreakpoints: TTabSheet;
|
---|
96 | TabSheetTargetProject: TTabSheet;
|
---|
97 | TabSheetSource: TTabSheet;
|
---|
98 | TabSheetTarget: TTabSheet;
|
---|
99 | ToolBar1: TToolBar;
|
---|
100 | ToolButton1: TToolButton;
|
---|
101 | ToolButton10: TToolButton;
|
---|
102 | ToolButton11: TToolButton;
|
---|
103 | ToolButton2: TToolButton;
|
---|
104 | ToolButton3: TToolButton;
|
---|
105 | ToolButton4: TToolButton;
|
---|
106 | ToolButton5: TToolButton;
|
---|
107 | ToolButton6: TToolButton;
|
---|
108 | ToolButton7: TToolButton;
|
---|
109 | ToolButton8: TToolButton;
|
---|
110 | ToolButton9: TToolButton;
|
---|
111 | procedure AAboutExecute(Sender: TObject);
|
---|
112 | procedure AExitExecute(Sender: TObject);
|
---|
113 | procedure AHomepageExecute(Sender: TObject);
|
---|
114 | procedure APauseExecute(Sender: TObject);
|
---|
115 | procedure AProjectCloseExecute(Sender: TObject);
|
---|
116 | procedure AProjectNewExecute(Sender: TObject);
|
---|
117 | procedure AProjectOpenExecute(Sender: TObject);
|
---|
118 | procedure AProjectSaveAsExecute(Sender: TObject);
|
---|
119 | procedure AProjectSaveExecute(Sender: TObject);
|
---|
120 | procedure ABuildExecute(Sender: TObject);
|
---|
121 | procedure AResetExecute(Sender: TObject);
|
---|
122 | procedure ARunExecute(Sender: TObject);
|
---|
123 | procedure ARunToCursorExecute(Sender: TObject);
|
---|
124 | procedure AStepInExecute(Sender: TObject);
|
---|
125 | procedure AStepOutExecute(Sender: TObject);
|
---|
126 | procedure AStepOverExecute(Sender: TObject);
|
---|
127 | procedure AStopExecute(Sender: TObject);
|
---|
128 | procedure AViewCodeTreeExecute(Sender: TObject);
|
---|
129 | procedure AViewCompiledSoruceExecute(Sender: TObject);
|
---|
130 | procedure AViewMessagesExecute(Sender: TObject);
|
---|
131 | procedure AViewOptionsExecute(Sender: TObject);
|
---|
132 | procedure AViewTargetsExecute(Sender: TObject);
|
---|
133 | procedure AViewProjectExecute(Sender: TObject);
|
---|
134 | procedure AViewSourceEditorExecute(Sender: TObject);
|
---|
135 | procedure ComboBoxTargetChange(Sender: TObject);
|
---|
136 | procedure FormShow(Sender: TObject);
|
---|
137 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
138 | procedure FormCreate(Sender: TObject);
|
---|
139 | procedure FormDestroy(Sender: TObject);
|
---|
140 | private
|
---|
141 | procedure MenuItemTargetClick(Sender: TObject);
|
---|
142 | procedure DockInit;
|
---|
143 | procedure UpdateMenu;
|
---|
144 | procedure UpdateTitle;
|
---|
145 | procedure ProducerProcessOutput(Text: string);
|
---|
146 | procedure ShowProject(ProjectFile: TProjectFile);
|
---|
147 | procedure ShowTargetCode(ProjectFile: TProjectFile);
|
---|
148 | public
|
---|
149 | FormMessages: TFormMessages;
|
---|
150 | FormSourceCode: TFormSourceCode;
|
---|
151 | FormProject: TFormProject;
|
---|
152 | FormTargetCode: TFormTargetCode;
|
---|
153 | FormTargetProject: TFormTargetProject;
|
---|
154 | FormExternalProducerOutput: TFormExternalProducerOutput;
|
---|
155 | FormTargets: TFormTargets;
|
---|
156 | FormCodeTree: TFormCodeTree;
|
---|
157 | procedure LoadFromRegistry(Root: HKEY; const Key: string);
|
---|
158 | procedure SaveToRegistry(Root: HKEY; const Key: string);
|
---|
159 | procedure OpenRecentClick(Sender: TObject);
|
---|
160 | function GetSource(Name: string; var SourceCode: string): Boolean;
|
---|
161 | procedure UpdateInterface;
|
---|
162 | end;
|
---|
163 |
|
---|
164 | var
|
---|
165 | FormMain: TFormMain;
|
---|
166 |
|
---|
167 |
|
---|
168 | implementation
|
---|
169 |
|
---|
170 | {$R *.lfm}
|
---|
171 |
|
---|
172 | uses
|
---|
173 | Core, Common, FormAbout, FormOptions, Target, Executor, FormProjectNew;
|
---|
174 |
|
---|
175 | resourcestring
|
---|
176 | SBuildFinished = 'Build finished in %s seconds';
|
---|
177 |
|
---|
178 | { TFormMain }
|
---|
179 |
|
---|
180 | procedure TFormMain.ABuildExecute(Sender: TObject);
|
---|
181 | begin
|
---|
182 | FormSourceCode.Save;
|
---|
183 | AProjectSave.Execute;
|
---|
184 | with Core.Core do begin
|
---|
185 | // Compile project file
|
---|
186 | Compiler.Init;
|
---|
187 |
|
---|
188 | if LogParsing then
|
---|
189 | Compiler.Analyzer.OnDebugLog := CompilerDebugLog
|
---|
190 | else Compiler.Analyzer.OnDebugLog := nil;
|
---|
191 |
|
---|
192 | if Project.Files.Count > 0 then
|
---|
193 | with TProjectFile(Project.Files[0]) do begin
|
---|
194 | Compiler.SourceFiles.Files.Clear;
|
---|
195 | Compiler.TargetFiles.Files.Clear;
|
---|
196 | Project.Files.DumpFileList(Compiler.SourceFiles.Files);
|
---|
197 | Compiler.MainSource := Project.MainSource.AbsoluteFileName;
|
---|
198 | TargetProject.FileName := ExtractFileDir(Project.FileName) + DirectorySeparator +
|
---|
199 | Compiler.CompiledFolder + DirectorySeparator + Compiler.Target.Name +
|
---|
200 | DirectorySeparator + 'Target.tppr';
|
---|
201 | Compiler.TargetFolder := ExtractFileDir(TargetProject.FileName);
|
---|
202 | Compiler.Compile;
|
---|
203 | TargetProject.Files.LoadFromList(Compiler.TargetFiles.Files);
|
---|
204 | if TargetProject.Files.Count > 0 then
|
---|
205 | TargetProject.MainSource := TProjectFile(TargetProject.Files.First);
|
---|
206 | FormTargetProject.UpdateInterface;
|
---|
207 |
|
---|
208 | FormExternalProducerOutput.Memo1.Clear;
|
---|
209 | if Assigned(Compiler.Target.Producer) then
|
---|
210 | with Compiler.Target.Producer do begin
|
---|
211 | FormExternalProducerOutput.Memo1.Lines.Add(CompilerPath + ' ' + Format(CompilerParameters, [TargetProject.MainSource.AbsoluteFileName]));
|
---|
212 | ExternalExecute(CompilerPath + ' ' + Format(CompilerParameters, [TargetProject.MainSource.AbsoluteFileName]));
|
---|
213 | end;
|
---|
214 | end;
|
---|
215 | FormProject.TreeViewProjectChange(Self, FormProject.TreeViewProject.Selected);
|
---|
216 | Compiler.ErrorMessage(Format(SBuildFinished, [FloatToStrF(Compiler.ElapsedTime / OneSecond, ffGeneral, 3, 10)]), Point(0, 0), '');
|
---|
217 | FormMessages.Reload;
|
---|
218 | end;
|
---|
219 | end;
|
---|
220 |
|
---|
221 | procedure TFormMain.AResetExecute(Sender: TObject);
|
---|
222 | begin
|
---|
223 | Core.Core.Compiler.Target.Executor.Reset;
|
---|
224 | end;
|
---|
225 |
|
---|
226 | procedure TFormMain.ARunExecute(Sender: TObject);
|
---|
227 | begin
|
---|
228 | ABuildExecute(Self);
|
---|
229 | Core.Core.Compiler.Target.Executor.Run;
|
---|
230 | end;
|
---|
231 |
|
---|
232 | procedure TFormMain.ARunToCursorExecute(Sender: TObject);
|
---|
233 | begin
|
---|
234 | Core.Core.Compiler.Target.Executor.RunToCursor(0); // determine position
|
---|
235 | end;
|
---|
236 |
|
---|
237 | procedure TFormMain.AStepInExecute(Sender: TObject);
|
---|
238 | begin
|
---|
239 | Core.Core.Compiler.Target.Executor.StepIn;
|
---|
240 | end;
|
---|
241 |
|
---|
242 | procedure TFormMain.AStepOutExecute(Sender: TObject);
|
---|
243 | begin
|
---|
244 | Core.Core.Compiler.Target.Executor.StepOut;
|
---|
245 | end;
|
---|
246 |
|
---|
247 | procedure TFormMain.AStepOverExecute(Sender: TObject);
|
---|
248 | begin
|
---|
249 | Core.Core.Compiler.Target.Executor.StepOver;
|
---|
250 | end;
|
---|
251 |
|
---|
252 | procedure TFormMain.AStopExecute(Sender: TObject);
|
---|
253 | begin
|
---|
254 | Core.Core.Compiler.Target.Executor.Stop;
|
---|
255 | end;
|
---|
256 |
|
---|
257 | procedure TFormMain.AViewCodeTreeExecute(Sender: TObject);
|
---|
258 | begin
|
---|
259 | PageControlRight.TabIndex := 1;
|
---|
260 | end;
|
---|
261 |
|
---|
262 | procedure TFormMain.AViewCompiledSoruceExecute(Sender: TObject);
|
---|
263 | begin
|
---|
264 | PageControlBottom.TabIndex := 1;
|
---|
265 | end;
|
---|
266 |
|
---|
267 | procedure TFormMain.AViewMessagesExecute(Sender: TObject);
|
---|
268 | begin
|
---|
269 | PageControlBottom.TabIndex := 0;
|
---|
270 | end;
|
---|
271 |
|
---|
272 | procedure TFormMain.AViewOptionsExecute(Sender: TObject);
|
---|
273 | var
|
---|
274 | FormOptions: TFormOptions;
|
---|
275 | begin
|
---|
276 | FormOptions := TFormOptions.Create(nil);
|
---|
277 | try
|
---|
278 | FormOptions.ShowModal;
|
---|
279 | finally
|
---|
280 | FormOptions.Free;
|
---|
281 | end;
|
---|
282 | end;
|
---|
283 |
|
---|
284 | procedure TFormMain.AViewTargetsExecute(Sender: TObject);
|
---|
285 | begin
|
---|
286 | FormTargets.Show;
|
---|
287 | end;
|
---|
288 |
|
---|
289 | procedure TFormMain.AViewProjectExecute(Sender: TObject);
|
---|
290 | begin
|
---|
291 | PageControlRight.TabIndex := 0;
|
---|
292 | end;
|
---|
293 |
|
---|
294 | procedure TFormMain.AViewSourceEditorExecute(Sender: TObject);
|
---|
295 | begin
|
---|
296 | end;
|
---|
297 |
|
---|
298 | function TFormMain.GetSource(Name: string; var SourceCode: string): Boolean;
|
---|
299 | var
|
---|
300 | FileName: string;
|
---|
301 | F: TFileStream;
|
---|
302 | begin
|
---|
303 | FileName := ExtractFileDir(Core.Core.Project.FileName) + Name + '.pas';
|
---|
304 | if FileExists(FileName) then
|
---|
305 | try
|
---|
306 | F := TFileStream.Create(FileName, fmOpenRead);
|
---|
307 | SetLength(SourceCode, F.Size);
|
---|
308 | if F.Size > 0 then
|
---|
309 | F.Read(SourceCode[1], F.Size);
|
---|
310 | Result := True;
|
---|
311 | finally
|
---|
312 | F.Free;
|
---|
313 | end else Result := False;
|
---|
314 | end;
|
---|
315 |
|
---|
316 | procedure TFormMain.UpdateInterface;
|
---|
317 | begin
|
---|
318 | with Core.Core do begin
|
---|
319 | UpdateTitle;
|
---|
320 | AProjectClose.Enabled := Assigned(Project);
|
---|
321 | AProjectSave.Enabled := Assigned(Project) and Project.Modified;
|
---|
322 | AProjectSaveAs.Enabled := Assigned(Project);
|
---|
323 | (*AProgramRun.Enabled := Project.Active and (BrainFuckInterpreter.State = rsStopped);
|
---|
324 | AProgramPause.Enabled := Project.Active and (BrainFuckInterpreter.State = rsRunning);
|
---|
325 | AProgramStop.Enabled := Project.Active and (BrainFuckInterpreter.State <> rsStopped);*)
|
---|
326 | ABuild.Enabled := Assigned(Project) and Assigned(Compiler.Target) and
|
---|
327 | Assigned(Compiler.Target.Producer);
|
---|
328 | APause.Enabled := Assigned(Project) and Assigned(Compiler.Target) and
|
---|
329 | Assigned(Compiler.Target.Executor) and (Compiler.Target.Executor.State = rsRunning);
|
---|
330 | ARun.Enabled := Assigned(Project) and Assigned(Compiler.Target) and
|
---|
331 | Assigned(Compiler.Target.Executor) and ((Compiler.Target.Executor.State = rsStopped) or
|
---|
332 | (Compiler.Target.Executor.State = rsPaused));
|
---|
333 | AStop.Enabled := Assigned(Project) and Assigned(Compiler.Target) and
|
---|
334 | Assigned(Compiler.Target.Executor) and ((Compiler.Target.Executor.State = rsRunning) or
|
---|
335 | (Compiler.Target.Executor.State = rsPaused));
|
---|
336 | AStepIn.Enabled := Assigned(Project) and Assigned(Compiler.Target) and
|
---|
337 | Assigned(Compiler.Target.Executor) and ((Compiler.Target.Executor.State = rsRunning) or
|
---|
338 | (Compiler.Target.Executor.State = rsPaused));
|
---|
339 | AStepOut.Enabled := AStepIn.Enabled;
|
---|
340 | AStepOver.Enabled := AStepIn.Enabled;
|
---|
341 | ARunToCursor.Enabled := AStepIn.Enabled;
|
---|
342 | end;
|
---|
343 |
|
---|
344 | UpdateMenu;
|
---|
345 | Core.Core.Compiler.Targets.LoadToStrings(ComboBoxTarget.Items);
|
---|
346 | ComboBoxTarget.ItemIndex := Core.Core.Compiler.Targets.IndexOf(Core.Core.Compiler.Target);
|
---|
347 | FormSourceCode.UpdateInterface;
|
---|
348 | FormTargetCode.UpdateInterface;
|
---|
349 | FormProject.UpdateInterface;
|
---|
350 | end;
|
---|
351 |
|
---|
352 | procedure TFormMain.DockInit;
|
---|
353 | //var
|
---|
354 | //Container1: TCDConjoinForm;
|
---|
355 | //Container2: TCDConjoinForm;
|
---|
356 | begin
|
---|
357 | FormSourceCode.ManualDock(TabSheetSource, nil, alClient);
|
---|
358 | FormSourceCode.Align := alClient;
|
---|
359 | FormSourceCode.Show;
|
---|
360 | FormMessages.ManualDock(TabSheetMessages, nil, alClient);
|
---|
361 | FormMessages.Align := alClient;
|
---|
362 | FormMessages.Show;
|
---|
363 | FormProject.ManualDock(TabSheetProject, nil, alClient);
|
---|
364 | FormProject.Align := alClient;
|
---|
365 | FormProject.Show;
|
---|
366 | FormTargetProject.ManualDock(TabSheetTargetProject, nil, alClient);
|
---|
367 | FormTargetProject.Align := alClient;
|
---|
368 | FormTargetProject.Show;
|
---|
369 | FormCodeTree.ManualDock(TabSheetCodeTree, nil, alClient);
|
---|
370 | FormCodeTree.Align := alClient;
|
---|
371 | FormCodeTree.Show;
|
---|
372 | FormTargetCode.ManualDock(TabSheetTarget, nil, alClient);
|
---|
373 | FormTargetCode.Align := alClient;
|
---|
374 | FormTargetCode.Show;
|
---|
375 | FormExternalProducerOutput.ManualDock(TabSheetExternalProducer, nil, alClient);
|
---|
376 | FormExternalProducerOutput.Align := alClient;
|
---|
377 | FormExternalProducerOutput.Show;
|
---|
378 | PageControlRight.TabIndex := 0;
|
---|
379 | PageControlBottom.TabIndex := 0;
|
---|
380 | PageControlMain.TabIndex := 0;
|
---|
381 |
|
---|
382 | (*ProjectManager.ManualDock(DockPanel, nil, alLeft);
|
---|
383 | ProjectManager.Show;
|
---|
384 |
|
---|
385 | Container1 := TCDManager(DockPanel.DockManager).CreateConjoinForm;
|
---|
386 | Container1.Caption := 'Tools';
|
---|
387 | Container1.Name := 'Tools';
|
---|
388 | Container1.ManualDock(DockPanel, nil, alRight);
|
---|
389 | Container1.Show;
|
---|
390 | Container1.Parent.Parent.Width := FormMain.Width;
|
---|
391 |
|
---|
392 | CodeTreeForm.ManualDock(DockPanel, nil, alRight);
|
---|
393 | CodeTreeForm.Show;
|
---|
394 |
|
---|
395 | Container2 := TCDManager(DockPanel.DockManager).CreateConjoinForm;
|
---|
396 | Container2.Caption := 'Panel';
|
---|
397 | Container2.Name := 'Tools2';
|
---|
398 | Container2.ManualDock(Container1, nil, alRight);
|
---|
399 | Container2.Show;
|
---|
400 |
|
---|
401 | MessagesForm.ManualDock(Container1, nil, alBottom);
|
---|
402 | MessagesForm.Show;
|
---|
403 |
|
---|
404 | CodeForm.ManualDock(Container2, nil, alTop);
|
---|
405 | CodeForm.Show;
|
---|
406 |
|
---|
407 |
|
---|
408 | //CompiledForm.ManualDock(Container2.Panel, nil, alTop);
|
---|
409 | //CompiledForm.Show;
|
---|
410 |
|
---|
411 | //TCoolDockManager(Container2.Panel.DockManager).DockStyle := dsTabs;
|
---|
412 |
|
---|
413 | Container1.Parent.Parent.Width := FormMain.Width - ProjectManager.Width - 200;
|
---|
414 | Container2.Parent.Parent.Height := FormMain.Height;*)
|
---|
415 | end;
|
---|
416 |
|
---|
417 | procedure TFormMain.LoadFromRegistry(Root: HKEY; const Key: string);
|
---|
418 | begin
|
---|
419 | with TRegistryEx.Create do
|
---|
420 | try
|
---|
421 | RootKey := Root;
|
---|
422 | OpenKey(Key, True);
|
---|
423 | if ValueExists('RightPanelWidth') then
|
---|
424 | PageControlRight.Width := ReadInteger('RightPanelWidth')
|
---|
425 | else PageControlRight.Width := 150;
|
---|
426 | if ValueExists('BottomPanelHeight') then
|
---|
427 | PageControlBottom.Height := ReadInteger('BottomPanelHeight')
|
---|
428 | else PageControlBottom.Height := 100;
|
---|
429 | finally
|
---|
430 | Free;
|
---|
431 | end;
|
---|
432 | end;
|
---|
433 |
|
---|
434 | procedure TFormMain.SaveToRegistry(Root: HKEY; const Key: string);
|
---|
435 | begin
|
---|
436 | with TRegistryEx.Create do
|
---|
437 | try
|
---|
438 | RootKey := Root;
|
---|
439 | OpenKey(Key, True);
|
---|
440 | WriteInteger('RightPanelWidth', PageControlRight.Width);
|
---|
441 | WriteInteger('BottomPanelHeight', PageControlBottom.Height);
|
---|
442 | finally
|
---|
443 | Free;
|
---|
444 | end;
|
---|
445 | end;
|
---|
446 |
|
---|
447 | procedure TFormMain.MenuItemTargetClick(Sender: TObject);
|
---|
448 | begin
|
---|
449 | with TMenuItem(Sender) do begin
|
---|
450 | Core.Core.Compiler.Target := TTarget(Core.Core.Compiler.Targets[MenuIndex]);
|
---|
451 | UpdateInterface;
|
---|
452 | end;
|
---|
453 | end;
|
---|
454 |
|
---|
455 | procedure TFormMain.UpdateMenu;
|
---|
456 | var
|
---|
457 | I: Integer;
|
---|
458 | NewMenuItem: TMenuItem;
|
---|
459 | begin
|
---|
460 | MenuItemProducer.Clear;
|
---|
461 | with Core.Core do
|
---|
462 | for I := 0 to Compiler.Targets.Count - 1 do begin
|
---|
463 | NewMenuItem := TMenuItem.Create(MenuItemProducer);
|
---|
464 | NewMenuItem.Caption := TTarget(Compiler.Targets[I]).Name;
|
---|
465 | NewMenuItem.OnClick := MenuItemTargetClick;
|
---|
466 | if Assigned(Compiler.Target) and
|
---|
467 | (TTarget(Compiler.Targets[I]).SysName = Compiler.Target.SysName) then NewMenuItem.Checked := True;
|
---|
468 | MenuItemProducer.Add(NewMenuItem);
|
---|
469 | end;
|
---|
470 | end;
|
---|
471 |
|
---|
472 | procedure TFormMain.UpdateTitle;
|
---|
473 | var
|
---|
474 | Title: string;
|
---|
475 | begin
|
---|
476 | Title := Core.Core.ApplicationInfo.AppName;
|
---|
477 | if Assigned(Core.Core.Project) then begin
|
---|
478 | if Core.Core.Project.FileName <> '' then Title := Core.Core.Project.FileName + ' - ' + Title;
|
---|
479 | if Core.Core.Project.Modified then Title := Title + ' *';
|
---|
480 | end;
|
---|
481 | Caption := Title;
|
---|
482 | end;
|
---|
483 |
|
---|
484 | procedure TFormMain.ProducerProcessOutput(Text: string);
|
---|
485 | begin
|
---|
486 | FormExternalProducerOutput.Memo1.Lines.Add(Text);
|
---|
487 | end;
|
---|
488 |
|
---|
489 | procedure TFormMain.ShowProject(ProjectFile: TProjectFile);
|
---|
490 | begin
|
---|
491 | FormMain.TabSheetSource.Show;
|
---|
492 | FormSourceCode.ProjectFile := ProjectFile;
|
---|
493 | end;
|
---|
494 |
|
---|
495 | procedure TFormMain.ShowTargetCode(ProjectFile: TProjectFile);
|
---|
496 | begin
|
---|
497 | FormTargetCode.ProjectFile := ProjectFile;
|
---|
498 | FormMain.TabSheetTarget.Show;
|
---|
499 | FormTargetCode.SynEdit1.Lines.Assign(ProjectFile.Source);
|
---|
500 | end;
|
---|
501 |
|
---|
502 | procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
503 | begin
|
---|
504 | AProjectClose.Execute;
|
---|
505 | Core.Core.SaveToRegistry(HKEY(Core.Core.ApplicationInfo.RegistryRoot), Core.Core.ApplicationInfo.RegistryKey);
|
---|
506 | end;
|
---|
507 |
|
---|
508 | procedure TFormMain.FormCreate(Sender: TObject);
|
---|
509 | var
|
---|
510 | I: Integer;
|
---|
511 | begin
|
---|
512 | FormMessages := TFormMessages.Create(nil);
|
---|
513 | FormSourceCode := TFormSourceCode.Create(nil);
|
---|
514 | FormProject := TFormProject.Create(nil);
|
---|
515 | FormProject.OnShowProject := ShowProject;
|
---|
516 | FormTargetCode := TFormTargetCode.Create(nil);
|
---|
517 | FormTargetProject := TFormTargetProject.Create(nil);
|
---|
518 | FormTargetProject.OnShowTargetCode := ShowTargetCode;
|
---|
519 | FormExternalProducerOutput := TFormExternalProducerOutput.Create(nil);
|
---|
520 | FormTargets := TFormTargets.Create(nil);
|
---|
521 | FormCodeTree := TFormCodeTree.Create(nil);
|
---|
522 |
|
---|
523 | with Core.Core.Compiler.Targets do
|
---|
524 | for I := 0 to Count - 1 do
|
---|
525 | with TTarget(Items[I]) do
|
---|
526 | if Assigned(Producer) then
|
---|
527 | Producer.OnProcessOutput := ProducerProcessOutput;
|
---|
528 | end;
|
---|
529 |
|
---|
530 | procedure TFormMain.FormDestroy(Sender: TObject);
|
---|
531 | begin
|
---|
532 | end;
|
---|
533 |
|
---|
534 | procedure TFormMain.OpenRecentClick(Sender: TObject);
|
---|
535 | begin
|
---|
536 | if Sender is TMenuItem then
|
---|
537 | Core.Core.ProjectOpen(StringReplace(TMenuItem(Sender).Caption, '&', '', [rfReplaceAll]));
|
---|
538 | end;
|
---|
539 |
|
---|
540 | procedure TFormMain.FormShow(Sender: TObject);
|
---|
541 | begin
|
---|
542 | Core.Core.LoadFromRegistry(HKEY(Core.Core.ApplicationInfo.RegistryRoot), Core.Core.ApplicationInfo.RegistryKey);
|
---|
543 | DockInit;
|
---|
544 | Core.Core.ProjectTemplatesInit;
|
---|
545 |
|
---|
546 | if Core.Core.ReopenLastOpenedFile and (Core.Core.LastOpenedFiles.Items.Count > 0) then
|
---|
547 | if FileExists(Core.Core.LastOpenedFiles.Items[0]) then
|
---|
548 | Core.Core.ProjectOpen(Core.Core.LastOpenedFiles.Items[0]);
|
---|
549 |
|
---|
550 | WindowState := wsMaximized;
|
---|
551 | UpdateInterface;
|
---|
552 | end;
|
---|
553 |
|
---|
554 | procedure TFormMain.AProjectOpenExecute(Sender: TObject);
|
---|
555 | begin
|
---|
556 | if Core.Core.LastOpenedFiles.Items.Count > 0 then
|
---|
557 | OpenDialogProject.FileName := Core.Core.LastOpenedFiles.Items[0]
|
---|
558 | else OpenDialogProject.FileName := ExtractFileDir(Application.ExeName);
|
---|
559 | if OpenDialogProject.Execute then begin
|
---|
560 | Core.Core.ProjectOpen(OpenDialogProject.FileName);
|
---|
561 | end;
|
---|
562 | end;
|
---|
563 |
|
---|
564 | procedure TFormMain.AProjectCloseExecute(Sender: TObject);
|
---|
565 | begin
|
---|
566 | //if Project.Modified then ; A
|
---|
567 | FormSourceCode.ProjectFile := nil;
|
---|
568 | FreeAndNil(Core.Core.Project);
|
---|
569 | FormProject.UpdateProjectTree;
|
---|
570 | UpdateInterface;
|
---|
571 | end;
|
---|
572 |
|
---|
573 | procedure TFormMain.AExitExecute(Sender: TObject);
|
---|
574 | begin
|
---|
575 | Close;
|
---|
576 | end;
|
---|
577 |
|
---|
578 | procedure TFormMain.AAboutExecute(Sender: TObject);
|
---|
579 | var
|
---|
580 | FormAbout: TFormAbout;
|
---|
581 | begin
|
---|
582 | FormAbout := TFormAbout.Create(nil);
|
---|
583 | try
|
---|
584 | FormAbout.ShowModal;
|
---|
585 | finally
|
---|
586 | FormAbout.Free;
|
---|
587 | end;
|
---|
588 | end;
|
---|
589 |
|
---|
590 | procedure TFormMain.AHomepageExecute(Sender: TObject);
|
---|
591 | begin
|
---|
592 | OpenWebPage(Core.Core.ApplicationInfo.HomePage);
|
---|
593 | end;
|
---|
594 |
|
---|
595 | procedure TFormMain.APauseExecute(Sender: TObject);
|
---|
596 | begin
|
---|
597 | Core.Core.Compiler.Target.Executor.Pause;
|
---|
598 | end;
|
---|
599 |
|
---|
600 | procedure TFormMain.AProjectNewExecute(Sender: TObject);
|
---|
601 | var
|
---|
602 | FormProjectNew: TFormProjectNew;
|
---|
603 | begin
|
---|
604 | FormProjectNew := TFormProjectNew.Create(nil);
|
---|
605 | if FormProjectNew.ShowModal = mrOk then begin
|
---|
606 | if Assigned(FormProjectNew.ListView1.Selected) then begin
|
---|
607 | if TProjectTemplate(FormProjectNew.ListView1.Selected.Data).IsProject then
|
---|
608 | Core.Core.ProjectNew;
|
---|
609 | TProjectTemplate(FormProjectNew.ListView1.Selected.Data).InitProject(Core.Core.Project);
|
---|
610 | end;
|
---|
611 | end;
|
---|
612 | FormProjectNew.Free;
|
---|
613 | UpdateInterface;
|
---|
614 | end;
|
---|
615 |
|
---|
616 | procedure TFormMain.AProjectSaveAsExecute(Sender: TObject);
|
---|
617 | begin
|
---|
618 | if Core.Core.LastOpenedFiles.Items.Count > 0 then
|
---|
619 | SaveDialogProject.FileName := Core.Core.LastOpenedFiles.Items[0]
|
---|
620 | else SaveDialogProject.FileName := ExtractFileDir(Application.ExeName);
|
---|
621 | if Assigned(Core.Core.Project) then
|
---|
622 | if SaveDialogProject.Execute then begin
|
---|
623 | Core.Core.Project.SaveToFile(SaveDialogProject.FileName);
|
---|
624 | FormSourceCode.Save;
|
---|
625 | Core.Core.Project.Save;
|
---|
626 | UpdateInterface;
|
---|
627 | Core.Core.LastOpenedFiles.AddItem(SaveDialogProject.FileName);
|
---|
628 | end;
|
---|
629 | end;
|
---|
630 |
|
---|
631 | procedure TFormMain.AProjectSaveExecute(Sender: TObject);
|
---|
632 | begin
|
---|
633 | FormSourceCode.Save;
|
---|
634 | if not FileExists(Core.Core.Project.FileName) then AProjectSaveAs.Execute
|
---|
635 | else Core.Core.Project.SaveToFile(Core.Core.Project.FileName);
|
---|
636 | end;
|
---|
637 |
|
---|
638 | procedure TFormMain.ComboBoxTargetChange(Sender: TObject);
|
---|
639 | begin
|
---|
640 | with TMenuItem(Sender) do begin
|
---|
641 | Core.Core.Compiler.Target := TTarget(Core.Core.Compiler.Targets[ComboBoxTarget.ItemIndex]);
|
---|
642 | UpdateInterface;
|
---|
643 | end;
|
---|
644 | end;
|
---|
645 |
|
---|
646 | end.
|
---|