Changeset 6 for trunk/UMainForm.pas


Ignore:
Timestamp:
Feb 9, 2012, 3:22:38 PM (13 years ago)
Author:
chronos
Message:
  • Modified: Interpretter now wait for key press if Read instruction is executed and no input character is available.
  • Added: Actions to control program executions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UMainForm.pas

    r5 r6  
    1616    ACompile: TAction;
    1717    AAbout: TAction;
     18    AProgramPause: TAction;
     19    AProgramStop: TAction;
    1820    AHelp: TAction;
    19     ARun: TAction;
     21    AProgramRun: TAction;
    2022    AProjectNew: TAction;
    2123    AExit: TAction;
     
    3436    MenuItem13: TMenuItem;
    3537    MenuItem14: TMenuItem;
     38    MenuItem15: TMenuItem;
     39    MenuItem16: TMenuItem;
     40    MenuItem17: TMenuItem;
    3641    MenuItem2: TMenuItem;
    3742    MenuItem3: TMenuItem;
     
    5560    ToolButton7: TToolButton;
    5661    procedure AExitExecute(Sender: TObject);
     62    procedure AProgramPauseExecute(Sender: TObject);
     63    procedure AProgramStopExecute(Sender: TObject);
    5764    procedure AProjectCloseExecute(Sender: TObject);
    5865    procedure AProjectNewExecute(Sender: TObject);
     
    6067    procedure AProjectSaveAsExecute(Sender: TObject);
    6168    procedure AProjectSaveExecute(Sender: TObject);
    62     procedure ARunExecute(Sender: TObject);
     69    procedure AProgramRunExecute(Sender: TObject);
    6370    procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
    6471    procedure FormCreate(Sender: TObject);
     
    6774    procedure MemoSourceChange(Sender: TObject);
    6875  private
    69     { private declarations }
     76    procedure BrainFuckInterpreterChangeState(Sender: TObject);
    7077  public
    7178    Modified: Boolean;
     
    95102begin
    96103  Modified := True;
     104  UpdateInterface;
     105end;
     106
     107procedure TMainForm.BrainFuckInterpreterChangeState(Sender: TObject);
     108begin
    97109  UpdateInterface;
    98110end;
     
    109121  MemoSource.Enabled := ProjectFileName <> '';
    110122  AProjectClose.Enabled := ProjectFileName <> '';
    111   ARun.Enabled := ProjectFileName <> '';
     123  AProgramRun.Enabled := (ProjectFileName <> '') and (BrainFuckInterpreter.State = rsStopped);
     124  AProgramPause.Enabled := (ProjectFileName <> '') and (BrainFuckInterpreter.State = rsRunning);
     125  AProgramStop.Enabled := (ProjectFileName <> '') and (BrainFuckInterpreter.State <> rsStopped);
    112126  ACompile.Enabled := ProjectFileName <> '';
    113127end;
     
    116130begin
    117131  BrainFuckInterpreter := TBrainFuckInterpreter.Create;
     132  BrainFuckInterpreter.OnChangeState := BrainFuckInterpreterChangeState;
    118133end;
    119134
     
    123138end;
    124139
    125 procedure TMainForm.ARunExecute(Sender: TObject);
     140procedure TMainForm.AProgramRunExecute(Sender: TObject);
    126141begin
    127142  InterpreterForm.Show;
     
    138153begin
    139154  Close;
     155end;
     156
     157procedure TMainForm.AProgramPauseExecute(Sender: TObject);
     158begin
     159  MainForm.BrainFuckInterpreter.Pause
     160end;
     161
     162procedure TMainForm.AProgramStopExecute(Sender: TObject);
     163begin
     164  MainForm.BrainFuckInterpreter.Stop;
    140165end;
    141166
Note: See TracChangeset for help on using the changeset viewer.