Changeset 145 for trunk/Forms/FormMain.pas
- Timestamp:
- Jun 5, 2023, 6:44:57 PM (18 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/FormMain.pas
r144 r145 1 unit UFormMain;1 unit FormMain; 2 2 3 3 interface 4 4 5 5 uses 6 Classes, SysUtils, FileUtil, Forms, Controls, 7 Graphics, Dialogs, Menus, ActnList, ComCtrls, ExtCtrls, UTarget, Registry, 8 URegistry, LazFileUtils; 6 Classes, SysUtils, FileUtil, Forms, Controls, FormCPU, FormInput, 7 Graphics, Dialogs, Menus, ActnList, ComCtrls, ExtCtrls, Target, Registry, 8 LazFileUtils, FormOptions, FormMessages, FormTargets, 9 FormOutput, FormMemory, FormSourceCode, FormTargetCode, FormLog, 10 FormCompileMultiple; 9 11 10 12 type … … 144 146 procedure TimerRefreshTimer(Sender: TObject); 145 147 private 148 FormCPU: TFormCPU; 149 FormInput: TFormInput; 150 FormLog: TFormLog; 151 FormMemory: TFormMemory; 152 FormMessages: TFormMessages; 153 FormOutput: TFormOutput; 154 FormSourceCode: TFormSourceCode; 155 FormTargetCode: TFormTargetCode; 146 156 procedure AProjectOpenRecentExecute(Sender: TObject); 147 157 procedure MenuItemTargetClick(Sender: TObject); … … 151 161 procedure DockInit; 152 162 procedure LastOpenedListChange(Sender: TObject); 163 procedure CurrentTargetChangeExecute(Sender: TObject); 153 164 public 154 165 procedure MessagesChanged(Sender: TObject); 155 166 procedure TargetLogExecute(Lines: TStrings); 156 167 procedure TargetStateChanged(Sender: TObject); 157 procedure LoadFromRegistry(Context: TRegistryContext);158 procedure SaveToRegistry(Context: TRegistryContext);159 168 procedure UpdateInterface; 160 169 procedure UpdateStatusBar; … … 162 171 end; 163 172 164 var165 FormMain: TFormMain;166 167 173 168 174 implementation … … 171 177 172 178 uses 173 UCore, UFormCPU, UFormOptions, UFormMessages, UFormTargets, UFormOutput, UFormInput, 174 UFormMemory, UFormSourceCode, UFormTargetCode, UTargetInterpretter, UFormLog, 175 UBFTarget, UCommon, UFormCompileMultiple; 179 Core, TargetInterpretter, BFTarget, Common; 176 180 177 181 resourcestring … … 195 199 procedure TFormMain.FormShow(Sender: TObject); 196 200 begin 197 Core.Init; 198 LoadFromRegistry(Core.ApplicationInfo.GetRegistryContext); 201 Core.Core.Init; 199 202 PageControlMain.TabIndex := 0; 200 203 try 201 if Core. OpenProjectOnStart and (Core.LastOpenedList.Items.Count > 0) and202 FileExists(Core. LastOpenedList.Items[0]) then203 ProjectOpen(Core. LastOpenedList.Items[0])204 if Core.Core.OpenProjectOnStart and (Core.Core.LastOpenedList.Items.Count > 0) and 205 FileExists(Core.Core.LastOpenedList.Items[0]) then 206 ProjectOpen(Core.Core.LastOpenedList.Items[0]) 204 207 else AProjectNew.Execute; 205 208 finally … … 209 212 UpdateTargetList; 210 213 DockInit; 211 Core. PersistentForm1.Load(Self, True);212 Core. ThemeManager.UseTheme(Self);214 Core.Core.PersistentForm1.Load(Self, True); 215 Core.Core.ThemeManager.UseTheme(Self); 213 216 FormSourceCode.UpdateTheme; 214 217 end; 215 Core. Messages.OnChange := FormMain.MessagesChanged;218 Core.Core.Messages.OnChange := MessagesChanged; 216 219 end; 217 220 … … 232 235 begin 233 236 UpdateInterface; 234 if Core.C urrentTarget.State = rsPaused then237 if Core.Core.CurrentTarget.State = rsPaused then 235 238 AProgramShowExecutionPoint.Execute; 236 if Core.C urrentTarget.State = rsStopped then237 Core. Messages.AddMessage(SProgramStopped);239 if Core.Core.CurrentTarget.State = rsStopped then 240 Core.Core.Messages.AddMessage(SProgramStopped); 238 241 end; 239 242 … … 249 252 if Sender is TMenuItem then 250 253 with TMenuItem(Sender) do begin 251 Core.C urrentTarget := TTarget(Core.Targets[MenuIndex]);254 Core.Core.CurrentTarget := Core.Core.Targets[MenuIndex]; 252 255 Checked := True; 253 256 for I := 0 to Parent.Count - 1 do … … 258 261 procedure TFormMain.ProjectOpen(FileName: string); 259 262 begin 260 if Core.Project.Openned then 261 raise Exception.Create(SCloseProjectFirst); 262 FormSourceCode.SynEditSource.Lines.LoadFromFile(FileName); 263 Core.AddItemToLastOpenedList(FileName); 264 Core.Project.FileName := FileName; 265 Core.Project.Openned := True; 266 Core.CurrentTarget.Compiled := False; 263 with Core.Core do begin 264 if Project.Openned then 265 raise Exception.Create(SCloseProjectFirst); 266 FormSourceCode.SynEditSource.Lines.LoadFromFile(FileName); 267 AddItemToLastOpenedList(FileName); 268 Project.FileName := FileName; 269 Project.Openned := True; 270 CurrentTarget.Compiled := False; 271 end; 267 272 UpdateInterface; 268 273 end; … … 292 297 DockForm(FormMemory, PanelMemory); 293 298 DockForm(FormMessages, TabSheetMessages); 294 PageControlRight.Width := FormMain.Width div 3;295 PageControlBottom.Height := FormMain.Height div 5;299 PageControlRight.Width := Width div 3; 300 PageControlBottom.Height := Height div 5; 296 301 end; 297 302 298 303 procedure TFormMain.LastOpenedListChange(Sender: TObject); 299 304 begin 300 Core.LastOpenedList.LoadToMenuItem(MenuItemOpenRecent, AProjectOpenRecentExecute); 301 Core.LastOpenedList.LoadToMenuItem(PopupMenuRecentFiles.Items, AProjectOpenRecentExecute); 302 end; 303 304 procedure TFormMain.LoadFromRegistry(Context: TRegistryContext); 305 var 306 TargetName: string; 307 begin 308 with TRegistryEx.Create do 309 try 310 CurrentContext := Context; 311 TargetName := ReadStringWithDefault('TargetName', 'Interpretter'); 312 Core.CurrentTarget := Core.Targets.FindByName(TargetName); 313 if not Assigned(Core.CurrentTarget) then 314 Core.CurrentTarget := TTarget(Core.Targets[0]); 315 Core.Optimizations.AddSub := ReadBoolWithDefault('OptimizationAddSubEnabled', True); 316 Core.Optimizations.SetZero := ReadBoolWithDefault('OptimizationSetZeroEnabled', True); 317 Core.Optimizations.Merge := ReadBoolWithDefault('OptimizationMerge', True); 318 Core.Optimizations.CopyMultiply := ReadBoolWithDefault('OptimizationCopyMultiplyEnabled', True); 319 Core.Optimizations.RelativeIndexes := ReadBoolWithDefault('OptimizationRelativeIndexesEnabled', True); 320 finally 321 Free; 322 end; 323 end; 324 325 procedure TFormMain.SaveToRegistry(Context: TRegistryContext); 326 begin 327 with TRegistryEx.Create do 328 try 329 CurrentContext := Context; 330 WriteString('TargetName', Core.CurrentTarget.Name); 331 WriteBool('OptimizationAddSubEnabled', Core.Optimizations.AddSub); 332 WriteBool('OptimizationSetZeroEnabled', Core.Optimizations.SetZero); 333 WriteBool('OptimizationMerge', Core.Optimizations.Merge); 334 WriteBool('OptimizationCopyMultiplyEnabled', Core.Optimizations.CopyMultiply); 335 WriteBool('OptimizationRelativeIndexesEnabled', Core.Optimizations.RelativeIndexes); 336 finally 337 Free; 338 end; 305 Core.Core.LastOpenedList.LoadToMenuItem(MenuItemOpenRecent, AProjectOpenRecentExecute); 306 Core.Core.LastOpenedList.LoadToMenuItem(PopupMenuRecentFiles.Items, AProjectOpenRecentExecute); 307 end; 308 309 procedure TFormMain.CurrentTargetChangeExecute(Sender: TObject); 310 begin 311 UpdateTargetList; 312 UpdateInterface; 339 313 end; 340 314 … … 345 319 begin 346 320 Title := ''; 347 if Core.Project.FileName <> '' then Title := Core.Project.FileName; 348 if Core.Project.Modified then Title := Title + ' (' + SChanged + ')'; 349 Title:= Title + ' - ' + Core.ApplicationInfo.AppName; 350 Caption := Title; 351 AProjectSave.Enabled := Core.Project.Modified; 352 FormSourceCode.SynEditSource.Enabled := Core.Project.Openned; 353 AProjectClose.Enabled := Core.Project.Openned; 354 AProjectSaveAs.Enabled := Core.Project.Openned; 355 AProgramRun.Enabled := (tcRun in Core.CurrentTarget.Capabilities) and 356 Core.Project.Openned and (Core.CurrentTarget.State = rsStopped) or (Core.CurrentTarget.State = rsPaused); 357 AProgramPause.Enabled := (tcPause in Core.CurrentTarget.Capabilities) and 358 Core.Project.Openned and (Core.CurrentTarget.State = rsRunning); 359 AProgramStop.Enabled := (tcStop in Core.CurrentTarget.Capabilities) and 360 Core.Project.Openned and (Core.CurrentTarget.State <> rsStopped); 361 AProgramCompile.Enabled := (tcCompile in Core.CurrentTarget.Capabilities) and 362 Core.Project.Openned; 363 CanDebug := Core.DebugEnabled and Core.Project.Openned and 364 ((Core.CurrentTarget.State = rsPaused) or (Core.CurrentTarget.State = rsStopped)); 365 AProgramStepInto.Enabled := CanDebug and (tcStepInto in Core.CurrentTarget.Capabilities); 366 AProgramStepOut.Enabled := CanDebug and (tcStepOut in Core.CurrentTarget.Capabilities); 367 AProgramRunToCursor.Enabled := CanDebug and (tcRunToCursor in Core.CurrentTarget.Capabilities); 368 AProgramStepOver.Enabled := CanDebug and (tcStepOver in Core.CurrentTarget.Capabilities); 369 AProgramShowExecutionPoint.Enabled := CanDebug and (tcPause in Core.CurrentTarget.Capabilities); 370 AShowSourcePosition.Enabled := Core.CurrentTarget.Compiled; 371 AShowTargetPosition.Enabled := Core.CurrentTarget.Compiled; 321 with Core.Core do begin 322 if Project.FileName <> '' then Title := Project.FileName; 323 if Project.Modified then Title := Title + ' (' + SChanged + ')'; 324 Title:= Title + ' - ' + ApplicationInfo.AppName; 325 Caption := Title; 326 AProjectSave.Enabled := Project.Modified; 327 FormSourceCode.SynEditSource.Enabled := Project.Openned; 328 AProjectClose.Enabled := Project.Openned; 329 AProjectSaveAs.Enabled := Project.Openned; 330 AProgramRun.Enabled := (tcRun in CurrentTarget.Capabilities) and 331 Project.Openned and (CurrentTarget.State = rsStopped) or (CurrentTarget.State = rsPaused); 332 AProgramPause.Enabled := (tcPause in CurrentTarget.Capabilities) and 333 Project.Openned and (CurrentTarget.State = rsRunning); 334 AProgramStop.Enabled := (tcStop in CurrentTarget.Capabilities) and 335 Project.Openned and (CurrentTarget.State <> rsStopped); 336 AProgramCompile.Enabled := (tcCompile in CurrentTarget.Capabilities) and 337 Project.Openned; 338 CanDebug := DebugEnabled and Project.Openned and 339 ((CurrentTarget.State = rsPaused) or (CurrentTarget.State = rsStopped)); 340 AProgramStepInto.Enabled := CanDebug and (tcStepInto in CurrentTarget.Capabilities); 341 AProgramStepOut.Enabled := CanDebug and (tcStepOut in CurrentTarget.Capabilities); 342 AProgramRunToCursor.Enabled := CanDebug and (tcRunToCursor in CurrentTarget.Capabilities); 343 AProgramStepOver.Enabled := CanDebug and (tcStepOver in CurrentTarget.Capabilities); 344 AProgramShowExecutionPoint.Enabled := CanDebug and (tcPause in CurrentTarget.Capabilities); 345 AShowSourcePosition.Enabled := CurrentTarget.Compiled; 346 AShowTargetPosition.Enabled := CurrentTarget.Compiled; 347 end; 372 348 UpdateStatusBar; 373 349 end; … … 383 359 I: Integer; 384 360 begin 385 Core. Targets.LoadToMenuItem(MenuItemTarget, MenuItemTargetClick,Core.CurrentTarget);386 Core. Targets.LoadToMenuItem(PopupMenuTargets.Items, MenuItemTargetClick,Core.CurrentTarget);361 Core.Core.Targets.LoadToMenuItem(MenuItemTarget, MenuItemTargetClick, Core.Core.CurrentTarget); 362 Core.Core.Targets.LoadToMenuItem(PopupMenuTargets.Items, MenuItemTargetClick, Core.Core.CurrentTarget); 387 363 388 364 // Update toolbutton 389 I := Core. Targets.IndexOf(Core.CurrentTarget);365 I := Core.Core.Targets.IndexOf(Core.Core.CurrentTarget); 390 366 if I <> -1 then 391 with TTarget(Core. Targets[I]) do begin367 with TTarget(Core.Core.Targets[I]) do begin 392 368 ToolButtonTarget.ImageIndex := ImageIndex; 393 369 ToolButtonTarget.Caption := Name; … … 398 374 procedure TFormMain.FormCreate(Sender: TObject); 399 375 begin 376 Core.Core.Translator.TranslateComponentRecursive(Self); 377 Core.Core.ThemeManager.UseTheme(Self); 378 379 FormSourceCode := TFormSourceCode.Create(nil); 380 FormCPU := TFormCPU.Create(nil); 381 FormInput := TFormInput.Create(nil); 382 FormLog := TFormLog.Create(nil); 383 FormMemory := TFormMemory.Create(nil); 384 FormMessages := TFormMessages.Create(nil); 385 FormOutput := TFormOutput.Create(nil); 386 FormTargetCode := TFormTargetCode.Create(nil); 387 400 388 UpdateTargetList; 401 Core.LastOpenedList.OnChange := LastOpenedListChange; 389 with Core.Core do begin 390 LastOpenedList.OnChange := LastOpenedListChange; 391 OnCurrentTargetChange := CurrentTargetChangeExecute; 392 OnTargetChangeState := TargetStateChanged; 393 OnTargetLog := TargetLogExecute; 394 end; 402 395 end; 403 396 404 397 procedure TFormMain.FormDestroy(Sender: TObject); 405 398 begin 406 SaveToRegistry(Core.ApplicationInfo.GetRegistryContext); 399 FreeAndNil(FormSourceCode); 400 FreeAndNil(FormCPU); 401 FreeAndNil(FormInput); 402 FreeAndNil(FormLog); 403 FreeAndNil(FormMemory); 404 FreeAndNil(FormMessages); 405 FreeAndNil(FormOutput); 406 FreeAndNil(FormTargetCode); 407 407 end; 408 408 409 409 procedure TFormMain.AProgramRunExecute(Sender: TObject); 410 410 begin 411 if Core.C urrentTarget is TTargetInterpretter then412 TTargetInterpretter(Core.C urrentTarget).Input := FormInput.MemoInput.Lines.Text;413 if not Core.C urrentTarget.Compiled then AProgramCompile.Execute;414 Core.C urrentTarget.Run;415 Core. Messages.AddMessage(SProgramStarted);411 if Core.Core.CurrentTarget is TTargetInterpretter then 412 TTargetInterpretter(Core.Core.CurrentTarget).Input := FormInput.MemoInput.Lines.Text; 413 if not Core.Core.CurrentTarget.Compiled then AProgramCompile.Execute; 414 Core.Core.CurrentTarget.Run; 415 Core.Core.Messages.AddMessage(SProgramStarted); 416 416 end; 417 417 … … 420 420 DebugStep: TDebugStep; 421 421 begin 422 DebugStep := Core.C urrentTarget.DebugSteps.SearchByTargetPos(FormTargetCode.SynEditTarget.SelStart - 1);422 DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchByTargetPos(FormTargetCode.SynEditTarget.SelStart - 1); 423 423 if Assigned(DebugStep) then begin 424 424 FormSourceCode.SynEditSource.SelStart := DebugStep.SourcePosition + 1; … … 431 431 DebugStep: TDebugStep; 432 432 begin 433 DebugStep := Core.C urrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);433 DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1); 434 434 if Assigned(DebugStep) then begin 435 435 FormTargetCode.SynEditTarget.SelStart := DebugStep.TargetPosition + 1; … … 461 461 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); 462 462 begin 463 Core.PersistentForm1.Save(Self); 463 Core.Core.PersistentForm1.Save(Self); 464 Application.Terminate; 464 465 end; 465 466 466 467 procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: boolean); 467 468 begin 468 if Core. Project.Modified then begin469 if Core.Core.Project.Modified then begin 469 470 AProjectClose.Execute; 470 if Core. Project.Openned then CanClose := False;471 if Core.Core.Project.Openned then CanClose := False; 471 472 end; 472 473 end; … … 478 479 479 480 procedure TFormMain.AOptionsExecute(Sender: TObject); 481 var 482 FormOptions: TFormOptions; 480 483 begin 481 484 FormOptions := TFormOptions.Create(nil); … … 484 487 if FormOptions.ShowModal = mrOK then begin 485 488 FormOptions.Save; 486 if Assigned(Core.C urrentTarget) then begin487 Core.C urrentTarget.OptimizationLevel :=Core.OptimizationLevel;488 if Core.C urrentTarget is TBFTarget then begin489 TBFTarget(Core.C urrentTarget).CellSize :=Core.CellSize;490 TBFTarget(Core.C urrentTarget).MemorySize :=Core.MemorySize;489 if Assigned(Core.Core.CurrentTarget) then begin 490 Core.Core.CurrentTarget.OptimizationLevel := Core.Core.OptimizationLevel; 491 if Core.Core.CurrentTarget is TBFTarget then begin 492 TBFTarget(Core.Core.CurrentTarget).CellSize := Core.Core.CellSize; 493 TBFTarget(Core.Core.CurrentTarget).MemorySize := Core.Core.MemorySize; 491 494 end; 492 495 end; 493 Core. ThemeManager.UseTheme(Self);496 Core.Core.ThemeManager.UseTheme(Self); 494 497 FormSourceCode.UpdateTheme; 495 Core.SaveToRegistry(Core.ApplicationInfo.GetRegistryContext); 496 SaveToRegistry(Core.ApplicationInfo.GetRegistryContext); 498 Core.Core.SaveToRegistry(Core.Core.ApplicationInfo.GetRegistryContext); 497 499 end; 498 500 finally … … 503 505 procedure TFormMain.AProgramCompileExecute(Sender: TObject); 504 506 begin 505 with Core.C urrentTarget do507 with Core.Core, CurrentTarget do 506 508 try 507 Core.Messages.Clear;509 Messages.Clear; 508 510 AProgramStop.Execute; 509 511 SourceCode := FormSourceCode.SynEditSource.Text; 510 ProjectFileName := Core.Project.FileName;511 ProgramName := ExtractFileNameOnly( Core.Project.FileName);512 if C ore.CurrentTarget is TBFTarget then513 TBFTarget(C ore.CurrentTarget).Optimizations := Core.Optimizations;514 DebugEnabled := Core.DebugEnabled;515 Core.Messages.AddMessage(SCompileStart);512 ProjectFileName := Project.FileName; 513 ProgramName := ExtractFileNameOnly(Project.FileName); 514 if CurrentTarget is TBFTarget then 515 TBFTarget(CurrentTarget).Optimizations := Optimizations; 516 DebugEnabled := DebugEnabled; 517 Messages.AddMessage(SCompileStart); 516 518 Application.ProcessMessages; 517 519 Compile; 518 Core.Messages.AppendMessage(SDone);520 Messages.AppendMessage(SDone); 519 521 FormTargetCode.SynEditTarget.Text := TargetCode; 520 FormTargetCode.SetHighlighter(C ore.CurrentTarget.SourceExtension);522 FormTargetCode.SetHighlighter(CurrentTarget.SourceExtension); 521 523 UpdateInterface; 522 524 except … … 533 535 with TFormCompileMultiple.Create(nil) do 534 536 try 535 Targets := Core. Targets;537 Targets := Core.Core.Targets; 536 538 if ShowModal = mrOk then begin 537 Core. Messages.Clear;539 Core.Core.Messages.Clear; 538 540 for I := 0 to Targets.Count - 1 do 539 541 with Targets[I] do … … 542 544 AProgramStop.Execute; 543 545 SourceCode := FormSourceCode.SynEditSource.Text; 544 ProjectFileName := Core. Project.FileName;545 ProgramName := ExtractFileNameOnly(Core. Project.FileName);546 ProjectFileName := Core.Core.Project.FileName; 547 ProgramName := ExtractFileNameOnly(Core.Core.Project.FileName); 546 548 if Targets[I] is TBFTarget then 547 TBFTarget(Targets[I]).Optimizations := Core. Optimizations;548 DebugEnabled := Core. DebugEnabled;549 Core. Messages.AddMessage(Name + ' ' + SCompileStart);549 TBFTarget(Targets[I]).Optimizations := Core.Core.Optimizations; 550 DebugEnabled := Core.Core.DebugEnabled; 551 Core.Core.Messages.AddMessage(Name + ' ' + SCompileStart); 550 552 Application.ProcessMessages; 551 553 Compile; 552 Core. Messages.AppendMessage(SDone);554 Core.Core.Messages.AppendMessage(SDone); 553 555 FormTargetCode.SynEditTarget.Text := TargetCode; 554 FormTargetCode.SetHighlighter(Core.C urrentTarget.SourceExtension);556 FormTargetCode.SetHighlighter(Core.Core.CurrentTarget.SourceExtension); 555 557 UpdateInterface; 556 558 except … … 569 571 BreakPoint: TBreakPoint; 570 572 begin 571 DebugStep := Core.C urrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);573 DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1); 572 574 if Assigned(DebugStep) then begin 573 BreakPoint := Core.C urrentTarget.BreakPoints.SearchByTargetPos(DebugStep.ProgramPosition);575 BreakPoint := Core.Core.CurrentTarget.BreakPoints.SearchByTargetPos(DebugStep.ProgramPosition); 574 576 if Assigned(BreakPoint) then 575 Core.C urrentTarget.BreakPoints.Delete(Core.CurrentTarget.BreakPoints.IndexOf(BreakPoint))576 else Core.C urrentTarget.BreakPoints.AddItem(DebugStep.ProgramPosition);577 Core.Core.CurrentTarget.BreakPoints.Delete(Core.Core.CurrentTarget.BreakPoints.IndexOf(BreakPoint)) 578 else Core.Core.CurrentTarget.BreakPoints.AddItem(DebugStep.ProgramPosition); 577 579 end; 578 580 end; … … 580 582 procedure TFormMain.AAboutExecute(Sender: TObject); 581 583 begin 582 Core. AboutDialog.Show;584 Core.Core.AboutDialog.Show; 583 585 end; 584 586 585 587 procedure TFormMain.AProgramPauseExecute(Sender: TObject); 586 588 begin 587 Core.C urrentTarget.Pause;589 Core.Core.CurrentTarget.Pause; 588 590 end; 589 591 … … 592 594 DebugStep: TDebugStep; 593 595 begin 594 if Core.C urrentTarget.State = rsStopped then begin595 if not Core.C urrentTarget.Compiled then AProgramCompile.Execute;596 DebugStep := Core.C urrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);597 Core.C urrentTarget.BreakPoints.SetSystem(DebugStep.ProgramPosition);596 if Core.Core.CurrentTarget.State = rsStopped then begin 597 if not Core.Core.CurrentTarget.Compiled then AProgramCompile.Execute; 598 DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1); 599 Core.Core.CurrentTarget.BreakPoints.SetSystem(DebugStep.ProgramPosition); 598 600 AProgramRun.Execute; 599 601 end else begin 600 DebugStep := Core.C urrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);601 Core.C urrentTarget.RunToCursor(DebugStep.ProgramPosition);602 DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1); 603 Core.Core.CurrentTarget.RunToCursor(DebugStep.ProgramPosition); 602 604 end; 603 605 end; … … 607 609 DebugStep: TDebugStep; 608 610 begin 609 DebugStep := Core.CurrentTarget.DebugSteps.SearchByProgramPos(Core.CurrentTarget.ExecutionPosition); 611 DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchByProgramPos( 612 Core.Core.CurrentTarget.ExecutionPosition); 610 613 FormSourceCode.SynEditSource.SelStart := DebugStep.SourcePosition + 1; 611 614 FormTargetCode.SynEditTarget.SelStart := DebugStep.TargetPosition + 1; … … 616 619 procedure TFormMain.AProgramStepIntoExecute(Sender: TObject); 617 620 begin 618 if Core.CurrentTarget.State = rsStopped then begin 619 if not Core.CurrentTarget.Compiled then AProgramCompile.Execute; 620 Core.CurrentTarget.BreakPoints.SetSystem(Core.CurrentTarget.DebugSteps.First.ProgramPosition); 621 if Core.Core.CurrentTarget.State = rsStopped then begin 622 if not Core.Core.CurrentTarget.Compiled then AProgramCompile.Execute; 623 Core.Core.CurrentTarget.BreakPoints.SetSystem( 624 Core.Core.CurrentTarget.DebugSteps.First.ProgramPosition); 621 625 AProgramRun.Execute; 622 end else Core.C urrentTarget.StepInto;626 end else Core.Core.CurrentTarget.StepInto; 623 627 end; 624 628 625 629 procedure TFormMain.AProgramStepOutExecute(Sender: TObject); 626 630 begin 627 Core.C urrentTarget.StepOut;631 Core.Core.CurrentTarget.StepOut; 628 632 end; 629 633 630 634 procedure TFormMain.AProgramStepOverExecute(Sender: TObject); 631 635 begin 632 if Core.CurrentTarget.State = rsStopped then begin 633 if not Core.CurrentTarget.Compiled then AProgramCompile.Execute; 634 Core.CurrentTarget.BreakPoints.SetSystem(TDebugStep(Core.CurrentTarget.DebugSteps.First).ProgramPosition); 636 if Core.Core.CurrentTarget.State = rsStopped then begin 637 if not Core.Core.CurrentTarget.Compiled then AProgramCompile.Execute; 638 Core.Core.CurrentTarget.BreakPoints.SetSystem( 639 TDebugStep(Core.Core.CurrentTarget.DebugSteps.First).ProgramPosition); 635 640 AProgramRun.Execute; 636 end else Core.C urrentTarget.StepOver;641 end else Core.Core.CurrentTarget.StepOver; 637 642 end; 638 643 639 644 procedure TFormMain.AProgramStopExecute(Sender: TObject); 640 645 begin 641 Core.C urrentTarget.Stop;646 Core.Core.CurrentTarget.Stop; 642 647 end; 643 648 … … 647 652 begin 648 653 DialogResult := mrNo; 649 if Core. Project.Modified then begin654 if Core.Core.Project.Modified then begin 650 655 DialogResult := MessageDlg(SUnsavedChanges, SDoYouWantToSaveProject, mtConfirmation, [mbYes, mbNo, mbCancel], 0); 651 656 if DialogResult = mrYes then begin … … 655 660 if (DialogResult = mrNo) or (DialogResult = mrYes) then begin 656 661 AProgramStop.Execute; 657 Core. Project.Openned := False;662 Core.Core.Project.Openned := False; 658 663 FormSourceCode.SynEditSource.Clear; 659 664 UpdateInterface; … … 664 669 begin 665 670 AProjectClose.Execute; 666 if Core. Project.Openned then Exit;667 Core. Project.FileName := CombinePaths(Core.DataDir, ExamplesDir + DirectorySeparator + SNewProject + '.b');671 if Core.Core.Project.Openned then Exit; 672 Core.Core.Project.FileName := CombinePaths(Core.Core.DataDir, ExamplesDir + DirectorySeparator + SNewProject + '.b'); 668 673 FormSourceCode.SynEditSource.Clear; 669 Core. Project.Openned := True;670 Core.C urrentTarget.Compiled := False;674 Core.Core.Project.Openned := True; 675 Core.Core.CurrentTarget.Compiled := False; 671 676 UpdateInterface; 672 677 end; … … 676 681 FileName: string; 677 682 begin 678 FileName := Core. LastOpenedList.Items[TMenuItem(Sender).MenuIndex];683 FileName := Core.Core.LastOpenedList.Items[TMenuItem(Sender).MenuIndex]; 679 684 if FileExists(FileName) then begin 680 685 AProjectClose.Execute; 681 if Core. Project.Openned then Exit;686 if Core.Core.Project.Openned then Exit; 682 687 ProjectOpen(FileName); 683 688 end else ShowMessage(Format(SFileNotFound, [FileName])); … … 688 693 FileName: string; 689 694 begin 690 if Core. LastOpenedList.Items.Count > 0 then691 FileName := Core. LastOpenedList.Items[0]692 else FileName := CombinePaths(Core. DataDir, ExamplesDir);695 if Core.Core.LastOpenedList.Items.Count > 0 then 696 FileName := Core.Core.LastOpenedList.Items[0] 697 else FileName := CombinePaths(Core.Core.DataDir, ExamplesDir); 693 698 OpenDialog1.InitialDir := ExtractFileDir(FileName); 694 699 OpenDialog1.FileName := ExtractFileName(FileName); 695 700 if OpenDialog1.Execute then begin 696 701 AProjectClose.Execute; 697 if Core. Project.Openned then Exit;702 if Core.Core.Project.Openned then Exit; 698 703 ProjectOpen(OpenDialog1.FileName); 699 704 end; … … 702 707 procedure TFormMain.AProjectSaveAsExecute(Sender: TObject); 703 708 begin 704 SaveDialog1.InitialDir := ExtractFileDir(Core. Project.FileName);705 SaveDialog1.FileName := ExtractFileName(Core. Project.FileName);709 SaveDialog1.InitialDir := ExtractFileDir(Core.Core.Project.FileName); 710 SaveDialog1.FileName := ExtractFileName(Core.Core.Project.FileName); 706 711 if SaveDialog1.Execute then begin 707 712 FormSourceCode.SynEditSource.Lines.SaveToFile(SaveDialog1.FileName); 708 Core. Project.FileName := SaveDialog1.FileName;709 Core. AddItemToLastOpenedList(SaveDialog1.FileName);710 Core. Project.Modified := False;713 Core.Core.Project.FileName := SaveDialog1.FileName; 714 Core.Core.AddItemToLastOpenedList(SaveDialog1.FileName); 715 Core.Core.Project.Modified := False; 711 716 UpdateInterface; 712 717 end; … … 715 720 procedure TFormMain.AProjectSaveExecute(Sender: TObject); 716 721 begin 717 if Core. Project.Modified and FileExists(Core.Project.FileName) then begin718 FormSourceCode.SynEditSource.Lines.SaveToFile(Core. Project.FileName);719 Core. AddItemToLastOpenedList(Core.Project.FileName);720 Core. Project.Modified := False;722 if Core.Core.Project.Modified and FileExists(Core.Core.Project.FileName) then begin 723 FormSourceCode.SynEditSource.Lines.SaveToFile(Core.Core.Project.FileName); 724 Core.Core.AddItemToLastOpenedList(Core.Core.Project.FileName); 725 Core.Core.Project.Modified := False; 721 726 UpdateInterface; 722 727 end else AProjectSaveAs.Execute;
Note:
See TracChangeset
for help on using the changeset viewer.