Ignore:
Timestamp:
Dec 4, 2014, 11:46:40 AM (10 years ago)
Author:
chronos
Message:
  • Modified: Project openned state as property instead of checking FileName.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r61 r62  
    154154    procedure LastOpenedListChange(Sender: TObject);
    155155  public
    156     LastFileName: string;
    157156    procedure LoadFromRegistry(Root: HKEY; Key: string);
    158157    procedure SaveToRegistry(Root: HKEY; Key: string);
     
    182181  SCompileStart = 'Compiling...';
    183182  SDone = 'Done';
     183  SChanged = 'Changed';
    184184
    185185{ TMainForm }
     
    264264  Core.LastOpenedList.AddItem(FileName);
    265265  Core.Project.FileName := FileName;
    266   Core.Project.Modified := False;
     266  Core.Project.Openned := True;
    267267  CurrentTarget.Compiled := False;
    268268  UpdateInterface;
     
    319319    OpenKey(Key, True);
    320320    TargetName := ReadStringWithDefault('TargetName', 'Interpretter');
    321     LastFileName := ReadStringWithDefault('LastFileName',
    322       ExtractFileDir(Application.ExeName) + DirectorySeparator + 'Examples');
    323321    CurrentTarget := Core.Targets.FindByName(TargetName);
    324322    if not Assigned(CurrentTarget) then CurrentTarget := TTarget(Core.Targets[0]);
     
    335333    OpenKey(Key, True);
    336334    WriteString('TargetName', CurrentTarget.Name);
    337     WriteString('LastFileName', LastFileName);
    338335  finally
    339336    Free;
     
    345342  Title: string;
    346343begin
     344  Title := '';
     345  if Core.Project.FileName <> '' then Title := Core.Project.FileName;
     346  if Core.Project.Modified then Title := Title + ' (' + SChanged + ')';
     347  Title:= Title + ' - ' + Core.ApplicationInfo.AppName;
     348  Caption := Title;
    347349  AProjectSave.Enabled := Core.Project.Modified;
    348   Title := Core.ApplicationInfo.AppName;
    349   if Core.Project.FileName <> '' then Title := Core.Project.FileName + ' - ' + Title;
    350   if Core.Project.Modified then Title := Title + ' *';
    351   Caption := Title;
    352   FormSourceCode.MemoSource.Enabled := Core.Project.FileName <> '';
    353   AProjectClose.Enabled := Core.Project.FileName <> '';
     350  FormSourceCode.MemoSource.Enabled := Core.Project.Openned;
     351  AProjectClose.Enabled := Core.Project.Openned;
     352  AProjectSaveAs.Enabled := Core.Project.Openned;
    354353  AProgramRun.Enabled := (tcRun in CurrentTarget.Capabilities) and
    355     (Core.Project.FileName <> '') and (CurrentTarget.State = rsStopped) or (CurrentTarget.State = rsPaused);
     354    Core.Project.Openned and (CurrentTarget.State = rsStopped) or (CurrentTarget.State = rsPaused);
    356355  AProgramPause.Enabled := (tcPause in CurrentTarget.Capabilities) and
    357     (Core.Project.FileName <> '') and (CurrentTarget.State = rsRunning);
     356    Core.Project.Openned and (CurrentTarget.State = rsRunning);
    358357  AProgramStop.Enabled := (tcStop in CurrentTarget.Capabilities) and
    359     (Core.Project.FileName <> '') and (CurrentTarget.State <> rsStopped);
     358    Core.Project.Openned and (CurrentTarget.State <> rsStopped);
    360359  AProgramCompile.Enabled := (tcCompile in CurrentTarget.Capabilities) and
    361     (Core.Project.FileName <> '');
     360    Core.Project.Openned;
    362361  AProgramStepInto.Enabled := (tcStepInto in CurrentTarget.Capabilities) and
    363     (Core.Project.FileName <> '') and ((CurrentTarget.State = rsPaused) or (CurrentTarget.State = rsStopped));
     362    Core.Project.Openned and ((CurrentTarget.State = rsPaused) or (CurrentTarget.State = rsStopped));
    364363  AProgramStepOut.Enabled := (tcStepOut in CurrentTarget.Capabilities) and
    365     (Core.Project.FileName <> '') and (CurrentTarget.State = rsPaused);
     364    Core.Project.Openned and (CurrentTarget.State = rsPaused);
    366365  AProgramRunToCursor.Enabled := (tcRunToCursor in CurrentTarget.Capabilities) and
    367     (Core.Project.FileName <> '') and ((CurrentTarget.State = rsPaused) or (CurrentTarget.State = rsStopped));
     366    Core.Project.Openned and ((CurrentTarget.State = rsPaused) or (CurrentTarget.State = rsStopped));
    368367  AProgramStepOver.Enabled := (tcStepOver in CurrentTarget.Capabilities) and
    369     (Core.Project.FileName <> '') and ((CurrentTarget.State = rsPaused) or (CurrentTarget.State = rsStopped));
     368    Core.Project.Openned and ((CurrentTarget.State = rsPaused) or (CurrentTarget.State = rsStopped));
    370369  AProgramShowExecutionPoint.Enabled := (tcPause in CurrentTarget.Capabilities) and
    371     (Core.Project.FileName <> '') and (CurrentTarget.State = rsPaused);
     370    Core.Project.Openned and (CurrentTarget.State = rsPaused);
    372371  AShowSourcePosition.Enabled := CurrentTarget.Compiled;
    373372  AShowTargetPosition.Enabled := CurrentTarget.Compiled;
     
    568567  if Core.Project.Modified then AProjectSaveAs.Execute;
    569568  AProgramStop.Execute;
    570   Core.Project.FileName := '';
     569  Core.Project.Openned := False;
    571570  FormSourceCode.MemoSource.Clear;
    572   Core.Project.Modified := False;
    573571  UpdateInterface;
    574572end;
     
    579577  Core.Project.FileName := 'Examples' + DirectorySeparator + SNewProject + '.b';
    580578  FormSourceCode.MemoSource.Clear;
    581   Core.Project.Modified := False;
     579  Core.Project.Openned := True;
    582580  CurrentTarget.Compiled := False;
    583581  UpdateInterface;
     
    592590begin
    593591  AProjectClose.Execute;
    594   OpenDialog1.FileName := LastFileName;
    595   OpenDialog1.InitialDir := ExtractFileDir(LastFileName);
     592  if Core.LastOpenedList.Items.Count > 0 then
     593    OpenDialog1.FileName := Core.LastOpenedList.Items[0]
     594    else OpenDialog1.FileName := ExtractFileDir(Application.ExeName) + DirectorySeparator + 'Examples';
     595  OpenDialog1.InitialDir := ExtractFileDir(OpenDialog1.FileName);
    596596  if OpenDialog1.Execute then begin
    597     LastFileName := OpenDialog1.FileName;
    598597    ProjectOpen(OpenDialog1.FileName);
    599598  end;
     
    614613procedure TMainForm.AProjectSaveExecute(Sender: TObject);
    615614begin
    616   if Core.Project.Modified then AProjectSaveAs.Execute;
     615  if Core.Project.Modified and FileExistsUTF8(Core.Project.FileName) then begin
     616    FormSourceCode.MemoSource.Lines.SaveToFile(UTF8Decode(Core.Project.FileName));
     617    Core.Project.Modified := False;
     618    UpdateInterface;
     619  end else AProjectSaveAs.Execute;
    617620end;
    618621
Note: See TracChangeset for help on using the changeset viewer.