IDE: show compiler options: save option relative paths

git-svn-id: trunk@45420 -
This commit is contained in:
mattias 2014-06-09 07:40:55 +00:00
parent 98febbb4b8
commit 717159b415
5 changed files with 230 additions and 42 deletions

View File

@ -26,7 +26,8 @@
Author: Mattias Gaertner
Abstract:
History lists for strings and file names.
}
unit InputHistory;

View File

@ -4719,6 +4719,7 @@ begin
end;
if DlgResult in [mrOk,mrYes,mrAll] then begin
MiscellaneousOptions.Modified:=true;
MiscellaneousOptions.Save;
IncreaseCompilerParseStamp;
if DlgResult=mrAll then
@ -7613,8 +7614,10 @@ begin
Result:=fBuilder.MakeLazarus(BuildLazProfiles.Current, IDEBuildFlags);
if Result<>mrOk then exit;
if fBuilder.ProfileChanged then
if fBuilder.ProfileChanged then begin
MiscellaneousOptions.Modified:=true;
MiscellaneousOptions.Save;
end;
finally
MainBuildBoss.SetBuildTargetProject1(true);
DoCheckFilesOnDisk;

View File

@ -30,8 +30,8 @@ unit MiscOptions;
interface
uses
Classes, SysUtils, LCLProc, BuildProfileManager,
CodeToolsStructs, TextTools, FileUtil, Laz2_XMLCfg, LazConf, IDEProcs;
Classes, SysUtils, LCLProc, BuildProfileManager, CodeToolsStructs, TextTools,
FileUtil, Laz2_XMLCfg, LazFileCache, LazConf, IDEProcs;
type
{ TFindRenameIdentifierOptions }
@ -44,19 +44,43 @@ type
);
TFindRenameIdentifierOptions = class
private
FChangeStamp: integer;
FExtraFiles: TStrings;
FIdentifierFilename: string;
FIdentifierPosition: TPoint;
FRename: boolean;
FRenameShowResult: boolean;
FRenameTo: string;
FScope: TFindRenameScope;
FSearchInComments: boolean;
fSavedStamp: integer;
function GetModified: boolean;
procedure SetExtraFiles(AValue: TStrings);
procedure SetIdentifierFilename(AValue: string);
procedure SetIdentifierPosition(AValue: TPoint);
procedure SetModified(AValue: boolean);
procedure SetRename(AValue: boolean);
procedure SetRenameShowResult(AValue: boolean);
procedure SetRenameTo(AValue: string);
procedure SetScope(AValue: TFindRenameScope);
procedure SetSearchInComments(AValue: boolean);
public
IdentifierFilename: string;
IdentifierPosition: TPoint;
Rename: boolean;
RenameTo: string;
SearchInComments: boolean;
RenameShowResult: boolean;
Scope: TFindRenameScope;
ExtraFiles: TStrings;
constructor Create;
destructor Destroy; override;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
property ChangeStamp: integer read FChangeStamp;
procedure IncreaseChangeStamp; inline;
property Modified: boolean read GetModified write SetModified;
property IdentifierFilename: string read FIdentifierFilename write SetIdentifierFilename;
property IdentifierPosition: TPoint read FIdentifierPosition write SetIdentifierPosition;
property Rename: boolean read FRename write SetRename;
property RenameTo: string read FRenameTo write SetRenameTo;
property SearchInComments: boolean read FSearchInComments write SetSearchInComments;
property RenameShowResult: boolean read FRenameShowResult write SetRenameShowResult;
property Scope: TFindRenameScope read FScope write SetScope;
property ExtraFiles: TStrings read FExtraFiles write SetExtraFiles;
end;
@ -65,32 +89,47 @@ type
TMiscellaneousOptions = class
private
fBuildLazProfiles: TBuildLazarusProfiles;
FChangeStamp: integer;
FExtractProcName: string;
fFilename: string;
FFindRenameIdentifierOptions: TFindRenameIdentifierOptions;
FMakeResourceStringInsertPolicy: TResourcestringInsertPolicy;
FShowCompOptFullFilenames: boolean;
FSortSelDirection: TSortDirection;
FSortSelDomain: TSortDomain;
fSavedStamp: integer;
function GetBuildLazOpts: TBuildLazarusProfile;
function GetFilename: string;
function GetModified: boolean;
procedure SetExtractProcName(AValue: string);
procedure SetMakeResourceStringInsertPolicy(
AValue: TResourcestringInsertPolicy);
procedure SetModified(AValue: boolean);
procedure SetShowCompOptFullFilenames(AValue: boolean);
procedure SetSortSelDirection(AValue: TSortDirection);
public
constructor Create;
destructor Destroy; override;
procedure Load;
procedure Save;
property Filename: string read GetFilename;
property ChangeStamp: integer read FChangeStamp;
procedure IncreaseChangeStamp; inline;
property Modified: boolean read GetModified write SetModified;
property BuildLazProfiles: TBuildLazarusProfiles read fBuildLazProfiles;
property BuildLazOpts: TBuildLazarusProfile read GetBuildLazOpts;
property ExtractProcName: string read FExtractProcName write FExtractProcName;
property ExtractProcName: string read FExtractProcName write SetExtractProcName;
property SortSelDirection: TSortDirection read FSortSelDirection
write FSortSelDirection;
write SetSortSelDirection;
property SortSelDomain: TSortDomain read FSortSelDomain write FSortSelDomain;
property MakeResourceStringInsertPolicy: TResourcestringInsertPolicy
read FMakeResourceStringInsertPolicy
write FMakeResourceStringInsertPolicy;
write SetMakeResourceStringInsertPolicy;
property FindRenameIdentifierOptions: TFindRenameIdentifierOptions
read FFindRenameIdentifierOptions;
property ShowCompOptFullFilenames: boolean read FShowCompOptFullFilenames
write SetShowCompOptFullFilenames;
end;
const
@ -153,9 +192,16 @@ end;
{ TMiscellaneousOptions }
// inline
procedure TMiscellaneousOptions.IncreaseChangeStamp;
begin
LUIncreaseChangeStamp(fChangeStamp);
end;
constructor TMiscellaneousOptions.Create;
begin
inherited Create;
fSavedStamp:=LUInvalidChangeStamp;
fBuildLazProfiles:=TBuildLazarusProfiles.Create;
FExtractProcName:='NewProc';
fSortSelDirection:=sdAscending;
@ -186,6 +232,50 @@ begin
Result:=fFilename;
end;
function TMiscellaneousOptions.GetModified: boolean;
begin
Result:=(ChangeStamp<>fSavedStamp) or FindRenameIdentifierOptions.Modified;
end;
procedure TMiscellaneousOptions.SetExtractProcName(AValue: string);
begin
if FExtractProcName=AValue then Exit;
FExtractProcName:=AValue;
IncreaseChangeStamp;
end;
procedure TMiscellaneousOptions.SetMakeResourceStringInsertPolicy(
AValue: TResourcestringInsertPolicy);
begin
if FMakeResourceStringInsertPolicy=AValue then Exit;
FMakeResourceStringInsertPolicy:=AValue;
IncreaseChangeStamp;
end;
procedure TMiscellaneousOptions.SetModified(AValue: boolean);
begin
if AValue then
IncreaseChangeStamp
else begin
fSavedStamp:=ChangeStamp;
FindRenameIdentifierOptions.Modified:=false;
end;
end;
procedure TMiscellaneousOptions.SetShowCompOptFullFilenames(AValue: boolean);
begin
if FShowCompOptFullFilenames=AValue then Exit;
FShowCompOptFullFilenames:=AValue;
IncreaseChangeStamp;
end;
procedure TMiscellaneousOptions.SetSortSelDirection(AValue: TSortDirection);
begin
if FSortSelDirection=AValue then Exit;
FSortSelDirection:=AValue;
IncreaseChangeStamp;
end;
function TMiscellaneousOptions.GetBuildLazOpts: TBuildLazarusProfile;
begin
Result:=BuildLazProfiles.Current;
@ -206,8 +296,6 @@ begin
try
Path:='MiscellaneousOptions/';
FileVersion:=XMLConfig.GetValue(Path+'Version/Value',0);
// if (FileVersion<MiscOptsVersion) and (FileVersion<>0) then
// DebugLn('NOTE: converting old miscellaneous options ...');
BuildLazProfiles.Load(XMLConfig,Path+'BuildLazarusOptions/',FileVersion);
SortSelDirection:=SortDirectionNameToType(XMLConfig.GetValue(
Path+'SortSelection/Direction',SortDirectionNames[sdAscending]));
@ -219,6 +307,7 @@ begin
ExtractProcName:=XMLConfig.GetValue(Path+'ExtractProcName/Value','NewProc');
FindRenameIdentifierOptions.LoadFromXMLConfig(XMLConfig,
Path+'FindRenameIdentifier/');
ShowCompOptFullFilenames:=XMLConfig.GetValue(Path+'ShowCompOpts/Filenames/Full',false);
finally
XMLConfig.Free;
end;
@ -227,6 +316,7 @@ begin
DebugLn('ERROR: unable read miscellaneous options from "',GetFilename,'": ',E.Message);
end;
end;
Modified:=false;
end;
procedure TMiscellaneousOptions.Save;
@ -234,6 +324,7 @@ var XMLConfig: TXMLConfig;
Path: String;
XMLFilename: String;
begin
if not Modified then exit;
XMLFilename:=GetFilename;
try
XMLConfig:=TXMLConfig.CreateClean(XMLFilename);
@ -261,6 +352,7 @@ begin
'NewProc');
FindRenameIdentifierOptions.SaveToXMLConfig(XMLConfig,
Path+'FindRenameIdentifier/');
XMLConfig.SetDeleteValue(Path+'ShowCompOpts/Filenames/Full',ShowCompOptFullFilenames,false);
XMLConfig.Flush;
finally
XMLConfig.Free;
@ -270,33 +362,112 @@ begin
DebugLn('ERROR: unable read miscellaneous options from "',XMLFilename,'": ',E.Message);
end;
end;
Modified:=false;
end;
{ TFindRenameIdentifierOptions }
// inline
procedure TFindRenameIdentifierOptions.IncreaseChangeStamp;
begin
LUIncreaseChangeStamp(fChangeStamp);
end;
procedure TFindRenameIdentifierOptions.SetExtraFiles(AValue: TStrings);
begin
if (FExtraFiles=AValue) or FExtraFiles.Equals(AValue) then Exit;
FExtraFiles.Assign(AValue);
IncreaseChangeStamp;
end;
function TFindRenameIdentifierOptions.GetModified: boolean;
begin
Result:=fSavedStamp=ChangeStamp;
end;
procedure TFindRenameIdentifierOptions.SetIdentifierFilename(AValue: string);
begin
if FIdentifierFilename=AValue then Exit;
FIdentifierFilename:=AValue;
IncreaseChangeStamp;
end;
procedure TFindRenameIdentifierOptions.SetIdentifierPosition(AValue: TPoint);
begin
if ComparePoints(FIdentifierPosition,AValue)=0 then Exit;
FIdentifierPosition:=AValue;
IncreaseChangeStamp;
end;
procedure TFindRenameIdentifierOptions.SetModified(AValue: boolean);
begin
if AValue then
IncreaseChangeStamp
else
fSavedStamp:=ChangeStamp;
end;
procedure TFindRenameIdentifierOptions.SetRename(AValue: boolean);
begin
if FRename=AValue then Exit;
FRename:=AValue;
IncreaseChangeStamp;
end;
procedure TFindRenameIdentifierOptions.SetRenameShowResult(AValue: boolean);
begin
if FRenameShowResult=AValue then Exit;
FRenameShowResult:=AValue;
IncreaseChangeStamp;
end;
procedure TFindRenameIdentifierOptions.SetRenameTo(AValue: string);
begin
if FRenameTo=AValue then Exit;
FRenameTo:=AValue;
IncreaseChangeStamp;
end;
procedure TFindRenameIdentifierOptions.SetScope(AValue: TFindRenameScope);
begin
if FScope=AValue then Exit;
FScope:=AValue;
IncreaseChangeStamp;
end;
procedure TFindRenameIdentifierOptions.SetSearchInComments(AValue: boolean);
begin
if FSearchInComments=AValue then Exit;
FSearchInComments:=AValue;
IncreaseChangeStamp;
end;
constructor TFindRenameIdentifierOptions.Create;
begin
ExtraFiles:=TStringList.Create;
inherited;
fSavedStamp:=LUInvalidChangeStamp;
fExtraFiles:=TStringList.Create;
end;
destructor TFindRenameIdentifierOptions.Destroy;
begin
ExtraFiles.Free;
FreeAndNil(FExtraFiles);
inherited Destroy;
end;
procedure TFindRenameIdentifierOptions.LoadFromXMLConfig(XMLConfig: TXMLConfig;
const Path: string);
begin
IdentifierFilename:=XMLConfig.GetValue(Path+'Identifier/Filename','');
LoadPoint(XMLConfig,Path+'Identifier/',IdentifierPosition,Point(0,0));
Rename:=XMLConfig.GetValue(Path+'Rename/Value',false);
RenameTo:=XMLConfig.GetValue(Path+'Rename/Identifier','');
SearchInComments:=XMLConfig.GetValue(Path+'SearchInComments/Value',true);
RenameShowResult:=XMLConfig.GetValue(Path+'RenameShowResult/Value',false);
Scope:=FindRenameScopeNameToScope(XMLConfig.GetValue(Path+'Scope/Value',
fIdentifierFilename:=XMLConfig.GetValue(Path+'Identifier/Filename','');
LoadPoint(XMLConfig,Path+'Identifier/',fIdentifierPosition,Point(0,0));
fRename:=XMLConfig.GetValue(Path+'Rename/Value',false);
fRenameTo:=XMLConfig.GetValue(Path+'Rename/Identifier','');
fSearchInComments:=XMLConfig.GetValue(Path+'SearchInComments/Value',true);
fRenameShowResult:=XMLConfig.GetValue(Path+'RenameShowResult/Value',false);
fScope:=FindRenameScopeNameToScope(XMLConfig.GetValue(Path+'Scope/Value',
FindRenameScopeNames[frAllOpenProjectsAndPackages]));
LoadStringList(XMLConfig,ExtraFiles,Path+'ExtraFiles/');
LoadStringList(XMLConfig,fExtraFiles,Path+'ExtraFiles/');
Modified:=false;
end;
procedure TFindRenameIdentifierOptions.SaveToXMLConfig(XMLConfig: TXMLConfig;
@ -311,6 +482,7 @@ begin
XMLConfig.SetDeleteValue(Path+'Scope/Value',FindRenameScopeNames[Scope],
FindRenameScopeNames[frAllOpenProjectsAndPackages]);
SaveStringList(XMLConfig,ExtraFiles,Path+'ExtraFiles/');
Modified:=false;
end;
end.

View File

@ -9,20 +9,21 @@ object ShowCompilerOptionsDlg: TShowCompilerOptionsDlg
ClientWidth = 481
Constraints.MinHeight = 194
Constraints.MinWidth = 390
OnClose = FormClose
OnCreate = FormCreate
OnDestroy = FormDestroy
Position = poOwnerFormCenter
LCLVersion = '1.1'
LCLVersion = '1.3'
object CloseButton: TBitBtn
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 400
Height = 28
Top = 386
Width = 75
Left = 392
Height = 22
Top = 392
Width = 83
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Around = 6
@ -35,7 +36,7 @@ object ShowCompilerOptionsDlg: TShowCompilerOptionsDlg
object PageControl1: TPageControl
AnchorSideBottom.Control = CloseButton
Left = 0
Height = 380
Height = 386
Top = 0
Width = 481
ActivePage = InheritedParamsTabSheet
@ -80,13 +81,13 @@ object ShowCompilerOptionsDlg: TShowCompilerOptionsDlg
end
object InheritedParamsTabSheet: TTabSheet
Caption = 'InheritedParams'
ClientHeight = 351
ClientWidth = 477
ClientHeight = 347
ClientWidth = 475
object InhTreeView: TTreeView
Left = 0
Height = 285
Height = 281
Top = 0
Width = 477
Width = 475
Align = alClient
DefaultItemHeight = 18
ReadOnly = True
@ -98,8 +99,8 @@ object ShowCompilerOptionsDlg: TShowCompilerOptionsDlg
object InhItemMemo: TMemo
Left = 0
Height = 61
Top = 290
Width = 477
Top = 286
Width = 475
Align = alBottom
ReadOnly = True
ScrollBars = ssAutoVertical
@ -109,8 +110,8 @@ object ShowCompilerOptionsDlg: TShowCompilerOptionsDlg
Cursor = crVSplit
Left = 0
Height = 5
Top = 285
Width = 477
Top = 281
Width = 475
Align = alBottom
ResizeAnchor = akBottom
end

View File

@ -40,7 +40,7 @@ uses
CodeToolsCfgScript,
LazIDEIntf, IDEImagesIntf, CompOptsIntf, ProjectIntf,
LazarusIDEStrConsts, CompilerOptions, TransferMacros,
IDEProcs, Project, ModeMatrixOpts, PackageDefs;
IDEProcs, Project, ModeMatrixOpts, PackageDefs, MiscOptions;
type
@ -56,6 +56,7 @@ type
InhTreeView: TTreeView;
PageControl1: TPageControl;
RelativePathsCheckBox: TCheckBox;
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure InhTreeViewSelectionChanged(Sender: TObject);
@ -170,6 +171,7 @@ begin
PageControl1.ActivePage:=CmdLineParamsTabSheet;
CmdLineParamsTabSheet.Caption:=lisCommandLineParameters;
RelativePathsCheckBox.Caption:=lisShowRelativePaths;
RelativePathsCheckBox.Checked:=not MiscellaneousOptions.ShowCompOptFullFilenames;
InheritedParamsTabSheet.Caption:=lisInheritedParameters;
InhTreeView.Images := IDEImages.Images_16;
@ -178,6 +180,13 @@ begin
CloseButton.Caption:=lisBtnClose;
end;
procedure TShowCompilerOptionsDlg.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
MiscellaneousOptions.ShowCompOptFullFilenames:=not RelativePathsCheckBox.Checked;
MiscellaneousOptions.Save;
end;
procedure TShowCompilerOptionsDlg.FormDestroy(Sender: TObject);
begin
ClearInheritedTree;
@ -197,6 +206,7 @@ var
Flags: TCompilerCmdLineOptions;
CurOptions: String;
begin
if CompilerOpts=nil then exit;
Flags:=CompilerOpts.DefaultMakeOptionsFlags;
if not RelativePathsCheckBox.Checked then
Include(Flags,ccloAbsolutePaths);
@ -283,6 +293,7 @@ var
end;
begin
if CompilerOpts=nil then exit;
OptionsList := nil;
//debugln(['TCompilerInheritedOptionsFrame.UpdateInheritedTree START CompilerOpts=',DbgSName(CompilerOpts)]);
CompilerOpts.GetInheritedCompilerOptions(OptionsList);