Changeset 25 for trunk/Forms


Ignore:
Timestamp:
Feb 13, 2012, 9:47:18 AM (13 years ago)
Author:
chronos
Message:
  • Added: List of supported compiler targets.
  • Added: Action to compile and run project.
Location:
trunk/Forms
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UCompiledForm.lfm

    r23 r25  
    1010  object MemoCompiled: TMemo
    1111    Left = 8
    12     Height = 421
     12    Height = 384
    1313    Top = 8
    1414    Width = 540
     
    2020    TabOrder = 0
    2121  end
     22  object Button1: TButton
     23    Left = 7
     24    Height = 25
     25    Top = 404
     26    Width = 113
     27    Action = MainForm.ACompileAndRun
     28    Anchors = [akLeft, akBottom]
     29    TabOrder = 1
     30  end
    2231end
  • trunk/Forms/UCompiledForm.pas

    r23 r25  
    1313
    1414  TCompiledForm = class(TForm)
     15    Button1: TButton;
    1516    MemoCompiled: TMemo;
    1617  private
  • trunk/Forms/UMainForm.lfm

    r24 r25  
    8282      Top = 2
    8383      Width = 10
    84       Caption = 'ToolButton5'
    8584      Style = tbsSeparator
    8685    end
     
    412411          0000000000000000000000000000000000000000000000000000
    413412        }
     413      end
     414      object MenuItem31: TMenuItem
     415        Action = ACompileAndRun
    414416      end
    415417      object MenuItemTarget: TMenuItem
     
    590592        }
    591593      end
     594      object MenuItem30: TMenuItem
     595        Action = AViewCompilers
     596      end
    592597      object MenuItem19: TMenuItem
    593598        Action = AViewInterpretter
     
    648653    top = 96
    649654    object AProjectOpen: TAction
     655      Category = 'Project'
    650656      Caption = 'Open'
    651657      ImageIndex = 7
     
    654660    end
    655661    object AProjectSave: TAction
     662      Category = 'Project'
    656663      Caption = 'Save'
    657664      ImageIndex = 0
     
    660667    end
    661668    object AProjectClose: TAction
     669      Category = 'Project'
    662670      Caption = 'Close'
    663671      ImageIndex = 4
     
    666674    end
    667675    object AProjectSaveAs: TAction
     676      Category = 'Project'
    668677      Caption = 'Save as...'
    669678      ImageIndex = 0
     
    672681    end
    673682    object AProjectNew: TAction
     683      Category = 'Project'
    674684      Caption = 'New'
    675685      ImageIndex = 9
     
    688698      OnExecute = ACompileExecute
    689699    end
     700    object ACompileAndRun: TAction
     701      Caption = 'Compile and run'
     702      OnExecute = ACompileAndRunExecute
     703    end
    690704    object AProgramRun: TAction
    691705      Caption = 'Run'
     
    711725    end
    712726    object AViewInterpretter: TAction
     727      Category = 'View'
    713728      Caption = 'Interpretter'
    714729      OnExecute = AViewInterpretterExecute
    715730    end
    716731    object AViewCompiled: TAction
     732      Category = 'View'
    717733      Caption = 'Compiled'
    718734      OnExecute = AViewCompiledExecute
     
    736752    end
    737753    object AOptions: TAction
     754      Category = 'View'
    738755      Caption = 'Options'
    739756      ImageIndex = 2
     
    741758    end
    742759    object AFormatSource: TAction
     760      Category = 'Tool'
    743761      Caption = 'Format source'
    744762      OnExecute = AFormatSourceExecute
    745763    end
    746764    object AShrinkSource: TAction
     765      Category = 'Tool'
    747766      Caption = 'Shrink source'
    748767      OnExecute = AShrinkSourceExecute
    749768    end
    750769    object AGenerateNumber: TAction
     770      Category = 'Tool'
    751771      Caption = 'Generate code for number'
    752772      ImageIndex = 13
    753773      OnExecute = AGenerateNumberExecute
     774    end
     775    object AViewCompilers: TAction
     776      Category = 'View'
     777      Caption = 'Compilers'
     778      OnExecute = AViewCompilersExecute
    754779    end
    755780  end
  • trunk/Forms/UMainForm.lrt

    r24 r25  
    11TMAINFORM.CAPTION=LazFuck
    2 TMAINFORM.TOOLBUTTON5.CAPTION=ToolButton5
    32TMAINFORM.MENUITEM1.CAPTION=Project
    43TMAINFORM.MENUITEMOPENRECENT.CAPTION=Open recent
     
    1716TMAINFORM.AEXIT.CAPTION=Exit
    1817TMAINFORM.ACOMPILE.CAPTION=Compile
     18TMAINFORM.ACOMPILEANDRUN.CAPTION=Compile and run
    1919TMAINFORM.APROGRAMRUN.CAPTION=Run
    2020TMAINFORM.AABOUT.CAPTION=About
     
    3333TMAINFORM.ASHRINKSOURCE.CAPTION=Shrink source
    3434TMAINFORM.AGENERATENUMBER.CAPTION=Generate code for number
     35TMAINFORM.AVIEWCOMPILERS.CAPTION=Compilers
  • trunk/Forms/UMainForm.pas

    r24 r25  
    88  Classes, SysUtils, FileUtil, SynEdit, Forms, Controls, Graphics, Dialogs,
    99  Menus, ActnList, StdCtrls, ComCtrls, UBrainFuck, UCoolTranslator, StrUtils,
    10   SpecializedList, UCompiler, Registry, URegistry, ULastOpenedList;
     10  SpecializedList, UCompiler, Registry, URegistry, ULastOpenedList, Process;
    1111
    1212const
     
    2121    AAbout: TAction;
    2222    ABreakpointToggle: TAction;
     23    ACompileAndRun: TAction;
     24    AViewCompilers: TAction;
    2325    AGenerateNumber: TAction;
    2426    AShrinkSource: TAction;
     
    6870    MenuItem28: TMenuItem;
    6971    MenuItem29: TMenuItem;
     72    MenuItem30: TMenuItem;
     73    MenuItem31: TMenuItem;
    7074    MenuItemOpenRecent: TMenuItem;
    7175    MenuItemTarget: TMenuItem;
     
    9599    ToolButton9: TToolButton;
    96100    procedure ABreakpointToggleExecute(Sender: TObject);
     101    procedure ACompileAndRunExecute(Sender: TObject);
    97102    procedure ACompileExecute(Sender: TObject);
    98103    procedure AExitExecute(Sender: TObject);
     
    110115    procedure AShrinkSourceExecute(Sender: TObject);
    111116    procedure AViewCompiledExecute(Sender: TObject);
     117    procedure AViewCompilersExecute(Sender: TObject);
    112118    procedure AViewInterpretterExecute(Sender: TObject);
    113119    procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
     
    135141    BrainFuckInterpreter: TBrainFuckInterpretter;
    136142    BreakPoints: TListInteger;
    137     Compilers: TListObject; // TListObject<TCompiler>
     143    Compilers: TCompilerList;
    138144    LastOpenedList: TLastOpenedList;
    139145    OpenProjectOnStart: Boolean;
     
    142148    procedure UpdateInterface;
    143149    procedure UpdateStatusBar;
    144     procedure UpdateTergetList;
     150    procedure UpdateTargetList;
    145151  end;
    146152
     
    154160uses
    155161  UInterpretterForm, UApplicationInfo, UCompiledForm, UOptionsForm,
    156   UCompilerDelphi, UCompilerPHP;
     162  UCompilerDelphi, UCompilerPHP, UCompilersForm;
    157163
    158164resourcestring
    159165  SEnterNumber = 'Enter number';
    160166  SNumberGeneration = 'Number generation';
     167  SProgramExited = 'Program exited';
     168  SCompilerNotFound = 'Compiler "%s" not found';
     169  SCompiledFileNotFound = 'Program compiled file "%s" not found';
    161170
    162171{ TMainForm }
     
    167176    ProjectOpen(LastOpenedList[0])
    168177    else AProjectNew.Execute;
     178  UpdateInterface;
    169179end;
    170180
     
    234244      CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(ReadStringWithDefault('LanguageCode', ''))
    235245      else CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode('');
     246    CompilerIndex := ReadIntegerWithDefault('SelectedCompiler', 0);
    236247  finally
    237248    Free;
    238249  end;
    239250  LastOpenedList.LoadFromRegistry(Root, Key);
     251  Compilers.LoadFromRegistry(Root, Key);
    240252end;
    241253
    242254procedure TMainForm.SaveToRegistry(Root: HKEY; Key: string);
    243255begin
     256  Compilers.SaveToRegistry(Root, Key);
    244257  LastOpenedList.SaveToRegistry(Root, Key);
    245258  with TRegistryEx.Create do
     
    253266      WriteString('LanguageCode', CoolTranslator1.Language.Code)
    254267      else DeleteValue('LanguageCode');
     268    WriteInteger('SelectedCompiler', CompilerIndex);
    255269  finally
    256270    Free;
     
    274288  ACompile.Enabled := ProjectFileName <> '';
    275289  UpdateStatusBar;
     290  UpdateTargetList;
    276291end;
    277292
     
    281296end;
    282297
    283 procedure TMainForm.UpdateTergetList;
     298procedure TMainForm.UpdateTargetList;
    284299var
    285300  I: Integer;
     
    302317  BrainFuckInterpreter.OnChangeState := BrainFuckInterpreterChangeState;
    303318  BrainFuckCompiler := TBrainFuckCompiler.Create;
    304   Compilers := TListObject.Create;
     319  Compilers := TCompilerList.Create;
    305320  Compilers.Add(TBrainFuckCompilerDelphi.Create);
    306321  Compilers.Add(TBrainFuckCompilerPHP.Create);
    307   UpdateTergetList;
     322  UpdateTargetList;
    308323  LastOpenedList := TLastOpenedList.Create;
    309324  LastOpenedList.MenuItem := MenuItemOpenRecent;
     
    352367begin
    353368  CompiledForm.Show;
     369end;
     370
     371procedure TMainForm.AViewCompilersExecute(Sender: TObject);
     372begin
     373  FormCompilers.Show;
    354374end;
    355375
     
    437457end;
    438458
     459procedure TMainForm.ACompileAndRunExecute(Sender: TObject);
     460var
     461  Process: TProcess;
     462  CompiledFile: string;
     463begin
     464  with TBrainFuckCompiler(Compilers[CompilerIndex]) do begin
     465    Optimization := coNormal;
     466    Source := MemoSource.Text;
     467    ProgramName := ExtractFileNameOnly(ProjectFileName);
     468    Compile;
     469    CompiledFile := ExtractFilePath(ProjectFileName) +
     470      'compiled' + DirectorySeparator + Name + DirectorySeparator +
     471      ExtractFileNameOnly(ProjectFileName) + SourceExtension;
     472    ForceDirectoriesUTF8(ExtractFilePath(CompiledFile));
     473    with TStringList.Create do
     474    try
     475      Text := Output;
     476      SaveToFile(CompiledFile);
     477    finally
     478      Free;
     479    end;
     480    if FileExistsUTF8(CompilerPath) then
     481    try
     482      Process := TProcess.Create(nil);
     483      Process.CommandLine := '"' + CompilerPath + '" "' + CompiledFile + '"';
     484      Process.Options := [poWaitOnExit];
     485      Process.Execute;
     486    finally
     487      Process.Free;
     488    end else raise Exception.Create(Format(SCompilerNotFound, [CompilerPath]));
     489
     490    if CompiledExtension <> '' then begin
     491      CompiledFile := ExtractFilePath(CompiledFile) + ExtractFileNameOnly(CompiledFile) + CompiledExtension;
     492      if FileExistsUTF8(CompiledFile) then
     493      try
     494        Process := TProcess.Create(nil);
     495        Process.CommandLine := '"' + CompiledFile + '"';
     496        Process.Options := [poWaitOnExit];
     497        Process.Execute;
     498      finally
     499        Process.Free;
     500      end else raise Exception.Create(Format(SCompiledFileNotFound, [CompiledFile]));
     501    end;
     502  end;
     503end;
     504
    439505procedure TMainForm.AProgramPauseExecute(Sender: TObject);
    440506begin
  • trunk/Forms/UOptionsForm.lfm

    r23 r25  
    1010  LCLVersion = '0.9.31'
    1111  object ButtonOk: TButton
    12     Left = 380
     12    Left = 389
    1313    Height = 25
    1414    Top = 247
     
    2121  end
    2222  object ButtonCancel: TButton
    23     Left = 292
     23    Left = 304
    2424    Height = 25
    2525    Top = 247
     
    3030    TabOrder = 1
    3131  end
    32   object Label1: TLabel
    33     Left = 8
    34     Height = 18
    35     Top = 8
    36     Width = 88
    37     Caption = 'Memory size:'
    38     ParentColor = False
    39   end
    40   object SpinEditMemorySize: TSpinEdit
     32  object SpinEditCellSize: TSpinEdit
    4133    Left = 136
    42     Height = 27
    43     Top = 6
     34    Height = 21
     35    Top = 40
    4436    Width = 130
    4537    MaxValue = 2000000000
    4638    TabOrder = 2
    4739  end
    48   object Label2: TLabel
    49     Left = 8
    50     Height = 18
    51     Top = 40
    52     Width = 60
    53     Caption = 'Cell size:'
    54     ParentColor = False
    55   end
    56   object SpinEditCellSize: TSpinEdit
     40  object SpinEditMemorySize: TSpinEdit
    5741    Left = 136
    58     Height = 27
    59     Top = 40
     42    Height = 21
     43    Top = 6
    6044    Width = 130
    6145    MaxValue = 2000000000
    6246    TabOrder = 3
    6347  end
     48  object Label1: TLabel
     49    Left = 8
     50    Height = 14
     51    Top = 8
     52    Width = 64
     53    Caption = 'Memory size:'
     54    ParentColor = False
     55  end
     56  object Label2: TLabel
     57    Left = 8
     58    Height = 14
     59    Top = 40
     60    Width = 43
     61    Caption = 'Cell size:'
     62    ParentColor = False
     63  end
    6464  object Label3: TLabel
    6565    Left = 8
    66     Height = 18
     66    Height = 14
    6767    Top = 95
    68     Width = 127
     68    Width = 97
    6969    Caption = 'Interface language:'
    7070    ParentColor = False
    7171  end
     72  object CheckBox1: TCheckBox
     73    Left = 8
     74    Height = 17
     75    Top = 120
     76    Width = 159
     77    Caption = 'Reopend last opened project'
     78    TabOrder = 4
     79  end
    7280  object ComboBoxLanguage: TComboBox
    7381    Left = 162
    74     Height = 27
     82    Height = 21
    7583    Top = 86
    7684    Width = 188
    77     ItemHeight = 0
     85    ItemHeight = 13
    7886    Style = csDropDownList
    79     TabOrder = 4
    80   end
    81   object CheckBox1: TCheckBox
    82     Left = 8
    83     Height = 19
    84     Top = 120
    85     Width = 205
    86     Caption = 'Reopend last opened project'
    8787    TabOrder = 5
    8888  end
  • trunk/Forms/UOptionsForm.pas

    r23 r25  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   Spin, UBrainFuck;
     9  Spin, ComCtrls, UBrainFuck;
    1010
    1111type
Note: See TracChangeset for help on using the changeset viewer.