Changeset 75 for trunk/IDE/Forms/FormMain.pas
- Timestamp:
- Jun 4, 2024, 12:22:49 AM (5 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/IDE/Forms/FormMain.pas
r74 r75 1 unit UFormMain; 2 3 {$MODE Delphi} 1 unit FormMain; 4 2 5 3 interface … … 7 5 uses 8 6 SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, 9 ComCtrls, ExtCtrls, SynEdit, SynHighlighterPas, Registry, 10 UProject, FileUtil, Menus, ActnList, DateUtils, 11 UFormTargetCode, UFormCodeTree, URegistry; 7 ComCtrls, ExtCtrls, SynEdit, SynHighlighterPas, Registry, Project, FileUtil, 8 Menus, ActnList, DateUtils, FormTargetCode, FormCodeTree, RegistryEx, 9 FormMessages, FormSourceCode, FormProject, FormTargetProject, FormTargets, 10 FormExternalProducerOutput; 12 11 13 12 type … … 145 144 procedure UpdateTitle; 146 145 procedure ProducerProcessOutput(Text: string); 146 procedure ShowProject(ProjectFile: TProjectFile); 147 procedure ShowTargetCode(ProjectFile: TProjectFile); 147 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; 148 157 procedure LoadFromRegistry(Root: HKEY; const Key: string); 149 158 procedure SaveToRegistry(Root: HKEY; const Key: string); … … 162 171 163 172 uses 164 UCore, UFormMessages, UFormSourceCode, UFormProject, UCommon, UFormAbout, UFormOptions, 165 UFormTargets, UTarget, UExecutor, UFormProjectNew, 166 UFormTargetProject, UFormExternalProducerOutput; 173 Core, Common, FormAbout, FormOptions, Target, Executor, FormProjectNew; 167 174 168 175 resourcestring … … 175 182 FormSourceCode.Save; 176 183 AProjectSave.Execute; 177 with Core do begin184 with Core.Core do begin 178 185 // Compile project file 179 186 Compiler.Init; … … 214 221 procedure TFormMain.AResetExecute(Sender: TObject); 215 222 begin 216 Core.Co mpiler.Target.Executor.Reset;223 Core.Core.Compiler.Target.Executor.Reset; 217 224 end; 218 225 … … 220 227 begin 221 228 ABuildExecute(Self); 222 Core.Co mpiler.Target.Executor.Run;229 Core.Core.Compiler.Target.Executor.Run; 223 230 end; 224 231 225 232 procedure TFormMain.ARunToCursorExecute(Sender: TObject); 226 233 begin 227 Core.Co mpiler.Target.Executor.RunToCursor(0); // determine position234 Core.Core.Compiler.Target.Executor.RunToCursor(0); // determine position 228 235 end; 229 236 230 237 procedure TFormMain.AStepInExecute(Sender: TObject); 231 238 begin 232 Core.Co mpiler.Target.Executor.StepIn;239 Core.Core.Compiler.Target.Executor.StepIn; 233 240 end; 234 241 235 242 procedure TFormMain.AStepOutExecute(Sender: TObject); 236 243 begin 237 Core.Co mpiler.Target.Executor.StepOut;244 Core.Core.Compiler.Target.Executor.StepOut; 238 245 end; 239 246 240 247 procedure TFormMain.AStepOverExecute(Sender: TObject); 241 248 begin 242 Core.Co mpiler.Target.Executor.StepOver;249 Core.Core.Compiler.Target.Executor.StepOver; 243 250 end; 244 251 245 252 procedure TFormMain.AStopExecute(Sender: TObject); 246 253 begin 247 Core.Co mpiler.Target.Executor.Stop;254 Core.Core.Compiler.Target.Executor.Stop; 248 255 end; 249 256 … … 264 271 265 272 procedure TFormMain.AViewOptionsExecute(Sender: TObject); 266 begin 267 FormOptions.ShowModal; 273 var 274 FormOptions: TFormOptions; 275 begin 276 FormOptions := TFormOptions.Create(nil); 277 try 278 FormOptions.ShowModal; 279 finally 280 FormOptions.Free; 281 end; 268 282 end; 269 283 … … 280 294 procedure TFormMain.AViewSourceEditorExecute(Sender: TObject); 281 295 begin 282 283 296 end; 284 297 … … 288 301 F: TFileStream; 289 302 begin 290 FileName := ExtractFileDir(Core. Project.FileName) + Name + '.pas';303 FileName := ExtractFileDir(Core.Core.Project.FileName) + Name + '.pas'; 291 304 if FileExists(FileName) then 292 305 try … … 303 316 procedure TFormMain.UpdateInterface; 304 317 begin 305 with Core do begin306 UpdateTitle;307 AProjectClose.Enabled := Assigned(Project);308 AProjectSave.Enabled := Assigned(Project) and Project.Modified;309 AProjectSaveAs.Enabled := Assigned(Project);310 (*AProgramRun.Enabled := Project.Active and (BrainFuckInterpreter.State = rsStopped);311 AProgramPause.Enabled := Project.Active and (BrainFuckInterpreter.State = rsRunning);312 AProgramStop.Enabled := Project.Active and (BrainFuckInterpreter.State <> rsStopped);*)313 ABuild.Enabled := Assigned(Project) and Assigned(Compiler.Target) and314 Assigned(Compiler.Target.Producer);315 APause.Enabled := Assigned(Project) and Assigned(Compiler.Target) and316 Assigned(Compiler.Target.Executor) and (Compiler.Target.Executor.State = rsRunning);317 ARun.Enabled := Assigned(Project) and Assigned(Compiler.Target) and318 Assigned(Compiler.Target.Executor) and ((Compiler.Target.Executor.State = rsStopped) or319 (Compiler.Target.Executor.State = rsPaused));320 AStop.Enabled := Assigned(Project) and Assigned(Compiler.Target) and321 Assigned(Compiler.Target.Executor) and ((Compiler.Target.Executor.State = rsRunning) or322 (Compiler.Target.Executor.State = rsPaused));323 AStepIn.Enabled := Assigned(Project) and Assigned(Compiler.Target) and324 Assigned(Compiler.Target.Executor) and ((Compiler.Target.Executor.State = rsRunning) or325 (Compiler.Target.Executor.State = rsPaused));326 AStepOut.Enabled := AStepIn.Enabled;327 AStepOver.Enabled := AStepIn.Enabled;328 ARunToCursor.Enabled := AStepIn.Enabled;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; 329 342 end; 330 343 331 344 UpdateMenu; 332 Core.Co mpiler.Targets.LoadToStrings(ComboBoxTarget.Items);333 ComboBoxTarget.ItemIndex := Core.Co mpiler.Targets.IndexOf(Core.Compiler.Target);345 Core.Core.Compiler.Targets.LoadToStrings(ComboBoxTarget.Items); 346 ComboBoxTarget.ItemIndex := Core.Core.Compiler.Targets.IndexOf(Core.Core.Compiler.Target); 334 347 FormSourceCode.UpdateInterface; 335 348 FormTargetCode.UpdateInterface; … … 435 448 begin 436 449 with TMenuItem(Sender) do begin 437 Core.Co mpiler.Target := TTarget(Core.Compiler.Targets[MenuIndex]);450 Core.Core.Compiler.Target := TTarget(Core.Core.Compiler.Targets[MenuIndex]); 438 451 UpdateInterface; 439 452 end; … … 446 459 begin 447 460 MenuItemProducer.Clear; 448 with Core do461 with Core.Core do 449 462 for I := 0 to Compiler.Targets.Count - 1 do begin 450 463 NewMenuItem := TMenuItem.Create(MenuItemProducer); … … 461 474 Title: string; 462 475 begin 463 Title := Core. ApplicationInfo.AppName;464 if Assigned(Core. Project) then begin465 if Core. Project.FileName <> '' then Title :=Core.Project.FileName + ' - ' + Title;466 if Core. Project.Modified then Title := Title + ' *';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 + ' *'; 467 480 end; 468 481 Caption := Title; … … 474 487 end; 475 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 476 502 procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction); 477 503 begin 478 504 AProjectClose.Execute; 479 Core. SaveToRegistry(HKEY(Core.ApplicationInfo.RegistryRoot),Core.ApplicationInfo.RegistryKey);505 Core.Core.SaveToRegistry(HKEY(Core.Core.ApplicationInfo.RegistryRoot), Core.Core.ApplicationInfo.RegistryKey); 480 506 end; 481 507 … … 484 510 I: Integer; 485 511 begin 486 with Core.Compiler.Targets do 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 487 524 for I := 0 to Count - 1 do 488 525 with TTarget(Items[I]) do … … 498 535 begin 499 536 if Sender is TMenuItem then 500 Core. ProjectOpen(StringReplace(TMenuItem(Sender).Caption, '&', '', [rfReplaceAll]));537 Core.Core.ProjectOpen(StringReplace(TMenuItem(Sender).Caption, '&', '', [rfReplaceAll])); 501 538 end; 502 539 503 540 procedure TFormMain.FormShow(Sender: TObject); 504 541 begin 505 Core. LoadFromRegistry(HKEY(Core.ApplicationInfo.RegistryRoot),Core.ApplicationInfo.RegistryKey);542 Core.Core.LoadFromRegistry(HKEY(Core.Core.ApplicationInfo.RegistryRoot), Core.Core.ApplicationInfo.RegistryKey); 506 543 DockInit; 507 Core. ProjectTemplatesInit;508 509 if Core. ReopenLastOpenedFile and (Core.LastOpenedFiles.Items.Count > 0) then510 if FileExists(Core. LastOpenedFiles.Items[0]) then511 Core. ProjectOpen(Core.LastOpenedFiles.Items[0]);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]); 512 549 513 550 WindowState := wsMaximized; … … 517 554 procedure TFormMain.AProjectOpenExecute(Sender: TObject); 518 555 begin 519 if Core. LastOpenedFiles.Items.Count > 0 then520 OpenDialogProject.FileName := Core. LastOpenedFiles.Items[0]556 if Core.Core.LastOpenedFiles.Items.Count > 0 then 557 OpenDialogProject.FileName := Core.Core.LastOpenedFiles.Items[0] 521 558 else OpenDialogProject.FileName := ExtractFileDir(Application.ExeName); 522 559 if OpenDialogProject.Execute then begin 523 Core. ProjectOpen(OpenDialogProject.FileName);560 Core.Core.ProjectOpen(OpenDialogProject.FileName); 524 561 end; 525 562 end; … … 529 566 //if Project.Modified then ; A 530 567 FormSourceCode.ProjectFile := nil; 531 FreeAndNil(Core. Project);568 FreeAndNil(Core.Core.Project); 532 569 FormProject.UpdateProjectTree; 533 570 UpdateInterface; … … 540 577 541 578 procedure TFormMain.AAboutExecute(Sender: TObject); 542 begin 543 FormAbout.ShowModal; 579 var 580 FormAbout: TFormAbout; 581 begin 582 FormAbout := TFormAbout.Create(nil); 583 try 584 FormAbout.ShowModal; 585 finally 586 FormAbout.Free; 587 end; 544 588 end; 545 589 546 590 procedure TFormMain.AHomepageExecute(Sender: TObject); 547 591 begin 548 OpenWebPage(Core. ApplicationInfo.HomePage);592 OpenWebPage(Core.Core.ApplicationInfo.HomePage); 549 593 end; 550 594 551 595 procedure TFormMain.APauseExecute(Sender: TObject); 552 596 begin 553 Core.Co mpiler.Target.Executor.Pause;597 Core.Core.Compiler.Target.Executor.Pause; 554 598 end; 555 599 556 600 procedure TFormMain.AProjectNewExecute(Sender: TObject); 557 begin 601 var 602 FormProjectNew: TFormProjectNew; 603 begin 604 FormProjectNew := TFormProjectNew.Create(nil); 558 605 if FormProjectNew.ShowModal = mrOk then begin 559 606 if Assigned(FormProjectNew.ListView1.Selected) then begin 560 607 if TProjectTemplate(FormProjectNew.ListView1.Selected.Data).IsProject then 561 Core. ProjectNew;562 TProjectTemplate(FormProjectNew.ListView1.Selected.Data).InitProject(Core. Project);608 Core.Core.ProjectNew; 609 TProjectTemplate(FormProjectNew.ListView1.Selected.Data).InitProject(Core.Core.Project); 563 610 end; 564 611 end; 612 FormProjectNew.Free; 565 613 UpdateInterface; 566 614 end; … … 568 616 procedure TFormMain.AProjectSaveAsExecute(Sender: TObject); 569 617 begin 570 if Core. LastOpenedFiles.Items.Count > 0 then571 SaveDialogProject.FileName := Core. LastOpenedFiles.Items[0]618 if Core.Core.LastOpenedFiles.Items.Count > 0 then 619 SaveDialogProject.FileName := Core.Core.LastOpenedFiles.Items[0] 572 620 else SaveDialogProject.FileName := ExtractFileDir(Application.ExeName); 573 if Assigned(Core. Project) then621 if Assigned(Core.Core.Project) then 574 622 if SaveDialogProject.Execute then begin 575 Core. Project.SaveToFile(SaveDialogProject.FileName);623 Core.Core.Project.SaveToFile(SaveDialogProject.FileName); 576 624 FormSourceCode.Save; 577 Core. Project.Save;625 Core.Core.Project.Save; 578 626 UpdateInterface; 579 Core. LastOpenedFiles.AddItem(SaveDialogProject.FileName);627 Core.Core.LastOpenedFiles.AddItem(SaveDialogProject.FileName); 580 628 end; 581 629 end; … … 584 632 begin 585 633 FormSourceCode.Save; 586 if not FileExists(Core. Project.FileName) then AProjectSaveAs.Execute587 else Core. Project.SaveToFile(Core.Project.FileName);634 if not FileExists(Core.Core.Project.FileName) then AProjectSaveAs.Execute 635 else Core.Core.Project.SaveToFile(Core.Core.Project.FileName); 588 636 end; 589 637 … … 591 639 begin 592 640 with TMenuItem(Sender) do begin 593 Core.Co mpiler.Target := TTarget(Core.Compiler.Targets[ComboBoxTarget.ItemIndex]);641 Core.Core.Compiler.Target := TTarget(Core.Core.Compiler.Targets[ComboBoxTarget.ItemIndex]); 594 642 UpdateInterface; 595 643 end;
Note:
See TracChangeset
for help on using the changeset viewer.