From a66ef59cd2003b9c81d7f77234d393795f509bf8 Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 17 Oct 2009 10:19:47 +0000 Subject: [PATCH] IDE: compiler options dialog: path editor dlg using relative paths git-svn-id: trunk@22203 - --- ide/compileroptionsdlg.pp | 1 + ide/patheditordlg.pas | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ide/compileroptionsdlg.pp b/ide/compileroptionsdlg.pp index 6d54a4ac0c..6a52c60bf1 100644 --- a/ide/compileroptionsdlg.pp +++ b/ide/compileroptionsdlg.pp @@ -1884,6 +1884,7 @@ begin ); end else exit; + AButton.CurrentPathEditor.BaseDirectory:=CompilerOpts.BaseDirectory; AButton.CurrentPathEditor.Path:=OldPath; AButton.CurrentPathEditor.Templates:=SetDirSeparators(Templates); end; diff --git a/ide/patheditordlg.pas b/ide/patheditordlg.pas index f6ef8d523d..0ffe714c25 100644 --- a/ide/patheditordlg.pas +++ b/ide/patheditordlg.pas @@ -29,7 +29,8 @@ interface uses Classes, SysUtils, Forms, Controls, SynEdit, Buttons, StdCtrls, Dialogs, - LResources, FileUtil, ButtonPanel, LazarusIDEStrConsts, EditorOptions; + LResources, FileUtil, ButtonPanel, MacroIntf, + LazarusIDEStrConsts, EditorOptions; type @@ -56,14 +57,19 @@ type procedure MoveUpButtonClick(Sender: TObject); procedure TemplatesListBoxDblClick(Sender: TObject); private + FBaseDirectory: string; + FEffectiveBaseDirectory: string; function GetPath: string; function GetTemplates: string; function PathToText(const APath: string): string; procedure SelectCurrentPath; + procedure SetBaseDirectory(const AValue: string); procedure SetPath(const AValue: string); procedure SetTemplates(const AValue: string); function TextToPath(const AText: string): string; public + property BaseDirectory: string read FBaseDirectory write SetBaseDirectory; + property EffectiveBaseDirectory: string read FEffectiveBaseDirectory; property Path: string read GetPath write SetPath; property Templates: string read GetTemplates write SetTemplates; end; @@ -116,13 +122,18 @@ end; procedure TPathEditorDialog.BrowseButtonClick(Sender: TObject); var y: integer; + NewPath: String; begin with BrowseDialog do begin Title:=lisPathEditSelectDirectory; if (not Execute) then exit; y:=PathEdit.CaretY; if y>PathEdit.Lines.Count then y:=PathEdit.Lines.Count; - PathEdit.Lines.Insert(y,Trim(Filename)); + NewPath:=Filename; + if (FEffectiveBaseDirectory<>'') + and FilenameIsAbsolute(FEffectiveBaseDirectory) then + NewPath:=CreateRelativePath(NewPath,FEffectiveBaseDirectory); + PathEdit.Lines.Insert(y,Trim(NewPath)); PathEdit.CaretY:=y+1; end; SelectCurrentPath; @@ -313,6 +324,15 @@ begin PathEdit.BlockEnd:=Point(length(PathEdit.Lines[y-1])+1,y); end; +procedure TPathEditorDialog.SetBaseDirectory(const AValue: string); +begin + if FBaseDirectory=AValue then exit; + FBaseDirectory:=AValue; + FEffectiveBaseDirectory:=FBaseDirectory; + IDEMacros.SubstituteMacros(FEffectiveBaseDirectory); + BrowseDialog.InitialDir:=FEffectiveBaseDirectory; +end; + { TPathEditorButton } procedure TPathEditorButton.Click;