mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 02:20:19 +02:00
IDEIntf: moved TPkgVersion and TLazPackageID to unit packageintf
git-svn-id: trunk@24697 -
This commit is contained in:
parent
7c7f08a8b9
commit
a1bc7b255f
@ -1,12 +1,9 @@
|
||||
ExternHelp.lpk
|
||||
==============
|
||||
|
||||
Under construction by Mattias
|
||||
|
||||
|
||||
This designtime package allows to setup online help for bindings. For example,
|
||||
when the source editor cursor is on an identifier in the windows unit and the user
|
||||
presses F1, a browser is opened to the MSDN.
|
||||
when the source editor cursor is on an identifier in the windows unit and the
|
||||
user presses F1, a browser is opened to the MSDN.
|
||||
|
||||
Requirements
|
||||
Lazarus 0.9.29
|
||||
@ -15,8 +12,8 @@ Installation
|
||||
Open externhelp.lpk in Lazarus and click the install button.
|
||||
|
||||
Configuration
|
||||
In Lazarus IDE menu Environment / Options ... / Extern help
|
||||
In Lazarus IDE menu Environment / Options ... / Help / Extern help
|
||||
|
||||
|
||||
Author: Mattias Gaertner mattias@freepascal.org
|
||||
|
||||
|
||||
|
@ -36,7 +36,9 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, Math, LCLProc, Forms, Controls, Buttons,
|
||||
ComCtrls, StdCtrls, ExtCtrls, Menus, Dialogs, Graphics, FileUtil, ButtonPanel,
|
||||
AVL_Tree, IDEWindowIntf, LazarusIDEStrConsts, IDEProcs, IDEOptionDefs,
|
||||
AVL_Tree,
|
||||
IDEWindowIntf, PackageIntf,
|
||||
LazarusIDEStrConsts, IDEProcs, IDEOptionDefs,
|
||||
EnvironmentOpts, Project, PackageDefs, PackageSystem, InputHistory;
|
||||
|
||||
type
|
||||
|
@ -34,8 +34,10 @@ unit CompatibilityRestrictions;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, Forms, SysUtils, InterfaceBase, ObjectInspector, OIFavouriteProperties, PackageSystem,
|
||||
PackageDefs, ComponentReg, Laz_XMLRead, Laz_XMLWrite, Laz_DOM, LazConf, LCLProc, StringHashList;
|
||||
Classes, SysUtils, Forms, LCLProc, InterfaceBase, StringHashList,
|
||||
ObjectInspector, OIFavouriteProperties,
|
||||
Laz_XMLRead, Laz_XMLWrite, Laz_DOM, PackageIntf,
|
||||
PackageSystem, PackageDefs, ComponentReg, LazConf;
|
||||
|
||||
type
|
||||
TReadRestrictedEvent = procedure (const RestrictedName, WidgetSetName: String) of object;
|
||||
|
@ -28,7 +28,65 @@ uses
|
||||
const
|
||||
PkgDescGroupName = 'Package';
|
||||
PkgDescNameStandard = 'Standard Package';
|
||||
|
||||
|
||||
type
|
||||
{ TPkgVersion }
|
||||
|
||||
TPkgVersionValid = (
|
||||
pvtNone,
|
||||
pvtMajor,
|
||||
pvtMinor,
|
||||
pvtRelease,
|
||||
pvtBuild
|
||||
);
|
||||
|
||||
TPkgVersion = class
|
||||
public
|
||||
Major: integer;
|
||||
Minor: integer;
|
||||
Release: integer;
|
||||
Build: integer;
|
||||
Valid: TPkgVersionValid;
|
||||
OnChange: TNotifyEvent;
|
||||
procedure Clear;
|
||||
function Compare(Version2: TPkgVersion): integer;
|
||||
function CompareMask(ExactVersion: TPkgVersion): integer;
|
||||
procedure Assign(Source: TPkgVersion);
|
||||
function AsString: string;
|
||||
function AsWord: string;
|
||||
function ReadString(const s: string): boolean;
|
||||
procedure SetValues(NewMajor, NewMinor, NewRelease, NewBuild: integer;
|
||||
NewValid: TPkgVersionValid = pvtBuild);
|
||||
function VersionBound(v: integer): integer;
|
||||
end;
|
||||
|
||||
|
||||
{ TLazPackageID }
|
||||
|
||||
TLazPackageID = class
|
||||
private
|
||||
FIDAsWord: string;
|
||||
protected
|
||||
FName: string;
|
||||
FVersion: TPkgVersion;
|
||||
FIDAsString: string;
|
||||
procedure SetName(const AValue: string); virtual;
|
||||
procedure UpdateIDAsString;
|
||||
procedure VersionChanged(Sender: TObject); virtual;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
function StringToID(const s: string): boolean;
|
||||
function Compare(PackageID2: TLazPackageID): integer;
|
||||
function CompareMask(ExactPackageID: TLazPackageID): integer;
|
||||
procedure AssignID(Source: TLazPackageID); virtual;
|
||||
public
|
||||
property Name: string read FName write SetName;
|
||||
property Version: TPkgVersion read FVersion;
|
||||
property IDAsString: string read FIDAsString;
|
||||
property IDAsWord: string read FIDAsWord;
|
||||
end;
|
||||
|
||||
type
|
||||
TPkgSaveFlag = (
|
||||
psfSaveAs,
|
||||
@ -255,6 +313,215 @@ begin
|
||||
FDescriptor:=TNewItemPackage(Source).Descriptor;
|
||||
end;
|
||||
|
||||
{ TPkgVersion }
|
||||
|
||||
procedure TPkgVersion.Clear;
|
||||
begin
|
||||
SetValues(0,0,0,0,pvtBuild);
|
||||
end;
|
||||
|
||||
function TPkgVersion.Compare(Version2: TPkgVersion): integer;
|
||||
begin
|
||||
Result:=Major-Version2.Major;
|
||||
if Result<>0 then exit;
|
||||
Result:=Minor-Version2.Minor;
|
||||
if Result<>0 then exit;
|
||||
Result:=Release-Version2.Release;
|
||||
if Result<>0 then exit;
|
||||
Result:=Build-Version2.Build;
|
||||
end;
|
||||
|
||||
function TPkgVersion.CompareMask(ExactVersion: TPkgVersion): integer;
|
||||
begin
|
||||
if Valid=pvtNone then exit(0);
|
||||
Result:=Major-ExactVersion.Major;
|
||||
if Result<>0 then exit;
|
||||
if Valid=pvtMajor then exit;
|
||||
Result:=Minor-ExactVersion.Minor;
|
||||
if Result<>0 then exit;
|
||||
if Valid=pvtMinor then exit;
|
||||
Result:=Release-ExactVersion.Release;
|
||||
if Result<>0 then exit;
|
||||
if Valid=pvtRelease then exit;
|
||||
Result:=Build-ExactVersion.Build;
|
||||
end;
|
||||
|
||||
procedure TPkgVersion.Assign(Source: TPkgVersion);
|
||||
begin
|
||||
SetValues(Source.Major,Source.Minor,Source.Release,Source.Build,Source.Valid);
|
||||
end;
|
||||
|
||||
function TPkgVersion.AsString: string;
|
||||
begin
|
||||
Result:=IntToStr(Major)+'.'+IntToStr(Minor);
|
||||
if (Build<>0) then
|
||||
Result:=Result+'.'+IntToStr(Release)+'.'+IntToStr(Build)
|
||||
else if (Release<>0) then
|
||||
Result:=Result+'.'+IntToStr(Release)
|
||||
end;
|
||||
|
||||
function TPkgVersion.AsWord: string;
|
||||
begin
|
||||
Result:=IntToStr(Major)+'_'+IntToStr(Minor);
|
||||
if (Build<>0) then
|
||||
Result:=Result+'_'+IntToStr(Release)+'_'+IntToStr(Build)
|
||||
else if (Release<>0) then
|
||||
Result:=Result+'_'+IntToStr(Release)
|
||||
end;
|
||||
|
||||
function TPkgVersion.ReadString(const s: string): boolean;
|
||||
var
|
||||
ints: array[1..4] of integer;
|
||||
i: integer;
|
||||
CurPos: Integer;
|
||||
StartPos: Integer;
|
||||
NewValid: TPkgVersionValid;
|
||||
begin
|
||||
Result:=false;
|
||||
CurPos:=1;
|
||||
NewValid:=pvtNone;
|
||||
for i:=1 to 4 do begin
|
||||
ints[i]:=0;
|
||||
if CurPos<length(s) then begin
|
||||
if i>Low(ints) then begin
|
||||
// read point
|
||||
if s[CurPos]<>'.' then exit;
|
||||
inc(CurPos);
|
||||
end;
|
||||
// read int
|
||||
StartPos:=CurPos;
|
||||
while (CurPos<=length(s)) and (i<=9999)
|
||||
and (s[CurPos] in ['0'..'9']) do begin
|
||||
ints[i]:=ints[i]*10+ord(s[CurPos])-ord('0');
|
||||
inc(CurPos);
|
||||
end;
|
||||
if (StartPos=CurPos) then exit;
|
||||
NewValid:=succ(NewValid);
|
||||
end;
|
||||
end;
|
||||
if CurPos<=length(s) then exit;
|
||||
SetValues(ints[1],ints[2],ints[3],ints[4],NewValid);
|
||||
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
procedure TPkgVersion.SetValues(NewMajor, NewMinor, NewRelease,
|
||||
NewBuild: integer; NewValid: TPkgVersionValid);
|
||||
begin
|
||||
NewMajor:=VersionBound(NewMajor);
|
||||
NewMinor:=VersionBound(NewMinor);
|
||||
NewRelease:=VersionBound(NewRelease);
|
||||
NewBuild:=VersionBound(NewBuild);
|
||||
if (NewMajor=Major) and (NewMinor=Minor) and (NewRelease=Release)
|
||||
and (NewBuild=Build) and (NewValid=Valid) then exit;
|
||||
Major:=NewMajor;
|
||||
Minor:=NewMinor;
|
||||
Release:=NewRelease;
|
||||
Build:=NewBuild;
|
||||
Valid:=NewValid;
|
||||
if Assigned(OnChange) then OnChange(Self);
|
||||
end;
|
||||
|
||||
function TPkgVersion.VersionBound(v: integer): integer;
|
||||
begin
|
||||
if v>9999 then
|
||||
Result:=9999
|
||||
else if v<0 then
|
||||
Result:=0
|
||||
else
|
||||
Result:=v;
|
||||
end;
|
||||
|
||||
{ TLazPackageID }
|
||||
|
||||
procedure TLazPackageID.SetName(const AValue: string);
|
||||
begin
|
||||
if FName=AValue then exit;
|
||||
FName:=AValue;
|
||||
UpdateIDAsString;
|
||||
end;
|
||||
|
||||
constructor TLazPackageID.Create;
|
||||
begin
|
||||
FVersion:=TPkgVersion.Create;
|
||||
FVersion.OnChange:=@VersionChanged;
|
||||
end;
|
||||
|
||||
destructor TLazPackageID.Destroy;
|
||||
begin
|
||||
FreeAndNil(FVersion);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TLazPackageID.UpdateIDAsString;
|
||||
begin
|
||||
FIDAsString:=Version.AsString;
|
||||
if FIDAsString<>'' then
|
||||
FIDAsString:=Name+' '+FIDAsString
|
||||
else
|
||||
FIDAsString:=FIDAsString;
|
||||
FIDAsWord:=Version.AsWord;
|
||||
if FIDAsWord<>'' then
|
||||
FIDAsWord:=Name+FIDAsWord
|
||||
else
|
||||
FIDAsWord:=FIDAsWord;
|
||||
end;
|
||||
|
||||
procedure TLazPackageID.VersionChanged(Sender: TObject);
|
||||
begin
|
||||
UpdateIDAsString;
|
||||
end;
|
||||
|
||||
function TLazPackageID.StringToID(const s: string): boolean;
|
||||
var
|
||||
IdentEndPos: Integer;
|
||||
StartPos: Integer;
|
||||
begin
|
||||
Result:=false;
|
||||
IdentEndPos:=1;
|
||||
while (IdentEndPos<=length(s))
|
||||
and (s[IdentEndPos] in ['a'..'z','A'..'Z','0'..'9','_'])
|
||||
do
|
||||
inc(IdentEndPos);
|
||||
if IdentEndPos=1 then exit;
|
||||
Name:=copy(s,1,IdentEndPos-1);
|
||||
StartPos:=IdentEndPos;
|
||||
while (StartPos<=length(s)) and (s[StartPos]=' ') do inc(StartPos);
|
||||
if StartPos=IdentEndPos then begin
|
||||
Version.Clear;
|
||||
Version.Valid:=pvtNone;
|
||||
end else begin
|
||||
if not Version.ReadString(copy(s,StartPos,length(s))) then exit;
|
||||
end;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TLazPackageID.Compare(PackageID2: TLazPackageID): integer;
|
||||
begin
|
||||
if PackageID2 <> nil then
|
||||
begin
|
||||
Result:=CompareText(Name,PackageID2.Name);
|
||||
if Result<>0 then exit;
|
||||
Result:=Version.Compare(PackageID2.Version);
|
||||
end
|
||||
else
|
||||
Result := -1;
|
||||
end;
|
||||
|
||||
function TLazPackageID.CompareMask(ExactPackageID: TLazPackageID): integer;
|
||||
begin
|
||||
Result:=CompareText(Name,ExactPackageID.Name);
|
||||
if Result<>0 then exit;
|
||||
Result:=Version.CompareMask(ExactPackageID.Version);
|
||||
end;
|
||||
|
||||
procedure TLazPackageID.AssignID(Source: TLazPackageID);
|
||||
begin
|
||||
Name:=Source.Name;
|
||||
Version.Assign(Source.Version);
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
PackageEditingInterface:=nil;
|
||||
|
||||
|
@ -40,8 +40,10 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Buttons, ExtCtrls, StdCtrls,
|
||||
LazarusIDEStrConsts, Dialogs, AVL_Tree, FileUtil, IDEProcs, IDEWindowIntf,
|
||||
ComponentReg, PackageDefs, PackageSystem, IDEContextHelpEdit, ButtonPanel;
|
||||
Dialogs, AVL_Tree, FileUtil, ButtonPanel,
|
||||
IDEWindowIntf, PackageIntf,
|
||||
LazarusIDEStrConsts, IDEProcs,
|
||||
ComponentReg, PackageDefs, PackageSystem, IDEContextHelpEdit;
|
||||
|
||||
type
|
||||
|
||||
|
@ -40,7 +40,7 @@ interface
|
||||
uses
|
||||
Math, Classes, SysUtils, LCLType, Forms, Controls, Buttons,
|
||||
StdCtrls, ExtCtrls, Dialogs, FileUtil, ComCtrls, AVL_Tree, LCLProc,
|
||||
NewItemIntf, ProjectIntf,
|
||||
NewItemIntf, ProjectIntf, PackageIntf,
|
||||
LazarusIDEStrConsts, IDEWindowIntf, InputHistory, CodeToolManager, IDEDefs,
|
||||
IDEProcs, EnvironmentOpts, PackageSystem, PackageDefs, ComponentReg,
|
||||
AddDirToPkgDlg;
|
||||
|
@ -40,7 +40,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs,
|
||||
KeywordFuncLists, StdCtrls, Buttons, FileUtil, ExtCtrls,
|
||||
AVL_Tree, Laz_XMLCfg,
|
||||
AVL_Tree, Laz_XMLCfg, PackageIntf,
|
||||
LazarusIDEStrConsts, EnvironmentOpts, InputHistory, LazConf, IDEProcs,
|
||||
PackageDefs, PackageSystem, PackageLinks, IDEContextHelpEdit;
|
||||
|
||||
|
@ -48,14 +48,13 @@ uses
|
||||
Classes, SysUtils, LCLProc, LResources, Graphics, Forms, FileUtil,
|
||||
AVL_Tree,
|
||||
DefineTemplates, CodeToolManager, Laz_XMLWrite, Laz_XMLCfg, CodeCache,
|
||||
PropEdits, LazIDEIntf, MacroIntf, PackageIntf,
|
||||
EditDefineTree, CompilerOptions, CompOptsModes,
|
||||
PropEdits, LazIDEIntf, MacroIntf,
|
||||
LazarusIDEStrConsts, IDEProcs, ComponentReg,
|
||||
TransferMacros, FileReferenceList, PublishModule;
|
||||
|
||||
type
|
||||
TLazPackage = class;
|
||||
TLazPackageID = class;
|
||||
TPkgFile = class;
|
||||
TBasePackageEditor = class;
|
||||
TPkgDependency = class;
|
||||
@ -95,41 +94,6 @@ type
|
||||
property PkgFile: TPkgFile read FPkgFile write SetPkgFile;
|
||||
end;
|
||||
|
||||
|
||||
{ TPkgVersion }
|
||||
|
||||
TPkgVersionValid = (
|
||||
pvtNone,
|
||||
pvtMajor,
|
||||
pvtMinor,
|
||||
pvtRelease,
|
||||
pvtBuild
|
||||
);
|
||||
|
||||
TPkgVersion = class
|
||||
public
|
||||
Major: integer;
|
||||
Minor: integer;
|
||||
Release: integer;
|
||||
Build: integer;
|
||||
Valid: TPkgVersionValid;
|
||||
OnChange: TNotifyEvent;
|
||||
procedure Clear;
|
||||
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||
FileVersion: integer);
|
||||
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
||||
function Compare(Version2: TPkgVersion): integer;
|
||||
function CompareMask(ExactVersion: TPkgVersion): integer;
|
||||
procedure Assign(Source: TPkgVersion);
|
||||
function AsString: string;
|
||||
function AsWord: string;
|
||||
function ReadString(const s: string): boolean;
|
||||
procedure SetValues(NewMajor, NewMinor, NewRelease, NewBuild: integer;
|
||||
NewValid: TPkgVersionValid = pvtBuild);
|
||||
function VersionBound(v: integer): integer;
|
||||
end;
|
||||
|
||||
|
||||
{ TPkgFile }
|
||||
|
||||
TPkgFileType = (
|
||||
@ -446,34 +410,6 @@ type
|
||||
property LazPackage: TLazPackage read FLazPackage write SetLazPackage;
|
||||
end;
|
||||
|
||||
|
||||
{ TLazPackageID }
|
||||
|
||||
TLazPackageID = class
|
||||
private
|
||||
FIDAsWord: string;
|
||||
protected
|
||||
FName: string;
|
||||
FVersion: TPkgVersion;
|
||||
FIDAsString: string;
|
||||
procedure SetName(const AValue: string); virtual;
|
||||
procedure UpdateIDAsString;
|
||||
procedure VersionChanged(Sender: TObject); virtual;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
function StringToID(const s: string): boolean;
|
||||
function Compare(PackageID2: TLazPackageID): integer;
|
||||
function CompareMask(ExactPackageID: TLazPackageID): integer;
|
||||
procedure AssignID(Source: TLazPackageID); virtual;
|
||||
public
|
||||
property Name: string read FName write SetName;
|
||||
property Version: TPkgVersion read FVersion;
|
||||
property IDAsString: string read FIDAsString;
|
||||
property IDAsWord: string read FIDAsWord;
|
||||
end;
|
||||
|
||||
|
||||
{ TPublishPackageOptions }
|
||||
|
||||
TPublishPackageOptions = class(TPublishModuleOptions)
|
||||
@ -962,6 +898,10 @@ function GetDependencyOwnerDirectory(Dependency: TPkgDependency): string;
|
||||
|
||||
function PackageFileNameIsValid(const AFilename: string): boolean;
|
||||
|
||||
procedure PkgVersionLoadFromXMLConfig(Version: TPkgVersion;
|
||||
XMLConfig: TXMLConfig; const Path: string; FileVersion: integer);
|
||||
procedure PkgVersionSaveToXMLConfig(Version: TPkgVersion; XMLConfig: TXMLConfig;
|
||||
const Path: string);
|
||||
|
||||
implementation
|
||||
|
||||
@ -1379,6 +1319,31 @@ begin
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
procedure PkgVersionLoadFromXMLConfig(Version: TPkgVersion;
|
||||
XMLConfig: TXMLConfig; const Path: string; FileVersion: integer);
|
||||
var
|
||||
NewMajor: Integer;
|
||||
NewMinor: Integer;
|
||||
NewRelease: Integer;
|
||||
NewBuild: Integer;
|
||||
begin
|
||||
if FileVersion=1 then ;
|
||||
NewMajor:=Version.VersionBound(XMLConfig.GetValue(Path+'Major',0));
|
||||
NewMinor:=Version.VersionBound(XMLConfig.GetValue(Path+'Minor',0));
|
||||
NewRelease:=Version.VersionBound(XMLConfig.GetValue(Path+'Release',0));
|
||||
NewBuild:=Version.VersionBound(XMLConfig.GetValue(Path+'Build',0));
|
||||
Version.SetValues(NewMajor,NewMinor,NewRelease,NewBuild,pvtBuild);
|
||||
end;
|
||||
|
||||
procedure PkgVersionSaveToXMLConfig(Version: TPkgVersion; XMLConfig: TXMLConfig;
|
||||
const Path: string);
|
||||
begin
|
||||
XMLConfig.SetDeleteValue(Path+'Major',Version.Major,0);
|
||||
XMLConfig.SetDeleteValue(Path+'Minor',Version.Minor,0);
|
||||
XMLConfig.SetDeleteValue(Path+'Release',Version.Release,0);
|
||||
XMLConfig.SetDeleteValue(Path+'Build',Version.Build,0);
|
||||
end;
|
||||
|
||||
function IndexOfDependencyInList(First: TPkgDependency;
|
||||
ListType: TPkgDependencyList; FindDependency: TPkgDependency): integer;
|
||||
var
|
||||
@ -1802,8 +1767,8 @@ begin
|
||||
if FileVersion=1 then ;
|
||||
Clear;
|
||||
PackageName:=XMLConfig.GetValue(Path+'PackageName/Value','');
|
||||
MaxVersion.LoadFromXMLConfig(XMLConfig,Path+'MaxVersion/',FileVersion);
|
||||
MinVersion.LoadFromXMLConfig(XMLConfig,Path+'MinVersion/',FileVersion);
|
||||
PkgVersionLoadFromXMLConfig(MaxVersion,XMLConfig,Path+'MaxVersion/',FileVersion);
|
||||
PkgVersionLoadFromXMLConfig(MinVersion,XMLConfig,Path+'MinVersion/',FileVersion);
|
||||
if XMLConfig.GetValue(Path+'MaxVersion/Valid',false) then
|
||||
Include(FFlags,pdfMaxVersion);
|
||||
if XMLConfig.GetValue(Path+'MinVersion/Valid',false) then
|
||||
@ -1829,8 +1794,8 @@ procedure TPkgDependency.SaveToXMLConfig(XMLConfig: TXMLConfig;
|
||||
|
||||
begin
|
||||
XMLConfig.SetDeleteValue(Path+'PackageName/Value',PackageName,'');
|
||||
MaxVersion.SaveToXMLConfig(XMLConfig,Path+'MaxVersion/');
|
||||
MinVersion.SaveToXMLConfig(XMLConfig,Path+'MinVersion/');
|
||||
PkgVersionSaveToXMLConfig(MaxVersion,XMLConfig,Path+'MaxVersion/');
|
||||
PkgVersionSaveToXMLConfig(MinVersion,XMLConfig,Path+'MinVersion/');
|
||||
XMLConfig.SetDeleteValue(Path+'MaxVersion/Valid',pdfMaxVersion in FFlags,false);
|
||||
XMLConfig.SetDeleteValue(Path+'MinVersion/Valid',pdfMinVersion in FFlags,false);
|
||||
SaveFilename('DefaultFilename/Value',FDefaultFilename);
|
||||
@ -2019,150 +1984,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TPkgVersion }
|
||||
|
||||
procedure TPkgVersion.Clear;
|
||||
begin
|
||||
SetValues(0,0,0,0,pvtBuild);
|
||||
end;
|
||||
|
||||
procedure TPkgVersion.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
||||
const Path: string; FileVersion: integer);
|
||||
var
|
||||
NewMajor: Integer;
|
||||
NewMinor: Integer;
|
||||
NewRelease: Integer;
|
||||
NewBuild: Integer;
|
||||
begin
|
||||
if FileVersion=1 then ;
|
||||
NewMajor:=VersionBound(XMLConfig.GetValue(Path+'Major',0));
|
||||
NewMinor:=VersionBound(XMLConfig.GetValue(Path+'Minor',0));
|
||||
NewRelease:=VersionBound(XMLConfig.GetValue(Path+'Release',0));
|
||||
NewBuild:=VersionBound(XMLConfig.GetValue(Path+'Build',0));
|
||||
SetValues(NewMajor,NewMinor,NewRelease,NewBuild,pvtBuild);
|
||||
end;
|
||||
|
||||
procedure TPkgVersion.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string
|
||||
);
|
||||
begin
|
||||
XMLConfig.SetDeleteValue(Path+'Major',Major,0);
|
||||
XMLConfig.SetDeleteValue(Path+'Minor',Minor,0);
|
||||
XMLConfig.SetDeleteValue(Path+'Release',Release,0);
|
||||
XMLConfig.SetDeleteValue(Path+'Build',Build,0);
|
||||
end;
|
||||
|
||||
function TPkgVersion.Compare(Version2: TPkgVersion): integer;
|
||||
begin
|
||||
Result:=Major-Version2.Major;
|
||||
if Result<>0 then exit;
|
||||
Result:=Minor-Version2.Minor;
|
||||
if Result<>0 then exit;
|
||||
Result:=Release-Version2.Release;
|
||||
if Result<>0 then exit;
|
||||
Result:=Build-Version2.Build;
|
||||
end;
|
||||
|
||||
function TPkgVersion.CompareMask(ExactVersion: TPkgVersion): integer;
|
||||
begin
|
||||
if Valid=pvtNone then exit(0);
|
||||
Result:=Major-ExactVersion.Major;
|
||||
if Result<>0 then exit;
|
||||
if Valid=pvtMajor then exit;
|
||||
Result:=Minor-ExactVersion.Minor;
|
||||
if Result<>0 then exit;
|
||||
if Valid=pvtMinor then exit;
|
||||
Result:=Release-ExactVersion.Release;
|
||||
if Result<>0 then exit;
|
||||
if Valid=pvtRelease then exit;
|
||||
Result:=Build-ExactVersion.Build;
|
||||
end;
|
||||
|
||||
procedure TPkgVersion.Assign(Source: TPkgVersion);
|
||||
begin
|
||||
SetValues(Source.Major,Source.Minor,Source.Release,Source.Build,Source.Valid);
|
||||
end;
|
||||
|
||||
function TPkgVersion.AsString: string;
|
||||
begin
|
||||
Result:=IntToStr(Major)+'.'+IntToStr(Minor);
|
||||
if (Build<>0) then
|
||||
Result:=Result+'.'+IntToStr(Release)+'.'+IntToStr(Build)
|
||||
else if (Release<>0) then
|
||||
Result:=Result+'.'+IntToStr(Release)
|
||||
end;
|
||||
|
||||
function TPkgVersion.AsWord: string;
|
||||
begin
|
||||
Result:=IntToStr(Major)+'_'+IntToStr(Minor);
|
||||
if (Build<>0) then
|
||||
Result:=Result+'_'+IntToStr(Release)+'_'+IntToStr(Build)
|
||||
else if (Release<>0) then
|
||||
Result:=Result+'_'+IntToStr(Release)
|
||||
end;
|
||||
|
||||
function TPkgVersion.ReadString(const s: string): boolean;
|
||||
var
|
||||
ints: array[1..4] of integer;
|
||||
i: integer;
|
||||
CurPos: Integer;
|
||||
StartPos: Integer;
|
||||
NewValid: TPkgVersionValid;
|
||||
begin
|
||||
Result:=false;
|
||||
CurPos:=1;
|
||||
NewValid:=pvtNone;
|
||||
for i:=1 to 4 do begin
|
||||
ints[i]:=0;
|
||||
if CurPos<length(s) then begin
|
||||
if i>Low(ints) then begin
|
||||
// read point
|
||||
if s[CurPos]<>'.' then exit;
|
||||
inc(CurPos);
|
||||
end;
|
||||
// read int
|
||||
StartPos:=CurPos;
|
||||
while (CurPos<=length(s)) and (i<=9999)
|
||||
and (s[CurPos] in ['0'..'9']) do begin
|
||||
ints[i]:=ints[i]*10+ord(s[CurPos])-ord('0');
|
||||
inc(CurPos);
|
||||
end;
|
||||
if (StartPos=CurPos) then exit;
|
||||
NewValid:=succ(NewValid);
|
||||
end;
|
||||
end;
|
||||
if CurPos<=length(s) then exit;
|
||||
SetValues(ints[1],ints[2],ints[3],ints[4],NewValid);
|
||||
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
procedure TPkgVersion.SetValues(NewMajor, NewMinor, NewRelease,
|
||||
NewBuild: integer; NewValid: TPkgVersionValid);
|
||||
begin
|
||||
NewMajor:=VersionBound(NewMajor);
|
||||
NewMinor:=VersionBound(NewMinor);
|
||||
NewRelease:=VersionBound(NewRelease);
|
||||
NewBuild:=VersionBound(NewBuild);
|
||||
if (NewMajor=Major) and (NewMinor=Minor) and (NewRelease=Release)
|
||||
and (NewBuild=Build) and (NewValid=Valid) then exit;
|
||||
Major:=NewMajor;
|
||||
Minor:=NewMinor;
|
||||
Release:=NewRelease;
|
||||
Build:=NewBuild;
|
||||
Valid:=NewValid;
|
||||
if Assigned(OnChange) then OnChange(Self);
|
||||
end;
|
||||
|
||||
function TPkgVersion.VersionBound(v: integer): integer;
|
||||
begin
|
||||
if v>9999 then
|
||||
Result:=9999
|
||||
else if v<0 then
|
||||
Result:=0
|
||||
else
|
||||
Result:=v;
|
||||
end;
|
||||
|
||||
{ TLazPackage }
|
||||
|
||||
procedure TLazPackage.OnMacroListSubstitution(TheMacro: TTransferMacro;
|
||||
@ -2700,7 +2521,7 @@ begin
|
||||
XMLConfig.GetValue(Path+'AutoUpdate/Value',''));
|
||||
FDescription:=XMLConfig.GetValue(Path+'Description/Value','');
|
||||
FLicense:=XMLConfig.GetValue(Path+'License/Value','');
|
||||
FVersion.LoadFromXMLConfig(XMLConfig,Path+'Version/',FileVersion);
|
||||
PkgVersionLoadFromXMLConfig(FVersion,XMLConfig,Path+'Version/',FileVersion);
|
||||
FIconFile:=SwitchPathDelims(XMLConfig.GetValue(Path+'IconFile/Value',''),
|
||||
PathDelimChanged);
|
||||
OutputStateFile:=SwitchPathDelims(
|
||||
@ -2780,7 +2601,7 @@ begin
|
||||
FCompilerOptions.SaveToXMLConfig(XMLConfig,Path+'CompilerOptions/');
|
||||
XMLConfig.SetDeleteValue(Path+'Description/Value',FDescription,'');
|
||||
XMLConfig.SetDeleteValue(Path+'License/Value',FLicense,'');
|
||||
FVersion.SaveToXMLConfig(XMLConfig,Path+'Version/');
|
||||
PkgVersionSaveToXMLConfig(FVersion,XMLConfig,Path+'Version/');
|
||||
SaveFiles(Path+'Files/',FFiles);
|
||||
SaveFlags(Path);
|
||||
XMLConfig.SetDeleteValue(Path+'IconFile/Value',f(FIconFile),'');
|
||||
@ -3635,95 +3456,6 @@ begin
|
||||
Result:=(not PkgFile.Removed);
|
||||
end;
|
||||
|
||||
{ TLazPackageID }
|
||||
|
||||
procedure TLazPackageID.SetName(const AValue: string);
|
||||
begin
|
||||
if FName=AValue then exit;
|
||||
FName:=AValue;
|
||||
UpdateIDAsString;
|
||||
end;
|
||||
|
||||
constructor TLazPackageID.Create;
|
||||
begin
|
||||
FVersion:=TPkgVersion.Create;
|
||||
FVersion.OnChange:=@VersionChanged;
|
||||
end;
|
||||
|
||||
destructor TLazPackageID.Destroy;
|
||||
begin
|
||||
FreeThenNil(FVersion);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TLazPackageID.UpdateIDAsString;
|
||||
begin
|
||||
FIDAsString:=Version.AsString;
|
||||
if FIDAsString<>'' then
|
||||
FIDAsString:=Name+' '+FIDAsString
|
||||
else
|
||||
FIDAsString:=FIDAsString;
|
||||
FIDAsWord:=Version.AsWord;
|
||||
if FIDAsWord<>'' then
|
||||
FIDAsWord:=Name+FIDAsWord
|
||||
else
|
||||
FIDAsWord:=FIDAsWord;
|
||||
end;
|
||||
|
||||
procedure TLazPackageID.VersionChanged(Sender: TObject);
|
||||
begin
|
||||
UpdateIDAsString;
|
||||
end;
|
||||
|
||||
function TLazPackageID.StringToID(const s: string): boolean;
|
||||
var
|
||||
IdentEndPos: Integer;
|
||||
StartPos: Integer;
|
||||
begin
|
||||
Result:=false;
|
||||
IdentEndPos:=1;
|
||||
while (IdentEndPos<=length(s))
|
||||
and (s[IdentEndPos] in ['a'..'z','A'..'Z','0'..'9','_'])
|
||||
do
|
||||
inc(IdentEndPos);
|
||||
if IdentEndPos=1 then exit;
|
||||
Name:=copy(s,1,IdentEndPos-1);
|
||||
StartPos:=IdentEndPos;
|
||||
while (StartPos<=length(s)) and (s[StartPos]=' ') do inc(StartPos);
|
||||
if StartPos=IdentEndPos then begin
|
||||
Version.Clear;
|
||||
Version.Valid:=pvtNone;
|
||||
end else begin
|
||||
if not Version.ReadString(copy(s,StartPos,length(s))) then exit;
|
||||
end;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TLazPackageID.Compare(PackageID2: TLazPackageID): integer;
|
||||
begin
|
||||
if PackageID2 <> nil then
|
||||
begin
|
||||
Result:=CompareText(Name,PackageID2.Name);
|
||||
if Result<>0 then exit;
|
||||
Result:=Version.Compare(PackageID2.Version);
|
||||
end
|
||||
else
|
||||
Result := -1;
|
||||
end;
|
||||
|
||||
function TLazPackageID.CompareMask(ExactPackageID: TLazPackageID): integer;
|
||||
begin
|
||||
Result:=CompareText(Name,ExactPackageID.Name);
|
||||
if Result<>0 then exit;
|
||||
Result:=Version.CompareMask(ExactPackageID.Version);
|
||||
end;
|
||||
|
||||
procedure TLazPackageID.AssignID(Source: TLazPackageID);
|
||||
begin
|
||||
Name:=Source.Name;
|
||||
Version.Assign(Source.Version);
|
||||
end;
|
||||
|
||||
{ TPkgCompilerOptions }
|
||||
|
||||
function TPkgCompilerOptions.LoadTheCompilerOptions(const APath: string): TModalResult;
|
||||
|
@ -41,7 +41,7 @@ uses
|
||||
Classes, SysUtils, Forms, Controls, StdCtrls, ComCtrls, Buttons, LResources,
|
||||
Graphics, LCLType, LCLProc, Menus, Dialogs, FileUtil, AVL_Tree,
|
||||
// IDEIntf CodeTools
|
||||
HelpIntfs, LazIDEIntf, ProjectIntf, FormEditingIntf, Laz_XMLCfg,
|
||||
HelpIntfs, LazIDEIntf, ProjectIntf, FormEditingIntf, Laz_XMLCfg, PackageIntf,
|
||||
// IDE
|
||||
MainIntf, IDEProcs, LazConf, LazarusIDEStrConsts, IDEOptionDefs, IDEDefs,
|
||||
IDEContextHelpEdit, CompilerOptions, CompilerOptionsDlg, ComponentReg,
|
||||
|
@ -38,7 +38,9 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, AVL_Tree, Laz_XMLCfg, FileProcs,
|
||||
LCLProc, FileUtil, IDEProcs, MacroIntf, EnvironmentOpts, PackageDefs, LazConf;
|
||||
LCLProc, FileUtil,
|
||||
MacroIntf, PackageIntf,
|
||||
IDEProcs, EnvironmentOpts, PackageDefs, LazConf;
|
||||
|
||||
const
|
||||
PkgLinksFileVersion = 2;
|
||||
@ -501,7 +503,7 @@ begin
|
||||
NewPkgLink:=TPackageLink.Create;
|
||||
NewPkgLink.Origin:=ploUser;
|
||||
NewPkgLink.Name:=XMLConfig.GetValue(ItemPath+'Name/Value','');
|
||||
NewPkgLink.Version.LoadFromXMLConfig(XMLConfig,ItemPath+'Version/',
|
||||
PkgVersionLoadFromXMLConfig(NewPkgLink.Version,XMLConfig,ItemPath+'Version/',
|
||||
LazPkgXMLFileVersion);
|
||||
NewPkgLink.Filename:=XMLConfig.GetValue(ItemPath+'Filename/Value','');
|
||||
NewPkgLink.AutoCheckExists:=
|
||||
@ -628,7 +630,7 @@ begin
|
||||
ItemPath:=Path+'Item'+IntToStr(i)+'/';
|
||||
CurPkgLink:=TPackageLink(ANode.Data);
|
||||
XMLConfig.SetDeleteValue(ItemPath+'Name/Value',CurPkgLink.Name,'');
|
||||
CurPkgLink.Version.SaveToXMLConfig(XMLConfig,ItemPath+'Version/');
|
||||
PkgVersionSaveToXMLConfig(CurPkgLink.Version,XMLConfig,ItemPath+'Version/');
|
||||
|
||||
// save package files in lazarus directory relative
|
||||
AFilename:=CurPkgLink.Filename;
|
||||
|
@ -41,7 +41,7 @@ uses
|
||||
Classes, SysUtils, LCLProc, Forms, Controls, Buttons, ComCtrls,
|
||||
StdCtrls, Menus, Dialogs, Graphics, FileCtrl,
|
||||
AVL_Tree,
|
||||
IDECommands,
|
||||
IDECommands, PackageIntf,
|
||||
LazConf, LazarusIDEStrConsts, IDEProcs, IDEOptionDefs, EnvironmentOpts,
|
||||
Project, PackageDefs, PackageSystem, PackageEditor, ExtCtrls;
|
||||
|
||||
|
@ -39,7 +39,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||
Buttons, Grids, AVL_Tree,
|
||||
FileProcs,
|
||||
FileProcs, PackageIntf,
|
||||
LazarusIDEStrConsts, PackageDefs, PackageLinks;
|
||||
|
||||
type
|
||||
|
@ -40,7 +40,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LCLProc, Forms, Controls, Buttons,
|
||||
ExtCtrls, StdCtrls, Spin, Dialogs, PathEditorDlg, IDEProcs, IDEWindowIntf,
|
||||
IDEDialogs, MacroIntf,
|
||||
IDEDialogs, MacroIntf, PackageIntf,
|
||||
LazarusIDEStrConsts,
|
||||
BrokenDependenciesDlg, PackageDefs, PackageSystem, CompilerOptions,
|
||||
ButtonPanel;
|
||||
|
Loading…
Reference in New Issue
Block a user