Changeset 136 for trunk


Ignore:
Timestamp:
Mar 5, 2022, 4:14:27 PM (2 years ago)
Author:
chronos
Message:
  • Modified: Update recent files list in registry immediately.
  • Fixed: Regresion in debugging step in and step out.
  • Fixed: Of by one index in loop start command interpretation.
  • Fixed: Correctly load directory and file name into open and save dialogs.
  • Modified: Faster interval for program output refresh.
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r133 r136  
    547547  end
    548548  object TimerRefresh: TTimer
     549    Interval = 200
    549550    OnTimer = TimerRefreshTimer
    550551    Left = 70
  • trunk/Forms/UFormMain.pas

    r134 r136  
    189189  SFileNotFound = 'File %s not found.';
    190190
     191const
     192  ExamplesDir = 'Examples';
     193
    191194{ TFormMain }
    192195
     
    259262    raise Exception.Create(SCloseProjectFirst);
    260263  FormSourceCode.SynEditSource.Lines.LoadFromFile(FileName);
    261   Core.LastOpenedList.AddItem(FileName);
     264  Core.AddItemToLastOpenedList(FileName);
    262265  Core.Project.FileName := FileName;
    263266  Core.Project.Openned := True;
     
    663666  AProjectClose.Execute;
    664667  if Core.Project.Openned then Exit;
    665   Core.Project.FileName := CombinePaths(Core.DataDir, 'Examples' + DirectorySeparator + SNewProject + '.b');
     668  Core.Project.FileName := CombinePaths(Core.DataDir, ExamplesDir + DirectorySeparator + SNewProject + '.b');
    666669  FormSourceCode.SynEditSource.Clear;
    667670  Core.Project.Openned := True;
     
    683686
    684687procedure TFormMain.AProjectOpenExecute(Sender: TObject);
     688var
     689  FileName: string;
    685690begin
    686691  if Core.LastOpenedList.Items.Count > 0 then
    687     OpenDialog1.FileName := Core.LastOpenedList.Items[0]
    688     else OpenDialog1.FileName := CombinePaths(Core.DataDir, 'Examples');
    689   OpenDialog1.InitialDir := ExtractFileDir(OpenDialog1.FileName);
     692    FileName := Core.LastOpenedList.Items[0]
     693    else FileName := CombinePaths(Core.DataDir, ExamplesDir);
     694  OpenDialog1.InitialDir := ExtractFileDir(FileName);
     695  OpenDialog1.FileName := ExtractFileName(FileName);
    690696  if OpenDialog1.Execute then begin
    691697    AProjectClose.Execute;
     
    697703procedure TFormMain.AProjectSaveAsExecute(Sender: TObject);
    698704begin
    699   SaveDialog1.FileName := Core.Project.FileName;
     705  SaveDialog1.InitialDir := ExtractFileDir(Core.Project.FileName);
     706  SaveDialog1.FileName := ExtractFileName(Core.Project.FileName);
    700707  if SaveDialog1.Execute then begin
    701708    FormSourceCode.SynEditSource.Lines.SaveToFile(SaveDialog1.FileName);
    702709    Core.Project.FileName := SaveDialog1.FileName;
    703     Core.LastOpenedList.AddItem(SaveDialog1.FileName);
     710    Core.AddItemToLastOpenedList(SaveDialog1.FileName);
    704711    Core.Project.Modified := False;
    705712    UpdateInterface;
     
    711718  if Core.Project.Modified and FileExists(Core.Project.FileName) then begin
    712719    FormSourceCode.SynEditSource.Lines.SaveToFile(Core.Project.FileName);
     720    Core.AddItemToLastOpenedList(Core.Project.FileName);
    713721    Core.Project.Modified := False;
    714722    UpdateInterface;
  • trunk/Languages/LazFuck.cs.po

    r135 r136  
    619619msgstr "Zastaveno"
    620620
     621#: utargetinterpretter.sbreakpointindexerror
     622#, object-pascal-format
     623msgid "Break point index error: %d"
     624msgstr "Chyba indexu bodu přeruÅ¡ení: %d"
     625
    621626#: utargetinterpretter.sjumptablecollision
    622627msgid "Jump table collision"
     
    628633msgstr "Nekonzistentní skoková tabulka"
    629634
    630 #: utargetinterpretter.sprogramlowerlimit
    631 msgid "Program run over lower limit"
    632 msgstr "Program překročil dolní omezení"
     635#: utargetinterpretter.sprogramlowermemorylimit
     636msgid "Program run over lower memory limit"
     637msgstr "Program překročil dolní rozsah paměti"
    633638
    634639#: utargetinterpretter.sprogramnotrunning
     
    636641msgstr "Program neběşí"
    637642
    638 #: utargetinterpretter.sprogramupperlimit
    639 msgid "Program run over upper limit"
    640 msgstr "Program překročil horní omezení"
     643#: utargetinterpretter.sprogramuppermemorylimit
     644msgid "Program run over upper memory limit"
     645msgstr "Program překročil horní rozsah paměti"
    641646
    642647#: utargetinterpretter.sunsupportedcommand
  • trunk/Languages/LazFuck.pot

    r135 r136  
    609609msgstr ""
    610610
     611#: utargetinterpretter.sbreakpointindexerror
     612#, object-pascal-format
     613msgid "Break point index error: %d"
     614msgstr ""
     615
    611616#: utargetinterpretter.sjumptablecollision
    612617msgid "Jump table collision"
     
    618623msgstr ""
    619624
    620 #: utargetinterpretter.sprogramlowerlimit
    621 msgid "Program run over lower limit"
     625#: utargetinterpretter.sprogramlowermemorylimit
     626msgid "Program run over lower memory limit"
    622627msgstr ""
    623628
     
    626631msgstr ""
    627632
    628 #: utargetinterpretter.sprogramupperlimit
    629 msgid "Program run over upper limit"
     633#: utargetinterpretter.sprogramuppermemorylimit
     634msgid "Program run over upper memory limit"
    630635msgstr ""
    631636
  • trunk/Target/UTargetInterpretter.pas

    r133 r136  
    1616  private
    1717    FNewState: TRunState;
     18    FMessage: string;
     19    procedure DoMessage;
    1820    procedure DoSetState;
    1921    procedure SetStateSafe(State: TRunState);
     
    8183
    8284resourcestring
    83   SProgramLowerLimit = 'Program run over lower limit';
    84   SProgramUpperLimit = 'Program run over upper limit';
     85  SProgramLowerMemoryLimit = 'Program run over lower memory limit';
     86  SProgramUpperMemoryLimit = 'Program run over upper memory limit';
    8587  SJumpTableInconsistent = 'Jump table is inconsistent';
    8688  SJumpTableCollision = 'Jump table collision';
    8789  SProgramNotRunning = 'Program not running';
    8890  SUnsupportedCommand = 'Unsupported command';
     91  SBreakPointIndexError = 'Break point index error: %d';
    8992
    9093{ TTargetInterpretterThread }
     
    9396var
    9497  BreakPoint: TBreakPoint;
    95 begin
     98  Index: Integer;
     99begin
     100  try
    96101  with Parent do
    97102  repeat
     
    100105        if FProgramBreakpoints[FProgramIndex] then begin
    101106          BreakPoint := BreakPoints.SearchByTargetPos(FProgramIndex);
    102           if BreakPoint.System then BreakPoints.Delete(BreakPoints.IndexOf(BreakPoint));
     107          if BreakPoint.System then begin
     108            Index := BreakPoints.IndexOf(BreakPoint);
     109            if Index <> -1 then BreakPoints.Delete(Index)
     110            else raise Exception.Create(Format(SBreakPointIndexError, [Index]));
     111          end;
    103112          SetStateSafe(rsPaused);
    104113        end else begin
     
    114123    if State <> rsStopped then SetStateSafe(rsStopped);
    115124  until Terminated or (State = rsStopped);
     125
     126  except
     127    on E: Exception do begin
     128      FMessage := E.Message;
     129      Synchronize(DoMessage);
     130    end;
     131  end;
     132end;
     133
     134procedure TTargetInterpretterThread.DoMessage;
     135begin
     136  Parent.SendMessage(FMessage);
    116137end;
    117138
     
    123144procedure TTargetInterpretterThread.SetStateSafe(State: TRunState);
    124145begin
     146  if Parent.State = State then Exit;
    125147  FNewState := State;
    126148  Synchronize(DoSetState);
     
    212234begin
    213235  if Memory[MemoryPosition + FProgram[FProgramIndex].RelIndex] = 0 then
    214     FProgramIndex := FProgram[FProgramIndex].Parameter;
     236    FProgramIndex := FProgram[FProgramIndex].Parameter - 1;
    215237end;
    216238
     
    245267  if MemoryPosition < MemorySize then
    246268    Inc(MemoryPosition, FProgram[FProgramIndex].Parameter)
    247     else raise Exception.Create(SProgramUpperLimit);
     269    else raise Exception.Create(SProgramUpperMemoryLimit);
    248270end;
    249271
     
    252274  if MemoryPosition > 0 then
    253275    Dec(MemoryPosition, FProgram[FProgramIndex].Parameter)
    254     else raise Exception.Create(SProgramLowerLimit);
     276    else raise Exception.Create(SProgramLowerMemoryLimit);
    255277end;
    256278
     
    319341procedure TTargetInterpretter.CheckMemoryBounds(Address: Integer);
    320342begin
    321   if Address < 0 then raise Exception.Create(SProgramLowerLimit);
    322   if Address >= MemorySize then raise Exception.Create(SProgramUpperLimit);
     343  if Address < 0 then raise Exception.Create(SProgramLowerMemoryLimit);
     344  if Address >= MemorySize then raise Exception.Create(SProgramUpperMemoryLimit);
    323345end;
    324346
     
    428450    Nesting := 1;
    429451    while (StepIndex < DebugSteps.Count) and (Nesting > 0) do begin
    430       if TDebugStep(DebugSteps[StepIndex]).Operation = soStepIn then Inc(Nesting);
    431       if TDebugStep(DebugSteps[StepIndex]).Operation = soStepOut then Dec(Nesting);
     452      if DebugSteps[StepIndex].Operation = soStepIn then Inc(Nesting);
     453      if DebugSteps[StepIndex].Operation = soStepOut then Dec(Nesting);
    432454      Inc(StepIndex);
    433455    end;
    434456    if StepIndex < DebugSteps.Count then begin
    435       Breakpoints.SetSystem(TDebugStep(DebugSteps[StepIndex]).ProgramPosition);
     457      Breakpoints.SetSystem(DebugSteps[StepIndex].ProgramPosition);
    436458    end;
    437459    Run;
  • trunk/UBFTarget.pas

    r128 r136  
    589589      ']': FProgram.Write(TMachineOperation.Create(cmLoopEnd, 0));
    590590    end;
    591     if DebugEnabled and (FProgram.Index <> LastIndex) then
    592       DebugSteps.AddStep(I - 1, FProgram.Index - 1, soNormal);
     591    if DebugEnabled and (FProgram.Index <> LastIndex) then begin
     592      case FSourceCode[I] of
     593        '[': DebugSteps.AddStep(I - 1, FProgram.Index - 1, soStepIn);
     594        ']': DebugSteps.AddStep(I - 1, FProgram.Index - 1, soStepOut);
     595        else DebugSteps.AddStep(I - 1, FProgram.Index - 1, soNormal);
     596      end;
     597    end;
    593598    LastIndex := FProgram.Index;
    594599  end;
  • trunk/UCore.lfm

    r135 r136  
    2121    AppName = 'LazFuck'
    2222    Description = 'A simple BrainFuck IDE written in Lazarus/FPC.'
    23     ReleaseDate = 44575
     23    ReleaseDate = 44625
    2424    RegistryKey = '\Software\Chronosoft\LazFuck'
    2525    RegistryRoot = rrKeyCurrentUser
  • trunk/UCore.pas

    r135 r136  
    2929    FCurrentTarget: TTarget;
    3030    StoredDimension: TControlDimension;
     31    RecentFileRegistryContext: TRegistryContext;
    3132    procedure InitTargets;
    3233    procedure SetCurrentTarget(AValue: TTarget);
     
    4647    Optimizations: TOptimizations;
    4748    procedure Init;
     49    procedure AddItemToLastOpenedList(FileName: string);
    4850    procedure LoadFromRegistry(Context: TRegistryContext);
    4951    procedure SaveToRegistry(Context: TRegistryContext);
     
    6971
    7072{ TCore }
     73
     74procedure TCore.AddItemToLastOpenedList(FileName: string);
     75begin
     76  with LastOpenedList do begin
     77    LoadFromRegistry(RecentFileRegistryContext);
     78    AddItem(FileName);
     79    SaveToRegistry(RecentFileRegistryContext);
     80  end;
     81end;
    7182
    7283procedure TCore.DataModuleCreate(Sender: TObject);
     
    91102  StoredDimension := TControlDimension.Create;
    92103  InitTargets;
     104  RecentFileRegistryContext := TRegistryContext.Create(ApplicationInfo.RegistryRoot,
     105    ApplicationInfo.RegistryKey + '\' + RecentFilesRegKey);
    93106  LoadFromRegistry(Core.ApplicationInfo.GetRegistryContext);
    94107end;
     
    149162    Free;
    150163  end;
    151   LastOpenedList.LoadFromRegistry(TRegistryContext.Create(Context.RootKey, Context.Key + '\' + RecentFilesRegKey));
    152164  Targets.LoadFromRegistry(TRegistryContext.Create(Context.RootKey, Context.Key + '\Compiler'));
     165  LastOpenedList.LoadFromRegistry(RecentFileRegistryContext);
    153166  PersistentForm1.RegistryContext := Context;
    154167end;
     
    157170begin
    158171  Targets.SaveToRegistry(TRegistryContext.Create(Context.RootKey, Context.Key + '\Compiler'));
    159   LastOpenedList.SaveToRegistry(TRegistryContext.Create(Context.RootKey, Context.Key + '\' + RecentFilesRegKey));
    160172  with TRegistryEx.Create do
    161173  try
  • trunk/UTarget.pas

    r135 r136  
    113113    DebugEnabled: Boolean;
    114114    Selected: Boolean;
     115    procedure SendMessage(Text: string);
    115116    constructor Create; virtual;
    116117    destructor Destroy; override;
     
    427428end;
    428429
     430procedure TTarget.SendMessage(Text: string);
     431begin
     432  if Assigned(FOnMessage) then
     433    FOnMessage(Text);
     434end;
     435
    429436procedure TTarget.SetSourceCode(AValue: string);
    430437begin
Note: See TracChangeset for help on using the changeset viewer.