mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-03 02:38:16 +02:00
MG: added Run Parameter Options - not enabled yet
git-svn-id: trunk@390 -
This commit is contained in:
parent
4d2da430b7
commit
311b264796
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -123,6 +123,7 @@ ide/newprojectdlg.pp svneol=native#text/pascal
|
||||
ide/project.pp svneol=native#text/pascal
|
||||
ide/projectopts.lrs svneol=native#text/pascal
|
||||
ide/projectopts.pp svneol=native#text/pascal
|
||||
ide/runparamsopts.pas svneol=native#text/pascal
|
||||
ide/splash.pp svneol=native#text/pascal
|
||||
ide/testform.pp svneol=native#text/pascal
|
||||
ide/transfermacros.pp svneol=native#text/pascal
|
||||
|
38
ide/main.pp
38
ide/main.pp
@ -39,7 +39,7 @@ uses
|
||||
IDEComp, AbstractFormEditor, FormEditor, CustomFormEditor, ObjectInspector,
|
||||
PropEdits, ControlSelection, UnitEditor, CompilerOptions, EditorOptions,
|
||||
EnvironmentOpts, TransferMacros, KeyMapping, ProjectOpts, IDEProcs, Process,
|
||||
UnitInfoDlg, Debugger;
|
||||
UnitInfoDlg, Debugger, RunParamsOpts;
|
||||
|
||||
const
|
||||
Version_String = '0.8 alpha';
|
||||
@ -112,6 +112,7 @@ type
|
||||
itmProjectRunToCursor: TMenuItem;
|
||||
itmProjectStop: TMenuItem;
|
||||
itmProjectCompilerSettings: TMenuItem;
|
||||
itmProjectRunParameters: TMenuItem;
|
||||
|
||||
itmEditUndo: TMenuItem;
|
||||
itmEditRedo: TMenuItem;
|
||||
@ -164,6 +165,7 @@ type
|
||||
Procedure mnuViewFormsClicked(Sender : TObject);
|
||||
|
||||
procedure mnuToggleFormUnitClicked(Sender : TObject);
|
||||
|
||||
procedure mnuNewProjectClicked(Sender : TObject);
|
||||
procedure mnuOpenProjectClicked(Sender : TObject);
|
||||
procedure mnuSaveProjectClicked(Sender : TObject);
|
||||
@ -171,6 +173,8 @@ type
|
||||
procedure mnuAddToProjectClicked(Sender : TObject);
|
||||
procedure mnuRemoveFromProjectClicked(Sender : TObject);
|
||||
procedure mnuViewProjectSourceClicked(Sender : TObject);
|
||||
procedure mnuProjectOptionsClicked(Sender : TObject);
|
||||
|
||||
procedure mnuBuildProjectClicked(Sender : TObject);
|
||||
procedure mnuRunProjectClicked(Sender : TObject);
|
||||
procedure mnuPauseProjectClicked(Sender : TObject);
|
||||
@ -178,8 +182,8 @@ type
|
||||
procedure mnuStepOverProjectClicked(Sender : TObject);
|
||||
procedure mnuRunToCursorProjectClicked(Sender : TObject);
|
||||
procedure mnuStopProjectClicked(Sender : TObject);
|
||||
procedure mnuRunParametersClicked(Sender : TObject);
|
||||
procedure mnuProjectCompilerSettingsClicked(Sender : TObject);
|
||||
procedure mnuProjectOptionsClicked(Sender : TObject);
|
||||
|
||||
procedure mnuViewCodeExplorerClick(Sender : TObject);
|
||||
procedure mnuViewMessagesClick(Sender : TObject);
|
||||
@ -1159,7 +1163,13 @@ begin
|
||||
itmProjectCompilerSettings.Caption := 'Compiler Options...';
|
||||
itmProjectCompilerSettings.OnClick := @mnuProjectCompilerSettingsClicked;
|
||||
mnuRun.Add(itmProjectCompilerSettings);
|
||||
|
||||
|
||||
itmProjectRunParameters := TMenuItem.Create(Self);
|
||||
itmProjectRunParameters.Name:='itmProjectRunParameters';
|
||||
itmProjectRunParameters.Caption := 'Run Parameters ...';
|
||||
itmProjectRunParameters.OnClick := @mnuRunParametersClicked;
|
||||
mnuRun.Add(itmProjectRunParameters);
|
||||
|
||||
//--------------
|
||||
// Environment
|
||||
//--------------
|
||||
@ -1726,6 +1736,13 @@ begin
|
||||
DoOpenMainUnit(false);
|
||||
end;
|
||||
|
||||
procedure TMainIDE.mnuProjectOptionsClicked(Sender : TObject);
|
||||
begin
|
||||
if ShowProjectOptionsDialog(Project)=mrOk then begin
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TMainIDE.mnuBuildProjectClicked(Sender : TObject);
|
||||
Begin
|
||||
DoBuildProject;
|
||||
@ -1776,13 +1793,15 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.mnuProjectOptionsClicked(Sender : TObject);
|
||||
procedure TMainIDE.mnuRunParametersClicked(Sender : TObject);
|
||||
begin
|
||||
if ShowProjectOptionsDialog(Project)=mrOk then begin
|
||||
if ShowRunParamsOptsDlg(Project.RunParameterOptions)=mrOk then begin
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
procedure TMainIDE.SaveDesktopSettings(
|
||||
@ -3337,7 +3356,8 @@ writeln('[TMainIDE.DoRunProject] A');
|
||||
TheProcess.Execute;
|
||||
except
|
||||
on e: Exception do begin
|
||||
AText:='Error running program "'+ProgramFilename+'": '+e.Message;
|
||||
AText:='Error running program'#13'"'+ProgramFilename+'"'#13
|
||||
+'Error: '+e.Message;
|
||||
MessageDlg(AText,mterror,[mbok], 0);
|
||||
end;
|
||||
end;
|
||||
@ -4409,6 +4429,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.136 2001/11/06 12:20:30 lazarus
|
||||
MG: added Run Parameter Options - not enabled yet
|
||||
|
||||
Revision 1.135 2001/11/05 18:18:13 lazarus
|
||||
added popupmenu+arrows to notebooks, added target filename
|
||||
|
||||
@ -9042,6 +9065,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.136 2001/11/06 12:20:30 lazarus
|
||||
MG: added Run Parameter Options - not enabled yet
|
||||
|
||||
Revision 1.135 2001/11/05 18:18:13 lazarus
|
||||
added popupmenu+arrows to notebooks, added target filename
|
||||
|
||||
|
100
ide/project.pp
100
ide/project.pp
@ -32,7 +32,8 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLLinux, XMLCfg, LazConf, CompilerOptions, FileCtrl,
|
||||
CodeToolManager, CodeCache, Forms, Controls, EditorOptions, Dialogs, IDEProcs;
|
||||
CodeToolManager, CodeCache, Forms, Controls, EditorOptions, Dialogs, IDEProcs,
|
||||
RunParamsOpts;
|
||||
|
||||
type
|
||||
//---------------------------------------------------------------------------
|
||||
@ -192,12 +193,12 @@ type
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
TProjectType = // for a description see ProjectTypeDescriptions
|
||||
TProjectType = // for a description see ProjectTypeDescriptions below
|
||||
(ptApplication, ptProgram, ptCustomProgram);
|
||||
|
||||
TProject = class(TObject)
|
||||
private
|
||||
xmlcfg: TXMLConfig;
|
||||
xmlconfig: TXMLConfig;
|
||||
|
||||
{ Variables }
|
||||
fActiveEditorIndexAtStart: integer;
|
||||
@ -214,6 +215,7 @@ type
|
||||
fTitle: String;
|
||||
fUnitList: TList; // list of TUnitInfo
|
||||
fUnitOutputDirectory: String;
|
||||
fRunParameterOptions: TRunParamsOptions;
|
||||
|
||||
function GetProjectInfoFile: string;
|
||||
function GetTargetFilename: string;
|
||||
@ -275,6 +277,7 @@ type
|
||||
property ProjectInfoFile: string
|
||||
read GetProjectInfoFile write SetProjectInfoFile;
|
||||
property ProjectType: TProjectType read fProjectType write fProjectType;
|
||||
property RunParameterOptions: TRunParamsOptions read fRunParameterOptions;
|
||||
property TargetFileExt: String read fTargetFileExt write fTargetFileExt;
|
||||
property TargetFilename: string read GetTargetFilename write SetTargetFilename;
|
||||
property Title: String read fTitle write fTitle;
|
||||
@ -293,7 +296,10 @@ const
|
||||
// ptApplication
|
||||
'Application'#13
|
||||
+'A graphical lcl/freepascal program. The program file is '
|
||||
+'automatically maintained by lazarus.'
|
||||
+'automatically maintained by lazarus.'#13
|
||||
+#13
|
||||
+'WARNING:'#13
|
||||
+'Form editing is under development and should not be used.'
|
||||
|
||||
// ptProgram
|
||||
,'Program:'#13
|
||||
@ -862,7 +868,7 @@ begin
|
||||
inherited Create;
|
||||
|
||||
Assert(False, 'Trace:Project Class Created');
|
||||
XMLCfg := nil;
|
||||
xmlconfig := nil;
|
||||
|
||||
fProjectType:=TheProjectType;
|
||||
|
||||
@ -874,6 +880,7 @@ begin
|
||||
fModified := false;
|
||||
fOutputDirectory := '.';
|
||||
fProjectFile := '';
|
||||
fRunParameterOptions:=TRunParamsOptions.Create;
|
||||
fTargetFileExt := DefaultTargetFileExt;
|
||||
fTitle := '';
|
||||
fUnitList := TList.Create; // list of TUnitInfo
|
||||
@ -928,8 +935,9 @@ destructor TProject.Destroy;
|
||||
begin
|
||||
Clear;
|
||||
fBookmarks.Free;
|
||||
if (XMLCfg <> nil) then XMLCfg.Free;
|
||||
if (xmlconfig <> nil) then xmlconfig.Free;
|
||||
fUnitList.Free;
|
||||
fRunParameterOptions.Free;
|
||||
fCompilerOptions.Free;
|
||||
|
||||
inherited Destroy;
|
||||
@ -951,39 +959,42 @@ begin
|
||||
Result:=fOnFileBackup(confPath,true);
|
||||
if Result=mrAbort then exit;
|
||||
end;
|
||||
xmlcfg := TXMLConfig.Create(SetDirSeparators(confPath));
|
||||
xmlconfig := TXMLConfig.Create(SetDirSeparators(confPath));
|
||||
|
||||
try
|
||||
repeat
|
||||
try
|
||||
xmlcfg.SetValue('ProjectOptions/General/ProjectType/Value',
|
||||
xmlconfig.SetValue('ProjectOptions/General/ProjectType/Value',
|
||||
ProjectTypeNames[ProjectType]);
|
||||
xmlcfg.SetValue('ProjectOptions/General/MainUnit/Value', MainUnit);
|
||||
xmlcfg.SetValue('ProjectOptions/General/ActiveEditorIndexAtStart/Value'
|
||||
xmlconfig.SetValue('ProjectOptions/General/MainUnit/Value', MainUnit);
|
||||
xmlconfig.SetValue('ProjectOptions/General/ActiveEditorIndexAtStart/Value'
|
||||
,ActiveEditorIndexAtStart);
|
||||
xmlcfg.SetValue('ProjectOptions/General/IconPath/Value', IconPath);
|
||||
xmlcfg.SetValue('ProjectOptions/General/TargetFileExt/Value'
|
||||
xmlconfig.SetValue('ProjectOptions/General/IconPath/Value', IconPath);
|
||||
xmlconfig.SetValue('ProjectOptions/General/TargetFileExt/Value'
|
||||
,TargetFileExt);
|
||||
xmlcfg.SetValue('ProjectOptions/General/Title/Value', Title);
|
||||
xmlcfg.SetValue('ProjectOptions/General/OutputDirectory/Value'
|
||||
xmlconfig.SetValue('ProjectOptions/General/Title/Value', Title);
|
||||
xmlconfig.SetValue('ProjectOptions/General/OutputDirectory/Value'
|
||||
,OutputDirectory);
|
||||
xmlcfg.SetValue('ProjectOptions/General/UnitOutputDirectory/Value'
|
||||
xmlconfig.SetValue('ProjectOptions/General/UnitOutputDirectory/Value'
|
||||
,UnitOutputDirectory);
|
||||
fBookmarks.SaveToXMLConfig(xmlcfg,'ProjectOptions/');
|
||||
fBookmarks.SaveToXMLConfig(xmlconfig,'ProjectOptions/');
|
||||
|
||||
// Set options for each Unit
|
||||
xmlcfg.SetValue('ProjectOptions/Units/Count',UnitCount);
|
||||
xmlconfig.SetValue('ProjectOptions/Units/Count',UnitCount);
|
||||
for i := 0 to UnitCount - 1 do begin
|
||||
Units[i].SaveToXMLConfig(
|
||||
xmlcfg,'ProjectOptions/Units/Unit'+IntToStr(i)+'/');
|
||||
xmlconfig,'ProjectOptions/Units/Unit'+IntToStr(i)+'/');
|
||||
end;
|
||||
|
||||
// Save the compiler options
|
||||
CompilerOptions.XMLConfigFile := xmlcfg;
|
||||
CompilerOptions.XMLConfigFile := xmlconfig;
|
||||
CompilerOptions.ProjectFile := confPath;
|
||||
CompilerOptions.SaveCompilerOptions(true);
|
||||
|
||||
// save the Run Parameter Options
|
||||
RunParameterOptions.Save(xmlconfig,'ProjectOptions/');
|
||||
|
||||
xmlcfg.Flush;
|
||||
xmlconfig.Flush;
|
||||
Modified:=false;
|
||||
except
|
||||
ACaption:='Write error';
|
||||
@ -994,8 +1005,8 @@ begin
|
||||
end;
|
||||
until Result<>mrRetry;
|
||||
finally
|
||||
xmlcfg.Free;
|
||||
xmlcfg:=nil;
|
||||
xmlconfig.Free;
|
||||
xmlconfig:=nil;
|
||||
end;
|
||||
Result := mrOk;
|
||||
end;
|
||||
@ -1013,46 +1024,49 @@ begin
|
||||
|
||||
ProjectInfoFile:=LPIFilename;
|
||||
try
|
||||
xmlcfg := TXMLConfig.Create(ProjectInfoFile);
|
||||
xmlconfig := TXMLConfig.Create(ProjectInfoFile);
|
||||
except
|
||||
MessageDlg('Unable to read the project info file "'+ProjectInfoFile+'".'
|
||||
MessageDlg('Unable to read the project info file'#13'"'+ProjectInfoFile+'".'
|
||||
,mtError,[mbOk],0);
|
||||
Result:=mrCancel;
|
||||
exit;
|
||||
end;
|
||||
|
||||
try
|
||||
ProjectType := ProjectTypeNameToType(xmlcfg.GetValue(
|
||||
ProjectType := ProjectTypeNameToType(xmlconfig.GetValue(
|
||||
'ProjectOptions/General/ProjectType/Value', ''));
|
||||
MainUnit := xmlcfg.GetValue('ProjectOptions/General/MainUnit/Value', -1);
|
||||
ActiveEditorIndexAtStart := xmlcfg.GetValue(
|
||||
MainUnit := xmlconfig.GetValue('ProjectOptions/General/MainUnit/Value', -1);
|
||||
ActiveEditorIndexAtStart := xmlconfig.GetValue(
|
||||
'ProjectOptions/General/ActiveEditorIndexAtStart/Value', -1);
|
||||
IconPath := xmlcfg.GetValue('ProjectOptions/General/IconPath/Value', './');
|
||||
TargetFileExt := xmlcfg.GetValue(
|
||||
IconPath := xmlconfig.GetValue('ProjectOptions/General/IconPath/Value', './');
|
||||
TargetFileExt := xmlconfig.GetValue(
|
||||
'ProjectOptions/General/TargetFileExt/Value', DefaultTargetFileExt);
|
||||
Title := xmlcfg.GetValue('ProjectOptions/General/Title/Value', '');
|
||||
OutputDirectory := xmlcfg.GetValue(
|
||||
Title := xmlconfig.GetValue('ProjectOptions/General/Title/Value', '');
|
||||
OutputDirectory := xmlconfig.GetValue(
|
||||
'ProjectOptions/General/OutputDirectory/Value', '.');
|
||||
UnitOutputDirectory := xmlcfg.GetValue(
|
||||
UnitOutputDirectory := xmlconfig.GetValue(
|
||||
'ProjectOptions/General/UnitOutputDirectory/Value', '.');
|
||||
fBookmarks.LoadFromXMLConfig(xmlcfg,'ProjectOptions/');
|
||||
fBookmarks.LoadFromXMLConfig(xmlconfig,'ProjectOptions/');
|
||||
|
||||
NewUnitCount:=xmlcfg.GetValue('ProjectOptions/Units/Count',0);
|
||||
NewUnitCount:=xmlconfig.GetValue('ProjectOptions/Units/Count',0);
|
||||
for i := 0 to NewUnitCount - 1 do begin
|
||||
NewUnitInfo:=TUnitInfo.Create(nil);
|
||||
AddUnit(NewUnitInfo,false);
|
||||
NewUnitInfo.LoadFromXMLConfig(
|
||||
xmlcfg,'ProjectOptions/Units/Unit'+IntToStr(i)+'/');
|
||||
xmlconfig,'ProjectOptions/Units/Unit'+IntToStr(i)+'/');
|
||||
end;
|
||||
|
||||
// Load the compiler options
|
||||
CompilerOptions.XMLConfigFile := xmlcfg;
|
||||
CompilerOptions.XMLConfigFile := xmlconfig;
|
||||
CompilerOptions.ProjectFile := ProjectFile;
|
||||
CompilerOptions.LoadCompilerOptions(true);
|
||||
|
||||
// load the Run Parameter Options
|
||||
RunParameterOptions.Load(xmlconfig,'ProjectOptions/');
|
||||
|
||||
finally
|
||||
xmlcfg.Free;
|
||||
xmlcfg:=nil;
|
||||
xmlconfig.Free;
|
||||
xmlconfig:=nil;
|
||||
end;
|
||||
|
||||
Result := mrOk;
|
||||
@ -1123,11 +1137,13 @@ end;
|
||||
procedure TProject.Clear;
|
||||
var i:integer;
|
||||
begin
|
||||
if XMLCfg<>nil then XMLCfg.Free;
|
||||
XMLCfg:=nil;
|
||||
if xmlconfig<>nil then xmlconfig.Free;
|
||||
xmlconfig:=nil;
|
||||
|
||||
for i:=0 to UnitCount-1 do Units[i].Free;
|
||||
fUnitList.Clear;
|
||||
|
||||
fRunParameterOptions.Clear;
|
||||
|
||||
fActiveEditorIndexAtStart := -1;
|
||||
fBookmarks.Clear;
|
||||
@ -1469,7 +1485,6 @@ begin
|
||||
if (OldUnitName<>'') and (ProjectType in [ptProgram, ptApplication]) then
|
||||
begin
|
||||
// rename unit in program uses section
|
||||
writeln('TProject.OnUnitNameChange A');
|
||||
CodeToolBoss.RenameUsedUnit(Units[MainUnit].Source
|
||||
,OldUnitName,NewUnitName,'');
|
||||
end;
|
||||
@ -1489,6 +1504,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.35 2001/11/06 12:20:33 lazarus
|
||||
MG: added Run Parameter Options - not enabled yet
|
||||
|
||||
Revision 1.34 2001/11/05 18:18:18 lazarus
|
||||
added popupmenu+arrows to notebooks, added target filename
|
||||
|
||||
|
@ -109,8 +109,6 @@ begin
|
||||
SetupFormsPage;
|
||||
SetupApplicationPage;
|
||||
|
||||
NoteBook.Show;
|
||||
|
||||
CancelButton:=TButton.Create(Self);
|
||||
with CancelButton do begin
|
||||
Name:='CancelButton';
|
||||
|
543
ide/runparamsopts.pas
Normal file
543
ide/runparamsopts.pas
Normal file
@ -0,0 +1,543 @@
|
||||
{
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
Author: Mattias Gaertner
|
||||
|
||||
Abstract:
|
||||
Run Parameters Options (TRunParamsOptions)
|
||||
and Dialog for them (TRunParamsOptsDlg)
|
||||
|
||||
Run Parameters are project specific options for the debugger like
|
||||
command line parameters and working directory.
|
||||
|
||||
The options saved in a TRunParamsOptions are stored in the project info file
|
||||
(.lpi) together with the rest of the project.
|
||||
|
||||
The dialog will be activated by main.pp with the function
|
||||
ShowRunParamsOptsDlg (see below) when the user clicks on the
|
||||
menu->Run->Run Parameters.
|
||||
}
|
||||
unit RunParamsOpts;
|
||||
|
||||
{$mode objfpc}
|
||||
{$H+}
|
||||
|
||||
{$I ide.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF IDE_MEM_CHECK}
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, Controls, Forms, Buttons, StdCtrls, ComCtrls, Dialogs,
|
||||
ExtCtrls, LResources, XMLCfg;
|
||||
|
||||
{ The xml format version:
|
||||
When the format changes (new values, changed formats) we can distinguish old
|
||||
files and are able to convert them.
|
||||
}
|
||||
const RunParamsOptionsVersion = '1.0';
|
||||
|
||||
type
|
||||
{
|
||||
the storage object for run parameters
|
||||
}
|
||||
TRunParamsOptions = class
|
||||
private
|
||||
// local options
|
||||
fHostApplicationFilename: string;
|
||||
fCmdLineParams: string;
|
||||
fUseLaunchingApplication: boolean;
|
||||
fLaunchingApplicationPathPlusParams: string;
|
||||
fWorkingDirectory: string;
|
||||
fDisplay: string;
|
||||
|
||||
// environment options
|
||||
fUserOverrides: TStringList;
|
||||
fIncludeSystemVariables: boolean;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure Clear;
|
||||
function Load(XMLConfig: TXMLConfig; const Path: string): TModalResult;
|
||||
function Save(XMLConfig: TXMLConfig; const Path: string): TModalResult;
|
||||
|
||||
// local options
|
||||
property HostApplicationFilename: string
|
||||
read fHostApplicationFilename write fHostApplicationFilename;
|
||||
property CmdLineParams: string read fCmdLineParams write fCmdLineParams;
|
||||
property UseLaunchingApplication: boolean
|
||||
read fUseLaunchingApplication write fUseLaunchingApplication;
|
||||
property LaunchingApplicationPathPlusParams: string
|
||||
read fLaunchingApplicationPathPlusParams
|
||||
write fLaunchingApplicationPathPlusParams;
|
||||
property WorkingDirectory: string
|
||||
read fWorkingDirectory write fWorkingDirectory;
|
||||
property Display: string read fDisplay write fDisplay;
|
||||
|
||||
// environment options
|
||||
property UserOverrides: TStringList read fUserOverrides;
|
||||
property IncludeSystemVariables: boolean
|
||||
read fIncludeSystemVariables write fIncludeSystemVariables;
|
||||
end;
|
||||
|
||||
{
|
||||
TRunParamsOptsDlg is the form of the run parameters options dialog
|
||||
}
|
||||
TRunParamsOptsDlg = class(TForm)
|
||||
Notebook: TNotebook;
|
||||
HostApplicationGroupBox: TGroupBox;
|
||||
HostApplicationEdit: TEdit;
|
||||
HostApplicationBrowseBtn: TBitBtn;
|
||||
CmdLineParametersGroupBox: TGroupBox;
|
||||
CmdLineParametersEdit: TEdit;
|
||||
UseLaunchingApplicationBevel: TBevel;
|
||||
UseLaunchingApplicationCheckBox: TCheckBox;
|
||||
UseLaunchingApplicationEdit: TEdit;
|
||||
WorkingDirectoryGroupBox: TGroupBox;
|
||||
WorkingDirectoryEdit: TEdit;
|
||||
WorkingDirectoryBtn: TBitBtn;
|
||||
DisplayGroupBox: TGroupBox;
|
||||
DisplayEdit: TEdit;
|
||||
SystemVariablesGroupBox: TGroupBox;
|
||||
UserOverridesGroupBox: TGroupBox;
|
||||
IncludeSystemVariablesCheckBox: TCheckBox;
|
||||
OkButton: TButton;
|
||||
CancelButton: TButton;
|
||||
procedure OkButtonClick(Sender: TObject);
|
||||
procedure CancelButtonClick(Sender: TObject);
|
||||
private
|
||||
fOptions: TRunParamsOptions;
|
||||
procedure SetupNotebook;
|
||||
procedure SetupLocalPage;
|
||||
procedure SetupEnvironmentPage;
|
||||
procedure SetOptions(NewOptions: TRunParamsOptions);
|
||||
procedure SaveToOptions;
|
||||
public
|
||||
constructor Create(AnOwner: TComponent); override;
|
||||
property Options: TRunParamsOptions read fOptions write SetOptions;
|
||||
end;
|
||||
|
||||
|
||||
function ShowRunParamsOptsDlg(RunParamsOptions: TRunParamsOptions):TModalResult;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
function ShowRunParamsOptsDlg(RunParamsOptions: TRunParamsOptions):TModalResult;
|
||||
var
|
||||
RunParamsOptsForm: TRunParamsOptsDlg;
|
||||
begin
|
||||
Result:=mrCancel;
|
||||
RunParamsOptsForm:=TRunParamsOptsDlg.Create(Application);
|
||||
try
|
||||
RunParamsOptsForm.Options:=RunParamsOptions;
|
||||
Result:=RunParamsOptsForm.ShowModal;
|
||||
finally
|
||||
RunParamsOptsForm.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{ TRunParamsOptions }
|
||||
|
||||
constructor TRunParamsOptions.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
fUserOverrides:=TStringList.Create;
|
||||
Clear;
|
||||
end;
|
||||
|
||||
destructor TRunParamsOptions.Destroy;
|
||||
begin
|
||||
fUserOverrides.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TRunParamsOptions.Clear;
|
||||
begin
|
||||
// local options
|
||||
fHostApplicationFilename:='';
|
||||
fCmdLineParams:='';
|
||||
fUseLaunchingApplication:=false;
|
||||
fLaunchingApplicationPathPlusParams:='';
|
||||
fWorkingDirectory:='';
|
||||
fDisplay:=':0';
|
||||
|
||||
// environment options
|
||||
fUserOverrides.Clear;
|
||||
fIncludeSystemVariables:=false;
|
||||
end;
|
||||
|
||||
function TRunParamsOptions.Load(XMLConfig: TXMLConfig;
|
||||
const Path: string): TModalResult;
|
||||
|
||||
procedure LoadUserOverrides(const APath: string);
|
||||
var i, Cnt: integer;
|
||||
begin
|
||||
fUserOverrides.Clear;
|
||||
Cnt:=XMLConfig.GetValue(APath+'/Count',0);
|
||||
for i:=0 to Cnt-1 do begin
|
||||
fUserOverrides.Values[XMLConfig.GetValue(
|
||||
APath+'/Variable'+IntToStr(i)+'/Name','')]:=
|
||||
XMLConfig.GetValue(APath+'/Variable'+IntToStr(i)+'/Value','');
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
// local options
|
||||
fHostApplicationFilename:=XMLConfig.GetValue(
|
||||
Path+'RunParams/local/HostApplicationFilename/Value',
|
||||
fHostApplicationFilename);
|
||||
fCmdLineParams:=XMLConfig.GetValue(
|
||||
Path+'RunParams/local/CommandLineParams/Value',
|
||||
fCmdLineParams);
|
||||
fUseLaunchingApplication:=XMLConfig.GetValue(
|
||||
Path+'RunParams/local/LaunchingApplication/Use',
|
||||
fUseLaunchingApplication);
|
||||
fLaunchingApplicationPathPlusParams:=XMLConfig.GetValue(
|
||||
Path+'RunParams/local/LaunchingApplication/PathPlusParams',
|
||||
fLaunchingApplicationPathPlusParams);
|
||||
fWorkingDirectory:=XMLConfig.GetValue(
|
||||
Path+'RunParams/local/WorkingDirectory/Value',
|
||||
fWorkingDirectory);
|
||||
fDisplay:=XMLConfig.GetValue(
|
||||
Path+'RunParams/local/Display/Value',
|
||||
fDisplay);
|
||||
|
||||
// environment options
|
||||
LoadUserOverrides(Path+'RunParams/environment/UserOverrides/');
|
||||
fIncludeSystemVariables:=XMLConfig.GetValue(
|
||||
Path+'RunParams/environment/IncludeSystemVariables/Value',
|
||||
fIncludeSystemVariables);
|
||||
|
||||
Result:=mrOk;
|
||||
end;
|
||||
|
||||
function TRunParamsOptions.Save(XMLConfig: TXMLConfig;
|
||||
const Path: string): TModalResult;
|
||||
|
||||
procedure SaveUserOverrides(const APath: string);
|
||||
var i: integer;
|
||||
begin
|
||||
XMLConfig.SetValue(APath+'/Count',fUserOverrides.Count);
|
||||
for i:=0 to fUserOverrides.Count-1 do begin
|
||||
XMLConfig.SetValue(APath+'/Variable'+IntToStr(i)+'/Name',
|
||||
fUserOverrides.Names[i]);
|
||||
XMLConfig.SetValue(APath+'/Variable'+IntToStr(i)+'/Value',
|
||||
fUserOverrides.Values[fUserOverrides.Names[i]]);
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
// save a format version to distinguish old formats
|
||||
XMLConfig.SetValue(Path+'RunParams/local/FormatVersion/Value',
|
||||
RunParamsOptionsVersion);
|
||||
|
||||
// local options
|
||||
XMLConfig.SetValue(Path+'RunParams/local/HostApplicationFilename/Value',
|
||||
fHostApplicationFilename);
|
||||
XMLConfig.SetValue(Path+'RunParams/local/CommandLineParams/Value',
|
||||
fCmdLineParams);
|
||||
XMLConfig.SetValue(Path+'RunParams/local/LaunchingApplication/Use',
|
||||
fUseLaunchingApplication);
|
||||
XMLConfig.SetValue(Path+'RunParams/local/LaunchingApplication/PathPlusParams',
|
||||
fLaunchingApplicationPathPlusParams);
|
||||
XMLConfig.SetValue(Path+'RunParams/local/WorkingDirectory/Value',
|
||||
fWorkingDirectory);
|
||||
XMLConfig.SetValue(Path+'RunParams/local/Display/Value',
|
||||
fDisplay);
|
||||
|
||||
// environment options
|
||||
SaveUserOverrides(Path+'RunParams/environment/UserOverrides/');
|
||||
XMLConfig.SetValue(Path+'RunParams/environment/IncludeSystemVariables/Value',
|
||||
fIncludeSystemVariables);
|
||||
|
||||
Result:=mrOk;
|
||||
end;
|
||||
|
||||
|
||||
{ TRunParamsOptsDlg }
|
||||
|
||||
constructor TRunParamsOptsDlg.Create(AnOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AnOwner);
|
||||
if LazarusResources.Find(ClassName)=nil then begin
|
||||
|
||||
Caption:='Run parameters';
|
||||
SetBounds((Screen.Width-500) div 2,(Screen.Height-450) div 2,500,450);
|
||||
|
||||
SetupNotebook;
|
||||
|
||||
OkButton:=TButton.Create(Self);
|
||||
with OkButton do begin
|
||||
Name:='OkButton';
|
||||
Parent:=Self;
|
||||
SetBounds(270,Self.ClientHeight-40,100,25);
|
||||
Caption:='Ok';
|
||||
OnClick:=@OkButtonClick;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
CancelButton:=TButton.Create(Self);
|
||||
with CancelButton do begin
|
||||
Name:='CancelButton';
|
||||
Parent:=Self;
|
||||
SetBounds(390,OkButton.Top,100,25);
|
||||
Caption:='Cancel';
|
||||
OnClick:=@CancelButtonClick;
|
||||
Visible:=true;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRunParamsOptsDlg.SetupNotebook;
|
||||
// create the notebook
|
||||
begin
|
||||
Notebook:=TNotebook.Create(Self);
|
||||
with Notebook do begin
|
||||
Name:='Notebook';
|
||||
Parent:=Self;
|
||||
SetBounds(0,0,Self.ClientWidth,Self.ClientHeight-50);
|
||||
Pages[0]:='Local';
|
||||
Pages.Add('Environment');
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
SetupLocalPage;
|
||||
SetupEnvironmentPage;
|
||||
end;
|
||||
|
||||
procedure TRunParamsOptsDlg.SetupLocalPage;
|
||||
var w: integer;
|
||||
begin
|
||||
w:=Self.ClientWidth-15;
|
||||
|
||||
HostApplicationGroupBox:=TGroupBox.Create(Self);
|
||||
with HostApplicationGroupBox do begin
|
||||
Name:='HostApplicationGroupBox';
|
||||
Parent:=NoteBook.Page[0];
|
||||
SetBounds(5,5,w,60);
|
||||
Caption:='Host application';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
HostApplicationEdit:=TEdit.Create(Self);
|
||||
with HostApplicationEdit do begin
|
||||
Name:='HostApplicationEdit';
|
||||
Parent:=HostApplicationGroupBox;
|
||||
SetBounds(5,5,w-10-35,25);
|
||||
Caption:='';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
HostApplicationBrowseBtn:=TBitBtn.Create(Self);
|
||||
with HostApplicationBrowseBtn do begin
|
||||
Name:='HostApplicationBrowseBtn';
|
||||
Parent:=HostApplicationGroupBox;
|
||||
SetBounds(HostApplicationEdit.Left+HostApplicationEdit.Width+2,5,25,25);
|
||||
Caption:='...';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
CmdLineParametersGroupBox:=TGroupBox.Create(Self);
|
||||
with CmdLineParametersGroupBox do begin
|
||||
Name:='CmdLineParametersGroupBox';
|
||||
Parent:=NoteBook.Page[0];
|
||||
SetBounds(5,HostApplicationGroupBox.Top+HostApplicationGroupBox.Height+5,
|
||||
w,60);
|
||||
Caption:='Command line parameters (without application name)';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
CmdLineParametersEdit:=TEdit.Create(Self);
|
||||
with CmdLineParametersEdit do begin
|
||||
Name:='CmdLineParametersEdit';
|
||||
Parent:=CmdLineParametersGroupBox;
|
||||
SetBounds(5,5,w-15,25);
|
||||
Caption:='';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
UseLaunchingApplicationBevel:=TBevel.Create(Self);
|
||||
with UseLaunchingApplicationBevel do begin
|
||||
Name:='UseLaunchingApplicationBevel';
|
||||
Parent:=NoteBook.Page[0];
|
||||
SetBounds(
|
||||
5,CmdLineParametersGroupBox.Top+CmdLineParametersGroupBox.Height+10,w,60);
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
UseLaunchingApplicationCheckBox:=TCheckBox.Create(Self);
|
||||
with UseLaunchingApplicationCheckBox do begin
|
||||
Name:='UseLaunchingApplicationCheckBox';
|
||||
Parent:=NoteBook.Page[0];
|
||||
SetBounds(UseLaunchingApplicationBevel.Left+10,
|
||||
UseLaunchingApplicationBevel.Top,100,25);
|
||||
Caption:='Use launching application';
|
||||
Checked:=false;
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
UseLaunchingApplicationEdit:=TEdit.Create(Self);
|
||||
with UseLaunchingApplicationEdit do begin
|
||||
Name:='UseLaunchingApplicationEdit';
|
||||
Parent:=NoteBook.Page[0];
|
||||
SetBounds(UseLaunchingApplicationBevel.Left+5,
|
||||
UseLaunchingApplicationBevel.Top+25,w-15,25);
|
||||
Caption:='';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
WorkingDirectoryGroupBox:=TGroupBox.Create(Self);
|
||||
with WorkingDirectoryGroupBox do begin
|
||||
Name:='WorkingDirectoryGroupBox';
|
||||
Parent:=NoteBook.Page[0];
|
||||
SetBounds(5,UseLaunchingApplicationBevel.Top
|
||||
+UseLaunchingApplicationBevel.Height+10,w,60);
|
||||
Caption:='Working directory';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
WorkingDirectoryEdit:=TEdit.Create(Self);
|
||||
with WorkingDirectoryEdit do begin
|
||||
Name:='WorkingDirectoryEdit';
|
||||
Parent:=WorkingDirectoryGroupBox;
|
||||
SetBounds(5,5,w-10-35,25);
|
||||
Caption:='';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
WorkingDirectoryBtn:=TBitBtn.Create(Self);
|
||||
with WorkingDirectoryBtn do begin
|
||||
Name:='WorkingDirectoryBtn';
|
||||
Parent:=WorkingDirectoryGroupBox;
|
||||
SetBounds(WorkingDirectoryEdit.Left+WorkingDirectoryEdit.Width+2,5,25,25);
|
||||
Caption:='...';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
DisplayGroupBox:=TGroupBox.Create(Self);
|
||||
with DisplayGroupBox do begin
|
||||
Name:='DisplayGroupBox';
|
||||
Parent:=NoteBook.Page[0];
|
||||
SetBounds(5,WorkingDirectoryGroupBox.Top+WorkingDirectoryGroupBox.Height+10,
|
||||
w,60);
|
||||
Caption:='Display (not for win32)';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
DisplayEdit:=TEdit.Create(Self);
|
||||
with DisplayEdit do begin
|
||||
Name:='DisplayEdit';
|
||||
Parent:=DisplayGroupBox;
|
||||
SetBounds(5,5,w-15,25);
|
||||
Caption:='';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRunParamsOptsDlg.SetupEnvironmentPage;
|
||||
var w: integer;
|
||||
begin
|
||||
w:=Self.ClientWidth-15;
|
||||
|
||||
SystemVariablesGroupBox:=TGroupBox.Create(Self);
|
||||
with SystemVariablesGroupBox do begin
|
||||
Name:='SystemVariablesGroupBox';
|
||||
Parent:=NoteBook.Page[1];
|
||||
SetBounds(5,5,w,150);
|
||||
Caption:='System variables';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
UserOverridesGroupBox:=TGroupBox.Create(Self);
|
||||
with UserOverridesGroupBox do begin
|
||||
Name:='UserOverridesGroupBox';
|
||||
Parent:=NoteBook.Page[1];
|
||||
SetBounds(5,SystemVariablesGroupBox.Top+SystemVariablesGroupBox.Height+10,
|
||||
w,150);
|
||||
Caption:='User overrides';
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
IncludeSystemVariablesCheckBox:=TCheckBox.Create(Self);
|
||||
with IncludeSystemVariablesCheckBox do begin
|
||||
Name:='IncludeSystemVariablesCheckBox';
|
||||
Parent:=NoteBook.Page[1];
|
||||
SetBounds(5,UserOverridesGroupBox.Top+UserOverridesGroupBox.Height+10,w,25);
|
||||
Caption:='Include system variables';
|
||||
Checked:=false;
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRunParamsOptsDlg.OkButtonClick(Sender: TObject);
|
||||
begin
|
||||
SaveToOptions;
|
||||
ModalResult:=mrOk;
|
||||
end;
|
||||
|
||||
procedure TRunParamsOptsDlg.CancelButtonClick(Sender: TObject);
|
||||
begin
|
||||
ModalResult:=mrCancel;
|
||||
end;
|
||||
|
||||
procedure TRunParamsOptsDlg.SaveToOptions;
|
||||
begin
|
||||
// local
|
||||
fOptions.HostApplicationFilename:=HostApplicationEdit.Text;
|
||||
fOptions.CmdLineParams:=CmdLineParametersEdit.Text;
|
||||
fOptions.UseLaunchingApplication:=UseLaunchingApplicationCheckBox.Checked;
|
||||
fOptions.LaunchingApplicationPathPlusParams:=UseLaunchingApplicationEdit.Text;
|
||||
fOptions.WorkingDirectory:=WorkingDirectoryEdit.Text;
|
||||
fOptions.Display:=DisplayEdit.Text;
|
||||
|
||||
// environment
|
||||
fOptions.IncludeSystemVariables:=IncludeSystemVariablesCheckBox.Checked;
|
||||
end;
|
||||
|
||||
procedure TRunParamsOptsDlg.SetOptions(NewOptions: TRunParamsOptions);
|
||||
begin
|
||||
fOptions:=NewOptions;
|
||||
|
||||
// local
|
||||
HostApplicationEdit.Text:=fOptions.HostApplicationFilename;
|
||||
CmdLineParametersEdit.Text:=fOptions.CmdLineParams;
|
||||
UseLaunchingApplicationCheckBox.Checked:=fOptions.UseLaunchingApplication;
|
||||
UseLaunchingApplicationEdit.Text:=fOptions.LaunchingApplicationPathPlusParams;
|
||||
WorkingDirectoryEdit.Text:=fOptions.WorkingDirectory;
|
||||
DisplayEdit.Text:=fOptions.Display;
|
||||
|
||||
// environment
|
||||
IncludeSystemVariablesCheckBox.Checked:=fOptions.IncludeSystemVariables;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
Loading…
Reference in New Issue
Block a user