From 7f4da47cd58f6c21e065c446b9500c5bedb1b5ba Mon Sep 17 00:00:00 2001 From: lazarus Date: Sun, 18 Aug 2002 08:53:30 +0000 Subject: [PATCH] MG: implemented run param environment variables git-svn-id: trunk@2750 - --- debugger/cmdlinedebugger.pp | 4 ++ debugger/debugger.pp | 13 +++++ ide/debugmanager.pas | 1 + ide/main.pp | 6 ++- ide/runparamsopts.pas | 97 +++++++++++++++++++++------------- lcl/include/customlistview.inc | 7 +++ 6 files changed, 91 insertions(+), 37 deletions(-) diff --git a/debugger/cmdlinedebugger.pp b/debugger/cmdlinedebugger.pp index cdaa0a7801..a71b86e36b 100644 --- a/debugger/cmdlinedebugger.pp +++ b/debugger/cmdlinedebugger.pp @@ -173,6 +173,7 @@ begin FDbgProcess.CommandLine := ExternalDebugger + ' ' + AOptions; FDbgProcess.Options:= [poUsePipes, poNoConsole, poStdErrToOutPut]; FDbgProcess.ShowWindow := swoNone; + //FDbgProcess.Environment:=Environment; end; if not FDbgProcess.Running then begin @@ -361,6 +362,9 @@ end; end. { ============================================================================= $Log$ + Revision 1.12 2002/08/28 10:44:44 lazarus + MG: implemented run param environment variables + Revision 1.11 2002/05/10 06:57:47 lazarus MG: updated licenses diff --git a/debugger/debugger.pp b/debugger/debugger.pp index ddc0e187fd..42c7f4ac9c 100644 --- a/debugger/debugger.pp +++ b/debugger/debugger.pp @@ -348,6 +348,7 @@ type FArguments: String; FBreakPoints: TDBGBreakPoints; FBreakPointGroups: TDBGBreakPointGroups; + FEnvironment: TStrings; FExitCode: Integer; FExternalDebugger: String; FFileName: String; @@ -362,6 +363,7 @@ type FOnState: TNotifyEvent; function GetState: TDBGState; function ReqCmd(const ACommand: TDBGCommand; const AParams: array of const): Boolean; + procedure SetEnvironment(const AValue: TStrings); procedure SetFileName(const AValue: String); protected function CreateBreakPoints: TDBGBreakPoints; virtual; @@ -403,6 +405,7 @@ type property BreakPointGroups: TDBGBreakPointGroups read FBreakPointGroups; // list of all breakpointgroups property Commands: TDBGCommands read GetCommands; // All current available commands of the debugger property CallStack: TDBGCallStack read FCallStack; + property Environment: TStrings read FEnvironment write SetEnvironment; property ExitCode: Integer read FExitCode; property ExternalDebugger: String read FExternalDebugger; property FileName: String read FFileName write SetFileName; // The name of the exe to be debugged @@ -457,6 +460,7 @@ begin FWatches := CreateWatches; FBreakPointGroups := TDBGBreakPointGroups.Create; FExitCode := 0; + FEnvironment:=TStringList.Create; end; function TDebugger.CreateBreakPoints: TDBGBreakPoints; @@ -500,6 +504,7 @@ begin FreeAndNil(FLocals); FreeAndNil(FCallStack); FreeAndNil(FWatches); + FreeAndNil(FEnvironment); inherited; end; @@ -583,6 +588,11 @@ begin else Result := False; end; +procedure TDebugger.SetEnvironment(const AValue: TStrings); +begin + FEnvironment.Assign(AValue); +end; + procedure TDebugger.Run; begin ReqCmd(dcRun, []); @@ -1461,6 +1471,9 @@ end; end. { ============================================================================= $Log$ + Revision 1.16 2002/08/28 10:44:44 lazarus + MG: implemented run param environment variables + Revision 1.15 2002/05/10 06:57:47 lazarus MG: updated licenses diff --git a/ide/debugmanager.pas b/ide/debugmanager.pas index 5d3b1b7420..5ed4e2fef5 100644 --- a/ide/debugmanager.pas +++ b/ide/debugmanager.pas @@ -463,6 +463,7 @@ begin FDebugger.FileName := LaunchingApplication; FDebugger.Arguments := LaunchingParams; + Project1.RunParameterOptions.AssignEnvironmentTo(FDebugger.Environment); if FDialogs[ddtOutput] <> nil then TDbgOutputForm(FDialogs[ddtOutput]).Clear; diff --git a/ide/main.pp b/ide/main.pp index dcf4d165ac..9106487728 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -4636,7 +4636,8 @@ begin WorkingDir:=ExtractFilePath(GetProjectTargetFilename); MacroList.SubstituteStr(WorkingDir); FRunProcess.CurrentDirectory:=ExpandFilename(WorkingDir); - + Project1.RunParameterOptions.AssignEnvironmentTo(FRunProcess.Environment); + FRunProcess.Options:= [poNoConsole]; FRunProcess.ShowWindow := swoNone; except @@ -6702,6 +6703,9 @@ end. { ============================================================================= $Log$ + Revision 1.355 2002/08/28 10:44:43 lazarus + MG: implemented run param environment variables + Revision 1.354 2002/08/27 09:22:44 lazarus MG: not existing files will now be removed from recent lists diff --git a/ide/runparamsopts.pas b/ide/runparamsopts.pas index bc830571e5..228a9740e1 100644 --- a/ide/runparamsopts.pas +++ b/ide/runparamsopts.pas @@ -80,6 +80,7 @@ type procedure Clear; function Load(XMLConfig: TXMLConfig; const Path: string): TModalResult; function Save(XMLConfig: TXMLConfig; const Path: string): TModalResult; + procedure AssignEnvironmentTo(Strings: TStrings); // local options property HostApplicationFilename: string @@ -146,6 +147,7 @@ type procedure ResizeLocalPage; procedure ResizeEnvironmentPage; procedure SetOptions(NewOptions: TRunParamsOptions); + procedure FillListView(ListView: TListView; sl: TStringList); procedure FillSystemVariablesListView; procedure FillUserOverridesListView; procedure SaveToOptions; @@ -182,7 +184,22 @@ begin end; end; - +function EnvironmentAsStringList: TStringList; +var + i, SysVarCount, e: integer; + Variable, Value: string; +Begin + Result:=TStringList.Create; + SysVarCount:=EnvCount; + for i:=0 to SysVarCount-1 do begin + Variable:=EnvStr(i+1); + e:=1; + while (e<=length(Variable)) and (Variable[e]<>'=') do inc(e); + Value:=copy(Variable,e+1,length(Variable)-e); + Variable:=LeftStr(Variable,e-1); + Result.Values[Variable]:=Value; + end; +end; { TRunParamsOptions } @@ -303,6 +320,27 @@ begin Result:=mrOk; end; +procedure TRunParamsOptions.AssignEnvironmentTo(Strings: TStrings); +var + EnvList: TStringList; + i: integer; + Variable, Value: string; +begin + // get system environment + EnvList:=EnvironmentAsStringList; + try + // merge user overrides + for i:=0 to UserOverrides.Count-1 do begin + Variable:=UserOverrides.Names[i]; + Value:=UserOverrides.Values[Variable]; + EnvList.Values[Variable]:=Value; + end; + Strings.Assign(EnvList); + finally + EnvList.Free; + end; +end; + { TRunParamsOptsDlg } @@ -604,6 +642,7 @@ begin SetBounds(5,UserOverridesGroupBox.Top+UserOverridesGroupBox.Height+10,w,25); Caption:='Include system variables'; Checked:=false; + Enabled:=false; Visible:=true; end; end; @@ -814,7 +853,7 @@ begin if ShowSysVarUserOverrideDialog(Variable,Value)=mrOk then begin NewLI:=UserOverridesListView.Items.Add; NewLI.Caption:=Variable; - NewLI.SubItems[0]:=Value; + NewLI.SubItems.Add(Value); UserOverridesListView.Selected:=NewLI; end; end; @@ -910,44 +949,16 @@ begin IncludeSystemVariablesCheckBox.Checked:=fOptions.IncludeSystemVariables; end; -procedure TRunParamsOptsDlg.FillSystemVariablesListView; -var - i, SysVarCount, e: integer; - Variable, Value: string; -Begin - with SystemVariablesListView.Items do begin - //BeginUpdate; - SysVarCount:=EnvCount; - for i:=0 to SysVarCount-1 do begin - Variable:=EnvStr(i+1); - e:=1; - while (e<=length(Variable)) and (Variable[e]<>'=') do inc(e); - Value:=copy(Variable,e+1,length(Variable)-e); - Variable:=LeftStr(Variable,e-1); - if Count<=i then begin - // add line to listview - Add; - Item[i].SubItems.Add(''); - end; - Item[i].Caption:=Variable; - Item[i].SubItems[0]:=Value; - end; - while Count>EnvCount do - Delete(Count-1); - //EndUpdate; - end; -end; - -procedure TRunParamsOptsDlg.FillUserOverridesListView; +procedure TRunParamsOptsDlg.FillListView(ListView: TListView; sl: TStringList); var i: integer; Variable, Value: string; Begin - with UserOverridesListView.Items do begin + with ListView.Items do begin //BeginUpdate; - for i:=0 to Options.UserOverrides.Count-1 do begin - Variable:=Options.UserOverrides.Names[i]; - Value:=Options.UserOverrides.Values[Variable]; + for i:=0 to sl.Count-1 do begin + Variable:=sl.Names[i]; + Value:=sl.Values[Variable]; if Count<=i then begin // add line to listview Add; @@ -956,11 +967,25 @@ Begin Item[i].Caption:=Variable; Item[i].SubItems[0]:=Value; end; - while Count>Options.UserOverrides.Count do + while Count>sl.Count do Delete(Count-1); //EndUpdate; end; end; +procedure TRunParamsOptsDlg.FillSystemVariablesListView; +var + EnvList: TStringList; +Begin + EnvList:=EnvironmentAsStringList; + FillListView(SystemVariablesListView,EnvList); + EnvList.Free; +end; + +procedure TRunParamsOptsDlg.FillUserOverridesListView; +Begin + FillListView(UserOverridesListView,Options.UserOverrides); +end; + end. diff --git a/lcl/include/customlistview.inc b/lcl/include/customlistview.inc index f5f0e6c571..35c12ce3b8 100644 --- a/lcl/include/customlistview.inc +++ b/lcl/include/customlistview.inc @@ -302,6 +302,10 @@ end; {------------------------------------------------------------------------------} procedure TCustomListView.SetSelection(const AValue: TListItem); begin + if FSelected=AValue then exit; + // ToDo: send message to interface + //FSelected := AValue; + //DoSelectItem(FSelected, True); end; procedure TCustomListView.SetMultiSelect(const AValue: Boolean); @@ -493,6 +497,9 @@ end; { ============================================================================= $Log$ + Revision 1.20 2002/08/28 10:44:45 lazarus + MG: implemented run param environment variables + Revision 1.19 2002/05/28 14:58:30 lazarus MG: added scrollbars for TListView