unit Unit10;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ExtCtrls, EditBtn, StdCtrls, Buttons, Dispatcher, ClipBrd;

type

  { TExtGeneratorForm }

  TExtGeneratorForm = class(TForm)
    UseShellCheckBox: TCheckBox;
    CmdBitBtn: TBitBtn;
    GenBitBtn: TBitBtn;
    UpdBitBtn: TBitBtn;
    PreviewMemo: TMemo;
    ParamsEdit: TEdit;
    GeneratorFileNameEdit: TFileNameEdit;
    Panel1: TPanel;
    procedure CmdBitBtnClick(Sender: TObject);
    procedure GenBitBtnClick(Sender: TObject);
    procedure UpdBitBtnClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  ExtGeneratorForm: TExtGeneratorForm;

implementation

{ TExtGeneratorForm }

procedure TExtGeneratorForm.GenBitBtnClick(Sender: TObject);
Var S:TStringList;
begin
  S:=TStringList.Create;
  If UseShellCheckBox.Checked Then
    S.Text:=Dispatcher.ExecShellCmd('bash -c "'+GeneratorFileNameEdit.Text+' '+ParamsEdit.Text+' "')
  Else
    S.Text:=Dispatcher.ExecShellCmd(GeneratorFileNameEdit.Text+' '+ParamsEdit.Text);
  PreviewMemo.Text:=S.Text;
  Clipboard.Clear;
  Clipboard.AsText:=S.Text;
  S.Free;
end;

procedure TExtGeneratorForm.CmdBitBtnClick(Sender: TObject);
Var I:Longint;
begin
  If PreviewMemo.Lines.Count>0 Then
    For I:=0 To PreviewMemo.Lines.Count-1 Do
      Dispatcher.QueueCommand(PreviewMemo.Lines[I]);
end;

procedure TExtGeneratorForm.UpdBitBtnClick(Sender: TObject);
begin
  Clipboard.Clear;
  Clipboard.AsText:=PreviewMemo.Text;

end;

initialization
  {$I unit10.lrs}

end.

