Ignore:
Timestamp:
May 6, 2015, 11:19:49 AM (10 years ago)
Author:
chronos
Message:
  • Added: Now opened projects are remembered between application restarts.
  • Added: Show basic list of files in selected project.
  • Added: Packages Common and TemplateGenerics.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormConsole.pas

    r5 r6  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   Buttons, ComCtrls, ActnList, Menus, Process;
     9  ExtCtrls, Process;
    1010
    1111type
     
    1414
    1515  TFormConsole = class(TForm)
    16     AAbort: TAction;
    17     ARestart: TAction;
    18     ActionList1: TActionList;
     16    ButtonAbort: TButton;
    1917    EditCommand: TEdit;
    20     MemoOutput: TMemo;
    21     MenuItem1: TMenuItem;
    22     MenuItem2: TMenuItem;
    23     PopupMenu1: TPopupMenu;
    24     ToolBar1: TToolBar;
    25     ToolButton1: TToolButton;
    26     procedure AAbortExecute(Sender: TObject);
     18    Memo1: TMemo;
     19    Timer1: TTimer;
     20    procedure ButtonAbortClick(Sender: TObject);
    2721    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    2822    procedure FormCreate(Sender: TObject);
    2923    procedure FormDestroy(Sender: TObject);
    3024    procedure FormShow(Sender: TObject);
     25    procedure Timer1Timer(Sender: TObject);
    3126  private
    3227    Process: TProcess;
     
    3631    Parameters: TStringList;
    3732    WorkingDir: string;
    38     Environment: TStringList;
     33    Environment: string;
    3934    Aborted: Boolean;
    40     Duration: TDateTime;
     35    Log: TStringList;
    4136    procedure Perform;
    4237  end;
     
    4742implementation
    4843
    49 uses
    50   UFormMain;
    51 
    5244{$R *.lfm}
    5345
     
    5749begin
    5850  Parameters := TStringList.Create;
    59   Parameters.QuoteChar := ' ';
    60   Parameters.Delimiter := ' ';
    61   Environment := TStringList.Create;
    62   Environment.QuoteChar := ' ';
    63   Environment.Delimiter := ' ';
     51  Log := TStringList.Create;
    6452end;
    6553
    6654procedure TFormConsole.FormDestroy(Sender: TObject);
    6755begin
    68   Environment.Free;
     56  Log.Free;
    6957  Parameters.Free;
    7058end;
     
    7260procedure TFormConsole.FormShow(Sender: TObject);
    7361begin
    74   //FormMain.PersistentForm1.Load(Self);
    75   MemoOutput.Clear;
    76   AAbort.Enabled := False;
     62  Memo1.Clear;
     63  ButtonAbort.Enabled := False;
     64  Timer1.Enabled := True;
    7765end;
    7866
    79 procedure TFormConsole.AAbortExecute(Sender: TObject);
     67procedure TFormConsole.Timer1Timer(Sender: TObject);
     68begin
     69  Timer1.Enabled := False;
     70  Perform;
     71end;
     72
     73procedure TFormConsole.ButtonAbortClick(Sender: TObject);
    8074begin
    8175  if Assigned(Process) then begin
     
    8882  );
    8983begin
    90   AAbort.Execute;
    91   //FormMain.PersistentForm1.Save(Self);
     84  ButtonAbort.Click;
    9285end;
    9386
     
    9992  Line: string;
    10093  CommandLine: string;
    101   TimeStart: TDateTime;
    10294begin
    103   TimeStart := Now;
    104   if not Visible then Show;
    10595  Text := '';
    10696  try
    10797    Process := TProcess.Create(nil);
    10898    Aborted := False;
    109     AAbort.Enabled := True;
     99    ButtonAbort.Enabled := True;
    110100    if WorkingDir <> '' then
    111101      Process.CurrentDirectory := WorkingDir;
    112102    //WorkingDir := '';
    113     if Environment.Count <> 0 then
    114       Process.Environment.Assign(Environment);
    115 //    Environment := '';
     103    if Environment <> '' then
     104      Process.Environment.Text := Environment;
     105    Environment := '';
    116106    //Process.Executable := Executable;
    117107    //Process.Parameters.Assign(Parameters);
    118     Process.CommandLine := Executable + ' ' + Parameters.DelimitedText;
    119     CommandLine := Executable + ' ' + Parameters.DelimitedText;
    120     //if CommandLine[Length(CommandLine)] = #$a then
    121     //  SetLength(CommandLine, Length(CommandLine) - 1);
     108    Process.CommandLine := Executable + ' ' + Parameters.Text;
     109    CommandLine := Executable + ' ' + StringReplace(Parameters.Text, LineEnding, ' ', [rfReplaceAll]);
     110    if CommandLine[Length(CommandLine)] = LineEnding then
     111      SetLength(CommandLine, Length(CommandLine) - 1);
    122112    EditCommand.Text := CommandLine;
    123113    Process.Options := [poUsePipes, poNoConsole];
     
    135125          Line := Copy(Text, 1, Pos(LineEnding, Text) - 1);
    136126          Delete(Text, 1, Length(Line) + Length(LineEnding));
    137           MemoOutput.Lines.Add(Line);
     127          Memo1.Lines.Add(Line);
    138128        end;
    139129      end;
     
    147137          Line := Copy(Text, 1, Pos(LineEnding, Text) - 1);
    148138          Delete(Text, 1, Length(Line) + Length(LineEnding));
    149           MemoOutput.Lines.Add(Line);
     139          Memo1.Lines.Add(Line);
    150140        end;
    151141      end;
     
    154144    end;
    155145  finally
    156     MemoOutput.Lines.Add(Text);
     146    Memo1.Lines.Add(Text);
    157147    FreeAndNil(Process);
    158148  end;
    159   Duration := Now - TimeStart;
    160   AAbort.Enabled := False;
    161   //ToolButton1.ModalResult := mrOK;
     149  Log.Assign(Memo1.Lines);
     150  ButtonAbort.Enabled := False;
     151  //ModalResult := mrOK;
     152  //Close;
    162153end;
    163154
Note: See TracChangeset for help on using the changeset viewer.