| 1 | unit FormMain;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, FileUtil, Forms, Controls, FormCPU, FormInput,
|
|---|
| 7 | Graphics, Dialogs, Menus, ActnList, ComCtrls, ExtCtrls, Target,
|
|---|
| 8 | LazFileUtils, FormOptions, FormMessages, FormTargets, FormCompileMultiple,
|
|---|
| 9 | FormOutput, FormMemory, FormSourceCode, FormTargetCode, FormLog, FormEx,
|
|---|
| 10 | FormKeyShortcuts;
|
|---|
| 11 |
|
|---|
| 12 | type
|
|---|
| 13 |
|
|---|
| 14 | { TFormMain }
|
|---|
| 15 |
|
|---|
| 16 | TFormMain = class(TFormEx)
|
|---|
| 17 | AKeyShortcuts: TAction;
|
|---|
| 18 | AFullScreen: TAction;
|
|---|
| 19 | AProgramCompileMultiple: TAction;
|
|---|
| 20 | AViewLog: TAction;
|
|---|
| 21 | AProgramShowExecutionPoint: TAction;
|
|---|
| 22 | AShowSourcePosition: TAction;
|
|---|
| 23 | AShowTargetPosition: TAction;
|
|---|
| 24 | AProgramCompile: TAction;
|
|---|
| 25 | AAbout: TAction;
|
|---|
| 26 | ABreakpointToggle: TAction;
|
|---|
| 27 | AViewCompilers: TAction;
|
|---|
| 28 | AOptions: TAction;
|
|---|
| 29 | AProgramStepOut: TAction;
|
|---|
| 30 | AProgramRunToCursor: TAction;
|
|---|
| 31 | AProgramStepOver: TAction;
|
|---|
| 32 | AProgramStepInto: TAction;
|
|---|
| 33 | AProgramPause: TAction;
|
|---|
| 34 | AProgramStop: TAction;
|
|---|
| 35 | AHelp: TAction;
|
|---|
| 36 | AProgramRun: TAction;
|
|---|
| 37 | AProjectNew: TAction;
|
|---|
| 38 | AExit: TAction;
|
|---|
| 39 | AProjectSaveAs: TAction;
|
|---|
| 40 | AProjectClose: TAction;
|
|---|
| 41 | AProjectSave: TAction;
|
|---|
| 42 | AProjectOpen: TAction;
|
|---|
| 43 | ActionList1: TActionList;
|
|---|
| 44 | MainMenu1: TMainMenu;
|
|---|
| 45 | MenuItem1: TMenuItem;
|
|---|
| 46 | MenuItem10: TMenuItem;
|
|---|
| 47 | MenuItem11: TMenuItem;
|
|---|
| 48 | MenuItem12: TMenuItem;
|
|---|
| 49 | MenuItem13: TMenuItem;
|
|---|
| 50 | MenuItem14: TMenuItem;
|
|---|
| 51 | MenuItem15: TMenuItem;
|
|---|
| 52 | MenuItem16: TMenuItem;
|
|---|
| 53 | MenuItem17: TMenuItem;
|
|---|
| 54 | MenuItem18: TMenuItem;
|
|---|
| 55 | MenuItem19: TMenuItem;
|
|---|
| 56 | MenuItem2: TMenuItem;
|
|---|
| 57 | MenuItem20: TMenuItem;
|
|---|
| 58 | MenuItem21: TMenuItem;
|
|---|
| 59 | MenuItem22: TMenuItem;
|
|---|
| 60 | MenuItem23: TMenuItem;
|
|---|
| 61 | MenuItem24: TMenuItem;
|
|---|
| 62 | MenuItem25: TMenuItem;
|
|---|
| 63 | MenuItem26: TMenuItem;
|
|---|
| 64 | MenuItem27: TMenuItem;
|
|---|
| 65 | MenuItem28: TMenuItem;
|
|---|
| 66 | MenuItem29: TMenuItem;
|
|---|
| 67 | MenuItem30: TMenuItem;
|
|---|
| 68 | MenuItem31: TMenuItem;
|
|---|
| 69 | MenuItem32: TMenuItem;
|
|---|
| 70 | MenuItem33: TMenuItem;
|
|---|
| 71 | MenuItem34: TMenuItem;
|
|---|
| 72 | MenuItem35: TMenuItem;
|
|---|
| 73 | MenuItemViewToolbar: TMenuItem;
|
|---|
| 74 | MenuItemOpenRecent: TMenuItem;
|
|---|
| 75 | MenuItemTarget: TMenuItem;
|
|---|
| 76 | MenuItem3: TMenuItem;
|
|---|
| 77 | MenuItem4: TMenuItem;
|
|---|
| 78 | MenuItem5: TMenuItem;
|
|---|
| 79 | MenuItem6: TMenuItem;
|
|---|
| 80 | MenuItem7: TMenuItem;
|
|---|
| 81 | MenuItem8: TMenuItem;
|
|---|
| 82 | MenuItem9: TMenuItem;
|
|---|
| 83 | OpenDialog1: TOpenDialog;
|
|---|
| 84 | PageControlMain: TPageControl;
|
|---|
| 85 | PageControlRight: TPageControl;
|
|---|
| 86 | PageControlBottom: TPageControl;
|
|---|
| 87 | PanelLeft: TPanel;
|
|---|
| 88 | PanelMemory: TPanel;
|
|---|
| 89 | PanelCPU: TPanel;
|
|---|
| 90 | PanelOutput: TPanel;
|
|---|
| 91 | PanelInput: TPanel;
|
|---|
| 92 | PopupMenuTargets: TPopupMenu;
|
|---|
| 93 | PopupMenuRecentFiles: TPopupMenu;
|
|---|
| 94 | SaveDialog1: TSaveDialog;
|
|---|
| 95 | Splitter1: TSplitter;
|
|---|
| 96 | Splitter2: TSplitter;
|
|---|
| 97 | Splitter3: TSplitter;
|
|---|
| 98 | Splitter4: TSplitter;
|
|---|
| 99 | Splitter5: TSplitter;
|
|---|
| 100 | StatusBarMain: TStatusBar;
|
|---|
| 101 | TabSheetMessages: TTabSheet;
|
|---|
| 102 | TabSheetDebug: TTabSheet;
|
|---|
| 103 | TabSheetSource: TTabSheet;
|
|---|
| 104 | TabSheetTarget: TTabSheet;
|
|---|
| 105 | TimerRefresh: TTimer;
|
|---|
| 106 | ToolBarMain: TToolBar;
|
|---|
| 107 | ToolButton1: TToolButton;
|
|---|
| 108 | ToolButton10: TToolButton;
|
|---|
| 109 | ToolButton11: TToolButton;
|
|---|
| 110 | ToolButton12: TToolButton;
|
|---|
| 111 | ToolButton13: TToolButton;
|
|---|
| 112 | ToolButton14: TToolButton;
|
|---|
| 113 | ToolButton15: TToolButton;
|
|---|
| 114 | ToolButtonTarget: TToolButton;
|
|---|
| 115 | ToolButton2: TToolButton;
|
|---|
| 116 | ToolButton3: TToolButton;
|
|---|
| 117 | ToolButton4: TToolButton;
|
|---|
| 118 | ToolButton5: TToolButton;
|
|---|
| 119 | ToolButton6: TToolButton;
|
|---|
| 120 | ToolButton7: TToolButton;
|
|---|
| 121 | ToolButton8: TToolButton;
|
|---|
| 122 | ToolButton9: TToolButton;
|
|---|
| 123 | procedure AAboutExecute(Sender: TObject);
|
|---|
| 124 | procedure ABreakpointToggleExecute(Sender: TObject);
|
|---|
| 125 | procedure AExitExecute(Sender: TObject);
|
|---|
| 126 | procedure AFullScreenExecute(Sender: TObject);
|
|---|
| 127 | procedure AHelpExecute(Sender: TObject);
|
|---|
| 128 | procedure AKeyShortcutsExecute(Sender: TObject);
|
|---|
| 129 | procedure AOptionsExecute(Sender: TObject);
|
|---|
| 130 | procedure AProgramCompileExecute(Sender: TObject);
|
|---|
| 131 | procedure AProgramCompileMultipleExecute(Sender: TObject);
|
|---|
| 132 | procedure AProgramPauseExecute(Sender: TObject);
|
|---|
| 133 | procedure AProgramRunToCursorExecute(Sender: TObject);
|
|---|
| 134 | procedure AProgramRunExecute(Sender: TObject);
|
|---|
| 135 | procedure AProgramShowExecutionPointExecute(Sender: TObject);
|
|---|
| 136 | procedure AProgramStepIntoExecute(Sender: TObject);
|
|---|
| 137 | procedure AProgramStepOutExecute(Sender: TObject);
|
|---|
| 138 | procedure AProgramStepOverExecute(Sender: TObject);
|
|---|
| 139 | procedure AProgramStopExecute(Sender: TObject);
|
|---|
| 140 | procedure AProjectCloseExecute(Sender: TObject);
|
|---|
| 141 | procedure AProjectNewExecute(Sender: TObject);
|
|---|
| 142 | procedure AProjectOpenExecute(Sender: TObject);
|
|---|
| 143 | procedure AProjectSaveAsExecute(Sender: TObject);
|
|---|
| 144 | procedure AProjectSaveExecute(Sender: TObject);
|
|---|
| 145 | procedure AShowSourcePositionExecute(Sender: TObject);
|
|---|
| 146 | procedure AShowTargetPositionExecute(Sender: TObject);
|
|---|
| 147 | procedure AViewCompilersExecute(Sender: TObject);
|
|---|
| 148 | procedure AViewInterpreterExecute(Sender: TObject);
|
|---|
| 149 | procedure AViewLogExecute(Sender: TObject);
|
|---|
| 150 | procedure FormActivate(Sender: TObject);
|
|---|
| 151 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|---|
| 152 | procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
|---|
| 153 | procedure FormCreate(Sender: TObject);
|
|---|
| 154 | procedure FormDestroy(Sender: TObject);
|
|---|
| 155 | procedure FormShow(Sender: TObject);
|
|---|
| 156 | procedure MenuItemViewToolbarClick(Sender: TObject);
|
|---|
| 157 | procedure TimerRefreshTimer(Sender: TObject);
|
|---|
| 158 | private
|
|---|
| 159 | FormCPU: TFormCPU;
|
|---|
| 160 | FormInput: TFormInput;
|
|---|
| 161 | FormLog: TFormLog;
|
|---|
| 162 | FormMemory: TFormMemory;
|
|---|
| 163 | FormMessages: TFormMessages;
|
|---|
| 164 | FormOutput: TFormOutput;
|
|---|
| 165 | FormSourceCode: TFormSourceCode;
|
|---|
| 166 | FormTargetCode: TFormTargetCode;
|
|---|
| 167 | FormKeyShortcuts: TFormKeyShortcuts;
|
|---|
| 168 | procedure AProjectOpenRecentExecute(Sender: TObject);
|
|---|
| 169 | procedure MenuItemTargetClick(Sender: TObject);
|
|---|
| 170 | procedure ProjectOpen(FileName: string);
|
|---|
| 171 | procedure UpdateToolBarHints;
|
|---|
| 172 | procedure DockForm(Form: TForm; DockSite: TWinControl);
|
|---|
| 173 | procedure DockInit;
|
|---|
| 174 | procedure LastOpenedListChange(Sender: TObject);
|
|---|
| 175 | procedure CurrentTargetChangeExecute(Sender: TObject);
|
|---|
| 176 | procedure UpdateStatusBarExecute(Sender: TObject);
|
|---|
| 177 | procedure UpdateInterfaceExecute(Sender: TObject);
|
|---|
| 178 | public
|
|---|
| 179 | procedure MessagesChanged(Sender: TObject);
|
|---|
| 180 | procedure TargetLogExecute(Lines: TStrings);
|
|---|
| 181 | procedure TargetStateChanged(Sender: TObject);
|
|---|
| 182 | procedure UpdateInterface;
|
|---|
| 183 | procedure UpdateStatusBar;
|
|---|
| 184 | procedure UpdateTargetList;
|
|---|
| 185 | end;
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 | implementation
|
|---|
| 189 |
|
|---|
| 190 | {$R *.lfm}
|
|---|
| 191 |
|
|---|
| 192 | uses
|
|---|
| 193 | Core, TargetInterpreter, BFTarget, Common, FormAbout, FormHelp;
|
|---|
| 194 |
|
|---|
| 195 | resourcestring
|
|---|
| 196 | SProgramStarted = 'Program started';
|
|---|
| 197 | SProgramStopped = 'Program stopped';
|
|---|
| 198 | SNewProject = 'New project';
|
|---|
| 199 | SCompileStart = 'Compiling...';
|
|---|
| 200 | SDone = 'Done';
|
|---|
| 201 | SChanged = 'Changed';
|
|---|
| 202 | SUnsavedChanges = 'Unsaved changes';
|
|---|
| 203 | SDoYouWantToSaveProject = 'There are unsaved changes in project. Do you want to save them?';
|
|---|
| 204 | SCloseProjectFirst = 'Project need to be closed before it can be openned';
|
|---|
| 205 | SError = 'Error';
|
|---|
| 206 | SFileNotFound = 'File %s not found.';
|
|---|
| 207 |
|
|---|
| 208 | { TFormMain }
|
|---|
| 209 |
|
|---|
| 210 | procedure TFormMain.FormShow(Sender: TObject);
|
|---|
| 211 | begin
|
|---|
| 212 | Core.Core.Init;
|
|---|
| 213 | PageControlMain.TabIndex := 0;
|
|---|
| 214 | try
|
|---|
| 215 | if Core.Core.LastOpenedList.Items.Count = 0 then
|
|---|
| 216 | Core.Core.LastOpenedList.Items.Add(Core.Core.ExamplesDir +
|
|---|
| 217 | DirectorySeparator + 'Sierpinski.b');
|
|---|
| 218 |
|
|---|
| 219 | if Core.Core.OpenProjectOnStart and (Core.Core.LastOpenedList.Items.Count > 0) and
|
|---|
| 220 | FileExists(Core.Core.LastOpenedList.Items[0]) then
|
|---|
| 221 | ProjectOpen(Core.Core.LastOpenedList.Items[0])
|
|---|
| 222 | else AProjectNew.Execute;
|
|---|
| 223 | finally
|
|---|
| 224 | LastOpenedListChange(nil);
|
|---|
| 225 | UpdateInterface;
|
|---|
| 226 | UpdateToolBarHints;
|
|---|
| 227 | UpdateTargetList;
|
|---|
| 228 | DockInit;
|
|---|
| 229 | FormSourceCode.UpdateTheme;
|
|---|
| 230 | end;
|
|---|
| 231 | Core.Core.Messages.OnChange := MessagesChanged;
|
|---|
| 232 | end;
|
|---|
| 233 |
|
|---|
| 234 | procedure TFormMain.MenuItemViewToolbarClick(Sender: TObject);
|
|---|
| 235 | begin
|
|---|
| 236 | Core.Core.ShowToolbar := MenuItemViewToolbar.Checked;
|
|---|
| 237 | UpdateInterface;
|
|---|
| 238 | end;
|
|---|
| 239 |
|
|---|
| 240 | procedure TFormMain.TimerRefreshTimer(Sender: TObject);
|
|---|
| 241 | begin
|
|---|
| 242 | FormCPU.Reload;
|
|---|
| 243 | FormOutput.Reload;
|
|---|
| 244 | FormMemory.Reload;
|
|---|
| 245 | end;
|
|---|
| 246 |
|
|---|
| 247 | procedure TFormMain.TargetLogExecute(Lines: TStrings);
|
|---|
| 248 | begin
|
|---|
| 249 | if Assigned(FormLog) then
|
|---|
| 250 | FormLog.Memo1.Lines.AddStrings(Lines);
|
|---|
| 251 | end;
|
|---|
| 252 |
|
|---|
| 253 | procedure TFormMain.TargetStateChanged(Sender: TObject);
|
|---|
| 254 | begin
|
|---|
| 255 | UpdateInterface;
|
|---|
| 256 | if Core.Core.CurrentTarget.State = rsPaused then
|
|---|
| 257 | AProgramShowExecutionPoint.Execute;
|
|---|
| 258 | if Core.Core.CurrentTarget.State = rsStopped then
|
|---|
| 259 | Core.Core.Messages.AddMessage(SProgramStopped);
|
|---|
| 260 | end;
|
|---|
| 261 |
|
|---|
| 262 | procedure TFormMain.MessagesChanged(Sender: TObject);
|
|---|
| 263 | begin
|
|---|
| 264 | FormMessages.Reload;
|
|---|
| 265 | end;
|
|---|
| 266 |
|
|---|
| 267 | procedure TFormMain.MenuItemTargetClick(Sender: TObject);
|
|---|
| 268 | var
|
|---|
| 269 | I: Integer;
|
|---|
| 270 | begin
|
|---|
| 271 | if Sender is TMenuItem then
|
|---|
| 272 | with TMenuItem(Sender) do begin
|
|---|
| 273 | Core.Core.CurrentTarget := Core.Core.Targets[MenuIndex];
|
|---|
| 274 | Checked := True;
|
|---|
| 275 | for I := 0 to Parent.Count - 1 do
|
|---|
| 276 | if Parent.Items[I].MenuIndex <> MenuIndex then Parent.Items[I].Checked := False;
|
|---|
| 277 | end;
|
|---|
| 278 | end;
|
|---|
| 279 |
|
|---|
| 280 | procedure TFormMain.ProjectOpen(FileName: string);
|
|---|
| 281 | begin
|
|---|
| 282 | with Core.Core do begin
|
|---|
| 283 | if Project.Openned then
|
|---|
| 284 | raise Exception.Create(SCloseProjectFirst);
|
|---|
| 285 | FormSourceCode.SynEditSource.Lines.LoadFromFile(FileName);
|
|---|
| 286 | AddItemToLastOpenedList(FileName);
|
|---|
| 287 | Project.FileName := FileName;
|
|---|
| 288 | Project.Openned := True;
|
|---|
| 289 | CurrentTarget.Compiled := False;
|
|---|
| 290 | end;
|
|---|
| 291 | UpdateInterface;
|
|---|
| 292 | end;
|
|---|
| 293 |
|
|---|
| 294 | procedure TFormMain.UpdateToolBarHints;
|
|---|
| 295 | var
|
|---|
| 296 | I: Integer;
|
|---|
| 297 | begin
|
|---|
| 298 | for I := 0 to ToolBarMain.ControlCount - 1 do
|
|---|
| 299 | ToolBarMain.Controls[I].Hint := ToolBarMain.Controls[I].Caption;
|
|---|
| 300 | end;
|
|---|
| 301 |
|
|---|
| 302 | procedure TFormMain.DockForm(Form: TForm; DockSite: TWinControl);
|
|---|
| 303 | begin
|
|---|
| 304 | Form.ManualDock(DockSite, nil, alClient);
|
|---|
| 305 | Form.Align := alClient;
|
|---|
| 306 | Form.Show;
|
|---|
| 307 | end;
|
|---|
| 308 |
|
|---|
| 309 | procedure TFormMain.DockInit;
|
|---|
| 310 | begin
|
|---|
| 311 | DockForm(FormSourceCode, TabSheetSource);
|
|---|
| 312 | DockForm(FormTargetCode, TabSheetTarget);
|
|---|
| 313 | DockForm(FormCPU, PanelCPU);
|
|---|
| 314 | DockForm(FormInput, PanelInput);
|
|---|
| 315 | DockForm(FormOutput, PanelOutput);
|
|---|
| 316 | DockForm(FormMemory, PanelMemory);
|
|---|
| 317 | DockForm(FormMessages, TabSheetMessages);
|
|---|
| 318 | PageControlRight.Width := Width div 3;
|
|---|
| 319 | PageControlBottom.Height := Height div 5;
|
|---|
| 320 | end;
|
|---|
| 321 |
|
|---|
| 322 | procedure TFormMain.LastOpenedListChange(Sender: TObject);
|
|---|
| 323 | begin
|
|---|
| 324 | Core.Core.LastOpenedList.LoadToMenuItem(MenuItemOpenRecent, AProjectOpenRecentExecute);
|
|---|
| 325 | Core.Core.LastOpenedList.LoadToMenuItem(PopupMenuRecentFiles.Items, AProjectOpenRecentExecute);
|
|---|
| 326 | end;
|
|---|
| 327 |
|
|---|
| 328 | procedure TFormMain.CurrentTargetChangeExecute(Sender: TObject);
|
|---|
| 329 | begin
|
|---|
| 330 | UpdateTargetList;
|
|---|
| 331 | UpdateInterface;
|
|---|
| 332 | end;
|
|---|
| 333 |
|
|---|
| 334 | procedure TFormMain.UpdateStatusBarExecute(Sender: TObject);
|
|---|
| 335 | begin
|
|---|
| 336 | UpdateStatusBar;
|
|---|
| 337 | end;
|
|---|
| 338 |
|
|---|
| 339 | procedure TFormMain.UpdateInterfaceExecute(Sender: TObject);
|
|---|
| 340 | begin
|
|---|
| 341 | UpdateInterface;
|
|---|
| 342 | end;
|
|---|
| 343 |
|
|---|
| 344 | procedure TFormMain.UpdateInterface;
|
|---|
| 345 | var
|
|---|
| 346 | Title: string;
|
|---|
| 347 | CanDebug: Boolean;
|
|---|
| 348 | begin
|
|---|
| 349 | Title := '';
|
|---|
| 350 | with Core.Core do begin
|
|---|
| 351 | if Project.FileName <> '' then Title := Project.FileName;
|
|---|
| 352 | if Project.Modified then Title := Title + ' (' + SChanged + ')';
|
|---|
| 353 | Title:= Title + ' - ' + ApplicationInfo.AppName;
|
|---|
| 354 | Caption := Title;
|
|---|
| 355 | AProjectSave.Enabled := Project.Modified;
|
|---|
| 356 | FormSourceCode.SynEditSource.Enabled := Project.Openned;
|
|---|
| 357 | AProjectClose.Enabled := Project.Openned;
|
|---|
| 358 | AProjectSaveAs.Enabled := Project.Openned;
|
|---|
| 359 | AProgramRun.Enabled := (tcRun in CurrentTarget.Capabilities) and
|
|---|
| 360 | Project.Openned and (CurrentTarget.State = rsStopped) or (CurrentTarget.State = rsPaused);
|
|---|
| 361 | AProgramPause.Enabled := (tcPause in CurrentTarget.Capabilities) and
|
|---|
| 362 | Project.Openned and (CurrentTarget.State = rsRunning);
|
|---|
| 363 | AProgramStop.Enabled := (tcStop in CurrentTarget.Capabilities) and
|
|---|
| 364 | Project.Openned and (CurrentTarget.State <> rsStopped);
|
|---|
| 365 | AProgramCompile.Enabled := (tcCompile in CurrentTarget.Capabilities) and
|
|---|
| 366 | Project.Openned;
|
|---|
| 367 | CanDebug := DebugEnabled and Project.Openned and
|
|---|
| 368 | ((CurrentTarget.State = rsPaused) or (CurrentTarget.State = rsStopped));
|
|---|
| 369 | AProgramStepInto.Enabled := CanDebug and (tcStepInto in CurrentTarget.Capabilities);
|
|---|
| 370 | AProgramStepOut.Enabled := CanDebug and (tcStepOut in CurrentTarget.Capabilities);
|
|---|
| 371 | AProgramRunToCursor.Enabled := CanDebug and (tcRunToCursor in CurrentTarget.Capabilities);
|
|---|
| 372 | AProgramStepOver.Enabled := CanDebug and (tcStepOver in CurrentTarget.Capabilities);
|
|---|
| 373 | AProgramShowExecutionPoint.Enabled := CanDebug and (tcPause in CurrentTarget.Capabilities) and
|
|---|
| 374 | (CurrentTarget.State = rsPaused);
|
|---|
| 375 | AShowSourcePosition.Enabled := CurrentTarget.Compiled;
|
|---|
| 376 | AShowTargetPosition.Enabled := CurrentTarget.Compiled;
|
|---|
| 377 | AFullScreen.Checked := FullScreen;
|
|---|
| 378 | MenuItemViewToolbar.Checked := Core.Core.ShowToolbar;
|
|---|
| 379 | ToolBarMain.Visible := Core.Core.ShowToolbar;
|
|---|
| 380 | end;
|
|---|
| 381 | UpdateStatusBar;
|
|---|
| 382 | end;
|
|---|
| 383 |
|
|---|
| 384 | procedure TFormMain.UpdateStatusBar;
|
|---|
| 385 | begin
|
|---|
| 386 | StatusBarMain.Panels[0].Text := IntToStr(FormSourceCode.SynEditSource.CaretXY.X) +
|
|---|
| 387 | ', ' + IntToStr(FormSourceCode.SynEditSource.CaretXY.Y);
|
|---|
| 388 | end;
|
|---|
| 389 |
|
|---|
| 390 | procedure TFormMain.UpdateTargetList;
|
|---|
| 391 | var
|
|---|
| 392 | I: Integer;
|
|---|
| 393 | begin
|
|---|
| 394 | Core.Core.Targets.LoadToMenuItem(MenuItemTarget, MenuItemTargetClick, Core.Core.CurrentTarget);
|
|---|
| 395 | Core.Core.Targets.LoadToMenuItem(PopupMenuTargets.Items, MenuItemTargetClick, Core.Core.CurrentTarget);
|
|---|
| 396 |
|
|---|
| 397 | // Update toolbutton
|
|---|
| 398 | I := Core.Core.Targets.IndexOf(Core.Core.CurrentTarget);
|
|---|
| 399 | if I <> -1 then
|
|---|
| 400 | with TTarget(Core.Core.Targets[I]) do begin
|
|---|
| 401 | ToolButtonTarget.ImageIndex := ImageIndex;
|
|---|
| 402 | ToolButtonTarget.Caption := Name;
|
|---|
| 403 | ToolButtonTarget.OnClick := MenuItemTargetClick();
|
|---|
| 404 | end;
|
|---|
| 405 | end;
|
|---|
| 406 |
|
|---|
| 407 | procedure TFormMain.FormCreate(Sender: TObject);
|
|---|
| 408 | begin
|
|---|
| 409 | FormSourceCode := TFormSourceCode.Create(nil);
|
|---|
| 410 | FormSourceCode.OnUpdateStatusBar := UpdateStatusBarExecute;
|
|---|
| 411 | FormSourceCode.OnUpdateInterface := UpdateInterfaceExecute;
|
|---|
| 412 | FormCPU := TFormCPU.Create(nil);
|
|---|
| 413 | FormInput := TFormInput.Create(nil);
|
|---|
| 414 | FormLog := TFormLog.Create(nil);
|
|---|
| 415 | FormMemory := TFormMemory.Create(nil);
|
|---|
| 416 | FormMessages := TFormMessages.Create(nil);
|
|---|
| 417 | FormOutput := TFormOutput.Create(nil);
|
|---|
| 418 | FormTargetCode := TFormTargetCode.Create(nil);
|
|---|
| 419 |
|
|---|
| 420 | UpdateTargetList;
|
|---|
| 421 | with Core.Core do begin
|
|---|
| 422 | LastOpenedList.OnChange := LastOpenedListChange;
|
|---|
| 423 | OnCurrentTargetChange := CurrentTargetChangeExecute;
|
|---|
| 424 | OnTargetChangeState := TargetStateChanged;
|
|---|
| 425 | OnTargetLog := TargetLogExecute;
|
|---|
| 426 | end;
|
|---|
| 427 | end;
|
|---|
| 428 |
|
|---|
| 429 | procedure TFormMain.FormDestroy(Sender: TObject);
|
|---|
| 430 | begin
|
|---|
| 431 | FreeAndNil(FormSourceCode);
|
|---|
| 432 | FreeAndNil(FormCPU);
|
|---|
| 433 | FreeAndNil(FormInput);
|
|---|
| 434 | FreeAndNil(FormLog);
|
|---|
| 435 | FreeAndNil(FormMemory);
|
|---|
| 436 | FreeAndNil(FormMessages);
|
|---|
| 437 | FreeAndNil(FormOutput);
|
|---|
| 438 | FreeAndNil(FormTargetCode);
|
|---|
| 439 | if Assigned(FormKeyShortcuts) then FreeAndNil(FormKeyShortcuts);
|
|---|
| 440 | end;
|
|---|
| 441 |
|
|---|
| 442 | procedure TFormMain.AProgramRunExecute(Sender: TObject);
|
|---|
| 443 | begin
|
|---|
| 444 | if Core.Core.CurrentTarget is TTargetInterpreter then
|
|---|
| 445 | TTargetInterpreter(Core.Core.CurrentTarget).Input := FormInput.MemoInput.Lines.Text;
|
|---|
| 446 | if not Core.Core.CurrentTarget.Compiled then AProgramCompile.Execute;
|
|---|
| 447 | Core.Core.CurrentTarget.Run;
|
|---|
| 448 | Core.Core.Messages.AddMessage(SProgramStarted);
|
|---|
| 449 | end;
|
|---|
| 450 |
|
|---|
| 451 | procedure TFormMain.AShowSourcePositionExecute(Sender: TObject);
|
|---|
| 452 | var
|
|---|
| 453 | DebugStep: TDebugStep;
|
|---|
| 454 | begin
|
|---|
| 455 | DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchByTargetPos(FormTargetCode.SynEditTarget.SelStart - 1);
|
|---|
| 456 | if Assigned(DebugStep) then begin
|
|---|
| 457 | FormSourceCode.SynEditSource.SelStart := DebugStep.SourcePosition + 1;
|
|---|
| 458 | PageControlMain.TabIndex := 0;
|
|---|
| 459 | end;
|
|---|
| 460 | end;
|
|---|
| 461 |
|
|---|
| 462 | procedure TFormMain.AShowTargetPositionExecute(Sender: TObject);
|
|---|
| 463 | var
|
|---|
| 464 | DebugStep: TDebugStep;
|
|---|
| 465 | begin
|
|---|
| 466 | DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);
|
|---|
| 467 | if Assigned(DebugStep) then begin
|
|---|
| 468 | FormTargetCode.SynEditTarget.SelStart := DebugStep.TargetPosition + 1;
|
|---|
| 469 | PageControlMain.TabIndex := 1;
|
|---|
| 470 | end;
|
|---|
| 471 | end;
|
|---|
| 472 |
|
|---|
| 473 | procedure TFormMain.AViewCompilersExecute(Sender: TObject);
|
|---|
| 474 | begin
|
|---|
| 475 | with TFormTargets.Create(nil) do
|
|---|
| 476 | try
|
|---|
| 477 | ShowModal;
|
|---|
| 478 | finally
|
|---|
| 479 | Free;
|
|---|
| 480 | end;
|
|---|
| 481 | end;
|
|---|
| 482 |
|
|---|
| 483 | procedure TFormMain.AViewInterpreterExecute(Sender: TObject);
|
|---|
| 484 | begin
|
|---|
| 485 | FormCPU.Show;
|
|---|
| 486 | end;
|
|---|
| 487 |
|
|---|
| 488 | procedure TFormMain.AViewLogExecute(Sender: TObject);
|
|---|
| 489 | begin
|
|---|
| 490 | if not Assigned(FormLog) then FormLog := TFormLog.Create(Self);
|
|---|
| 491 | FormLog.Show;
|
|---|
| 492 | end;
|
|---|
| 493 |
|
|---|
| 494 | procedure TFormMain.FormActivate(Sender: TObject);
|
|---|
| 495 | begin
|
|---|
| 496 | AFullScreen.Checked := FullScreen;
|
|---|
| 497 | end;
|
|---|
| 498 |
|
|---|
| 499 | procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|---|
| 500 | begin
|
|---|
| 501 | Application.Terminate;
|
|---|
| 502 | end;
|
|---|
| 503 |
|
|---|
| 504 | procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
|---|
| 505 | begin
|
|---|
| 506 | if Core.Core.Project.Modified then begin
|
|---|
| 507 | AProjectClose.Execute;
|
|---|
| 508 | if Core.Core.Project.Openned then CanClose := False;
|
|---|
| 509 | end;
|
|---|
| 510 | end;
|
|---|
| 511 |
|
|---|
| 512 | procedure TFormMain.AExitExecute(Sender: TObject);
|
|---|
| 513 | begin
|
|---|
| 514 | Close;
|
|---|
| 515 | end;
|
|---|
| 516 |
|
|---|
| 517 | procedure TFormMain.AFullScreenExecute(Sender: TObject);
|
|---|
| 518 | begin
|
|---|
| 519 | FullScreen := not FullScreen;
|
|---|
| 520 | AFullScreen.Checked := FullScreen;
|
|---|
| 521 | TFormEx.PersistentForm.Save(Self);
|
|---|
| 522 | TFormEx.PersistentForm.SetFullScreen(FullScreen);
|
|---|
| 523 | UpdateInterface;
|
|---|
| 524 | end;
|
|---|
| 525 |
|
|---|
| 526 | procedure TFormMain.AHelpExecute(Sender: TObject);
|
|---|
| 527 | var
|
|---|
| 528 | FormHelp: TFormHelp;
|
|---|
| 529 | begin
|
|---|
| 530 | FormHelp := TFormHelp.Create(nil);
|
|---|
| 531 | try
|
|---|
| 532 | FormHelp.ShowModal;
|
|---|
| 533 | finally
|
|---|
| 534 | FormHelp.Free;
|
|---|
| 535 | end;
|
|---|
| 536 | end;
|
|---|
| 537 |
|
|---|
| 538 | procedure TFormMain.AKeyShortcutsExecute(Sender: TObject);
|
|---|
| 539 | begin
|
|---|
| 540 | if not Assigned(FormKeyShortcuts) then FormKeyShortcuts := TFormKeyShortcuts.Create(nil);
|
|---|
| 541 | FormKeyShortcuts.ImageList := Core.Core.ImageListMain;
|
|---|
| 542 | FormKeyShortcuts.MainForm := Self;
|
|---|
| 543 | FormKeyShortcuts.SourceComponents.Clear;
|
|---|
| 544 | FormKeyShortcuts.SourceComponents.Add(Self);
|
|---|
| 545 | FormKeyShortcuts.Show;
|
|---|
| 546 | end;
|
|---|
| 547 |
|
|---|
| 548 | procedure TFormMain.AOptionsExecute(Sender: TObject);
|
|---|
| 549 | var
|
|---|
| 550 | FormOptions: TFormOptions;
|
|---|
| 551 | begin
|
|---|
| 552 | FormOptions := TFormOptions.Create(nil);
|
|---|
| 553 | try
|
|---|
| 554 | FormOptions.Load;
|
|---|
| 555 | if FormOptions.ShowModal = mrOK then begin
|
|---|
| 556 | FormOptions.Save;
|
|---|
| 557 | if Assigned(Core.Core.CurrentTarget) then begin
|
|---|
| 558 | Core.Core.CurrentTarget.OptimizationLevel := Core.Core.OptimizationLevel;
|
|---|
| 559 | if Core.Core.CurrentTarget is TBFTarget then begin
|
|---|
| 560 | TBFTarget(Core.Core.CurrentTarget).CellSize := Core.Core.CellSize;
|
|---|
| 561 | TBFTarget(Core.Core.CurrentTarget).MemorySize := Core.Core.MemorySize;
|
|---|
| 562 | end;
|
|---|
| 563 | end;
|
|---|
| 564 | Core.Core.ThemeManager.UseTheme(Self);
|
|---|
| 565 | FormSourceCode.UpdateTheme;
|
|---|
| 566 | Core.Core.SaveToRegistry(Core.Core.ApplicationInfo.GetRegistryContext);
|
|---|
| 567 | end;
|
|---|
| 568 | finally
|
|---|
| 569 | FormOptions.Free;
|
|---|
| 570 | end;
|
|---|
| 571 | end;
|
|---|
| 572 |
|
|---|
| 573 | procedure TFormMain.AProgramCompileExecute(Sender: TObject);
|
|---|
| 574 | begin
|
|---|
| 575 | with Core.Core, CurrentTarget do
|
|---|
| 576 | try
|
|---|
| 577 | Messages.Clear;
|
|---|
| 578 | AProgramStop.Execute;
|
|---|
| 579 | SourceCode := FormSourceCode.SynEditSource.Text;
|
|---|
| 580 | ProjectFileName := Project.FileName;
|
|---|
| 581 | ProgramName := ExtractFileNameOnly(Project.FileName);
|
|---|
| 582 | if CurrentTarget is TBFTarget then
|
|---|
| 583 | TBFTarget(CurrentTarget).Optimizations := Optimizations;
|
|---|
| 584 | DebugEnabled := Core.Core.DebugEnabled;
|
|---|
| 585 | Messages.AddMessage(SCompileStart);
|
|---|
| 586 | Application.ProcessMessages;
|
|---|
| 587 | Compile;
|
|---|
| 588 | Messages.AppendMessage(SDone);
|
|---|
| 589 | FormTargetCode.SynEditTarget.Text := TargetCode;
|
|---|
| 590 | FormTargetCode.SetHighlighter(CurrentTarget.SourceExtension);
|
|---|
| 591 | UpdateInterface;
|
|---|
| 592 | except
|
|---|
| 593 | on E: Exception do
|
|---|
| 594 | MessageDlg(SError, E.Message, mtError, [mbOk], 0);
|
|---|
| 595 | end;
|
|---|
| 596 | end;
|
|---|
| 597 |
|
|---|
| 598 | procedure TFormMain.AProgramCompileMultipleExecute(Sender: TObject);
|
|---|
| 599 | var
|
|---|
| 600 | I: Integer;
|
|---|
| 601 | begin
|
|---|
| 602 | AProgramStop.Execute;
|
|---|
| 603 | with TFormCompileMultiple.Create(nil) do
|
|---|
| 604 | try
|
|---|
| 605 | Targets := Core.Core.Targets;
|
|---|
| 606 | if ShowModal = mrOk then begin
|
|---|
| 607 | Core.Core.Messages.Clear;
|
|---|
| 608 | for I := 0 to Targets.Count - 1 do
|
|---|
| 609 | with Targets[I] do
|
|---|
| 610 | if Selected then
|
|---|
| 611 | try
|
|---|
| 612 | AProgramStop.Execute;
|
|---|
| 613 | SourceCode := FormSourceCode.SynEditSource.Text;
|
|---|
| 614 | ProjectFileName := Core.Core.Project.FileName;
|
|---|
| 615 | ProgramName := ExtractFileNameOnly(Core.Core.Project.FileName);
|
|---|
| 616 | if Targets[I] is TBFTarget then
|
|---|
| 617 | TBFTarget(Targets[I]).Optimizations := Core.Core.Optimizations;
|
|---|
| 618 | DebugEnabled := Core.Core.DebugEnabled;
|
|---|
| 619 | Core.Core.Messages.AddMessage(Name + ' ' + SCompileStart);
|
|---|
| 620 | Application.ProcessMessages;
|
|---|
| 621 | Compile;
|
|---|
| 622 | Core.Core.Messages.AppendMessage(SDone);
|
|---|
| 623 | FormTargetCode.SynEditTarget.Text := TargetCode;
|
|---|
| 624 | FormTargetCode.SetHighlighter(Core.Core.CurrentTarget.SourceExtension);
|
|---|
| 625 | UpdateInterface;
|
|---|
| 626 | except
|
|---|
| 627 | on E: Exception do
|
|---|
| 628 | MessageDlg(SError, E.Message, mtError, [mbOk], 0);
|
|---|
| 629 | end;
|
|---|
| 630 | end;
|
|---|
| 631 | finally
|
|---|
| 632 | Free;
|
|---|
| 633 | end;
|
|---|
| 634 | end;
|
|---|
| 635 |
|
|---|
| 636 | procedure TFormMain.ABreakpointToggleExecute(Sender: TObject);
|
|---|
| 637 | var
|
|---|
| 638 | DebugStep: TDebugStep;
|
|---|
| 639 | BreakPoint: TBreakPoint;
|
|---|
| 640 | begin
|
|---|
| 641 | DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);
|
|---|
| 642 | if Assigned(DebugStep) then begin
|
|---|
| 643 | BreakPoint := Core.Core.CurrentTarget.BreakPoints.SearchByTargetPos(DebugStep.ProgramPosition);
|
|---|
| 644 | if Assigned(BreakPoint) then
|
|---|
| 645 | Core.Core.CurrentTarget.BreakPoints.Delete(Core.Core.CurrentTarget.BreakPoints.IndexOf(BreakPoint))
|
|---|
| 646 | else Core.Core.CurrentTarget.BreakPoints.AddItem(DebugStep.ProgramPosition);
|
|---|
| 647 | end;
|
|---|
| 648 | end;
|
|---|
| 649 |
|
|---|
| 650 | procedure TFormMain.AAboutExecute(Sender: TObject);
|
|---|
| 651 | var
|
|---|
| 652 | FormAbout: TFormAbout;
|
|---|
| 653 | begin
|
|---|
| 654 | FormAbout := TFormAbout.Create(nil);
|
|---|
| 655 | FormAbout.ApplicationInfo := Core.Core.ApplicationInfo;
|
|---|
| 656 | try
|
|---|
| 657 | FormAbout.ShowModal;
|
|---|
| 658 | finally
|
|---|
| 659 | FormAbout.Free;
|
|---|
| 660 | end;
|
|---|
| 661 | end;
|
|---|
| 662 |
|
|---|
| 663 | procedure TFormMain.AProgramPauseExecute(Sender: TObject);
|
|---|
| 664 | begin
|
|---|
| 665 | Core.Core.CurrentTarget.Pause;
|
|---|
| 666 | end;
|
|---|
| 667 |
|
|---|
| 668 | procedure TFormMain.AProgramRunToCursorExecute(Sender: TObject);
|
|---|
| 669 | var
|
|---|
| 670 | DebugStep: TDebugStep;
|
|---|
| 671 | begin
|
|---|
| 672 | if Core.Core.CurrentTarget.State = rsStopped then begin
|
|---|
| 673 | if not Core.Core.CurrentTarget.Compiled then AProgramCompile.Execute;
|
|---|
| 674 | DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);
|
|---|
| 675 | Core.Core.CurrentTarget.BreakPoints.SetSystem(DebugStep.ProgramPosition);
|
|---|
| 676 | AProgramRun.Execute;
|
|---|
| 677 | end else begin
|
|---|
| 678 | DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchBySourcePos(FormSourceCode.SynEditSource.SelStart - 1);
|
|---|
| 679 | Core.Core.CurrentTarget.RunToCursor(DebugStep.ProgramPosition);
|
|---|
| 680 | end;
|
|---|
| 681 | end;
|
|---|
| 682 |
|
|---|
| 683 | procedure TFormMain.AProgramShowExecutionPointExecute(Sender: TObject);
|
|---|
| 684 | var
|
|---|
| 685 | DebugStep: TDebugStep;
|
|---|
| 686 | begin
|
|---|
| 687 | DebugStep := Core.Core.CurrentTarget.DebugSteps.SearchByProgramPos(
|
|---|
| 688 | Core.Core.CurrentTarget.ExecutionPosition);
|
|---|
| 689 | if Assigned(DebugStep) then begin
|
|---|
| 690 | FormSourceCode.SynEditSource.SelStart := DebugStep.SourcePosition + 1;
|
|---|
| 691 | FormTargetCode.SynEditTarget.SelStart := DebugStep.TargetPosition + 1;
|
|---|
| 692 | if PageControlMain.TabIndex = 0 then FormSourceCode.SynEditSource.SetFocus;
|
|---|
| 693 | if PageControlMain.TabIndex = 1 then FormTargetCode.SynEditTarget.SetFocus;
|
|---|
| 694 | end;
|
|---|
| 695 | end;
|
|---|
| 696 |
|
|---|
| 697 | procedure TFormMain.AProgramStepIntoExecute(Sender: TObject);
|
|---|
| 698 | begin
|
|---|
| 699 | if Core.Core.CurrentTarget.State = rsStopped then begin
|
|---|
| 700 | if not Core.Core.CurrentTarget.Compiled then AProgramCompile.Execute;
|
|---|
| 701 | Core.Core.CurrentTarget.BreakPoints.SetSystem(
|
|---|
| 702 | Core.Core.CurrentTarget.DebugSteps.First.ProgramPosition);
|
|---|
| 703 | AProgramRun.Execute;
|
|---|
| 704 | end else Core.Core.CurrentTarget.StepInto;
|
|---|
| 705 | end;
|
|---|
| 706 |
|
|---|
| 707 | procedure TFormMain.AProgramStepOutExecute(Sender: TObject);
|
|---|
| 708 | begin
|
|---|
| 709 | Core.Core.CurrentTarget.StepOut;
|
|---|
| 710 | end;
|
|---|
| 711 |
|
|---|
| 712 | procedure TFormMain.AProgramStepOverExecute(Sender: TObject);
|
|---|
| 713 | begin
|
|---|
| 714 | if Core.Core.CurrentTarget.State = rsStopped then begin
|
|---|
| 715 | if not Core.Core.CurrentTarget.Compiled then AProgramCompile.Execute;
|
|---|
| 716 | Core.Core.CurrentTarget.BreakPoints.SetSystem(
|
|---|
| 717 | TDebugStep(Core.Core.CurrentTarget.DebugSteps.First).ProgramPosition);
|
|---|
| 718 | AProgramRun.Execute;
|
|---|
| 719 | end else Core.Core.CurrentTarget.StepOver;
|
|---|
| 720 | end;
|
|---|
| 721 |
|
|---|
| 722 | procedure TFormMain.AProgramStopExecute(Sender: TObject);
|
|---|
| 723 | begin
|
|---|
| 724 | Core.Core.CurrentTarget.Stop;
|
|---|
| 725 | end;
|
|---|
| 726 |
|
|---|
| 727 | procedure TFormMain.AProjectCloseExecute(Sender: TObject);
|
|---|
| 728 | var
|
|---|
| 729 | DialogResult: TModalResult;
|
|---|
| 730 | begin
|
|---|
| 731 | DialogResult := mrNo;
|
|---|
| 732 | if Core.Core.Project.Modified then begin
|
|---|
| 733 | DialogResult := MessageDlg(SUnsavedChanges, SDoYouWantToSaveProject, mtConfirmation, [mbYes, mbNo, mbCancel], 0);
|
|---|
| 734 | if DialogResult = mrYes then begin
|
|---|
| 735 | AProjectSave.Execute;
|
|---|
| 736 | end;
|
|---|
| 737 | end;
|
|---|
| 738 | if (DialogResult = mrNo) or (DialogResult = mrYes) then begin
|
|---|
| 739 | AProgramStop.Execute;
|
|---|
| 740 | Core.Core.Project.Openned := False;
|
|---|
| 741 | FormSourceCode.SynEditSource.Clear;
|
|---|
| 742 | UpdateInterface;
|
|---|
| 743 | end;
|
|---|
| 744 | end;
|
|---|
| 745 |
|
|---|
| 746 | procedure TFormMain.AProjectNewExecute(Sender: TObject);
|
|---|
| 747 | begin
|
|---|
| 748 | AProjectClose.Execute;
|
|---|
| 749 | if Core.Core.Project.Openned then Exit;
|
|---|
| 750 | Core.Core.Project.FileName := SNewProject + '.b';
|
|---|
| 751 | Core.Core.Project.Openned := True;
|
|---|
| 752 | FormSourceCode.SynEditSource.Clear;
|
|---|
| 753 | Core.Core.CurrentTarget.Compiled := False;
|
|---|
| 754 | UpdateInterface;
|
|---|
| 755 | end;
|
|---|
| 756 |
|
|---|
| 757 | procedure TFormMain.AProjectOpenRecentExecute(Sender: TObject);
|
|---|
| 758 | var
|
|---|
| 759 | FileName: string;
|
|---|
| 760 | begin
|
|---|
| 761 | FileName := Core.Core.LastOpenedList.Items[TMenuItem(Sender).MenuIndex];
|
|---|
| 762 | if FileExists(FileName) then begin
|
|---|
| 763 | AProjectClose.Execute;
|
|---|
| 764 | if Core.Core.Project.Openned then Exit;
|
|---|
| 765 | ProjectOpen(FileName);
|
|---|
| 766 | end else ShowMessage(Format(SFileNotFound, [FileName]));
|
|---|
| 767 | end;
|
|---|
| 768 |
|
|---|
| 769 | procedure TFormMain.AProjectOpenExecute(Sender: TObject);
|
|---|
| 770 | var
|
|---|
| 771 | FileName: string;
|
|---|
| 772 | begin
|
|---|
| 773 | if Core.Core.LastOpenedList.Items.Count > 0 then
|
|---|
| 774 | FileName := Core.Core.LastOpenedList.Items[0];
|
|---|
| 775 | OpenDialog1.InitialDir := ExtractFileDir(FileName);
|
|---|
| 776 | OpenDialog1.FileName := ExtractFileName(FileName);
|
|---|
| 777 | if OpenDialog1.Execute then begin
|
|---|
| 778 | AProjectClose.Execute;
|
|---|
| 779 | if Core.Core.Project.Openned then Exit;
|
|---|
| 780 | ProjectOpen(OpenDialog1.FileName);
|
|---|
| 781 | end;
|
|---|
| 782 | end;
|
|---|
| 783 |
|
|---|
| 784 | procedure TFormMain.AProjectSaveAsExecute(Sender: TObject);
|
|---|
| 785 | begin
|
|---|
| 786 | SaveDialog1.InitialDir := ExtractFileDir(Core.Core.Project.FileName);
|
|---|
| 787 | SaveDialog1.FileName := ExtractFileName(Core.Core.Project.FileName);
|
|---|
| 788 | if SaveDialog1.Execute then begin
|
|---|
| 789 | FormSourceCode.SynEditSource.Lines.SaveToFile(SaveDialog1.FileName);
|
|---|
| 790 | Core.Core.Project.FileName := SaveDialog1.FileName;
|
|---|
| 791 | Core.Core.AddItemToLastOpenedList(SaveDialog1.FileName);
|
|---|
| 792 | Core.Core.Project.Modified := False;
|
|---|
| 793 | UpdateInterface;
|
|---|
| 794 | end;
|
|---|
| 795 | end;
|
|---|
| 796 |
|
|---|
| 797 | procedure TFormMain.AProjectSaveExecute(Sender: TObject);
|
|---|
| 798 | begin
|
|---|
| 799 | if Core.Core.Project.Modified and FileExists(Core.Core.Project.FileName) then begin
|
|---|
| 800 | FormSourceCode.SynEditSource.Lines.SaveToFile(Core.Core.Project.FileName);
|
|---|
| 801 | Core.Core.AddItemToLastOpenedList(Core.Core.Project.FileName);
|
|---|
| 802 | Core.Core.Project.Modified := False;
|
|---|
| 803 | UpdateInterface;
|
|---|
| 804 | end else AProjectSaveAs.Execute;
|
|---|
| 805 | end;
|
|---|
| 806 |
|
|---|
| 807 | end.
|
|---|
| 808 |
|
|---|