mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 23:59:07 +02:00
IDE: view forms: check lfm on disk
git-svn-id: trunk@27942 -
This commit is contained in:
parent
2ea1d344f1
commit
64ed209693
40
ide/main.pp
40
ide/main.pp
@ -8809,32 +8809,54 @@ var
|
|||||||
MainUnitInfo: TUnitInfo;
|
MainUnitInfo: TUnitInfo;
|
||||||
ActiveSourceEditor: TSourceEditor;
|
ActiveSourceEditor: TSourceEditor;
|
||||||
ActiveUnitInfo: TUnitInfo;
|
ActiveUnitInfo: TUnitInfo;
|
||||||
|
CurUnitInfo: TUnitInfo;
|
||||||
|
LFMFilename: String;
|
||||||
|
LFMType: String;
|
||||||
|
LFMComponentName: String;
|
||||||
|
LFMClassName: String;
|
||||||
|
anUnitName: String;
|
||||||
begin
|
begin
|
||||||
GetCurrentUnit(ActiveSourceEditor, ActiveUnitInfo);
|
GetCurrentUnit(ActiveSourceEditor, ActiveUnitInfo);
|
||||||
for i := 0 to Project1.UnitCount - 1 do
|
for i := 0 to Project1.UnitCount - 1 do
|
||||||
begin
|
begin
|
||||||
if not Project1.Units[i].IsPartOfProject then
|
CurUnitInfo:=Project1.Units[i];
|
||||||
|
if not CurUnitInfo.IsPartOfProject then
|
||||||
Continue;
|
Continue;
|
||||||
if ItemType in [piComponent, piFrame] then
|
if ItemType in [piComponent, piFrame] then
|
||||||
begin
|
begin
|
||||||
// add all form names of project
|
// add all form names of project
|
||||||
if Project1.Units[i].ComponentName <> '' then
|
if CurUnitInfo.ComponentName <> '' then
|
||||||
begin
|
begin
|
||||||
if (ItemType = piComponent) or
|
if (ItemType = piComponent) or
|
||||||
((ItemType = piFrame) and (Project1.Units[i].ResourceBaseClass = pfcbcFrame)) then
|
((ItemType = piFrame) and (CurUnitInfo.ResourceBaseClass = pfcbcFrame)) then
|
||||||
ItemList.AddObject(Project1.Units[i].Unit_Name,
|
ItemList.AddObject(CurUnitInfo.Unit_Name,
|
||||||
TViewUnitsEntry.Create(Project1.Units[i].ComponentName, i,
|
TViewUnitsEntry.Create(CurUnitInfo.ComponentName, i,
|
||||||
Project1.Units[i] = ActiveUnitInfo));
|
CurUnitInfo = ActiveUnitInfo));
|
||||||
|
end else if FilenameIsAbsolute(CurUnitInfo.Filename)
|
||||||
|
and FilenameIsPascalSource(CurUnitInfo.Filename)
|
||||||
|
and FileExistsCached(CurUnitInfo.Filename) then begin
|
||||||
|
LFMFilename:=ChangeFileExt(CurUnitInfo.Filename,'.lfm');
|
||||||
|
if FileExistsCached(LFMFilename) then begin
|
||||||
|
if ReadLFMHeaderFromFile(LFMFilename,LFMType,LFMComponentName,LFMClassName)
|
||||||
|
then begin
|
||||||
|
anUnitName:=CurUnitInfo.Unit_Name;
|
||||||
|
if anUnitName='' then
|
||||||
|
anUnitName:=ExtractFileNameOnly(LFMFilename);
|
||||||
|
ItemList.AddObject(anUnitName,
|
||||||
|
TViewUnitsEntry.Create(LFMComponentName, i,
|
||||||
|
CurUnitInfo = ActiveUnitInfo));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
// add all unit names of project
|
// add all unit names of project
|
||||||
if (Project1.Units[i].FileName <> '') then
|
if (CurUnitInfo.FileName <> '') then
|
||||||
begin
|
begin
|
||||||
AUnitName := ExtractFileName(Project1.Units[i].Filename);
|
AUnitName := ExtractFileName(CurUnitInfo.Filename);
|
||||||
if ItemList.IndexOf(AUnitName) = -1 then
|
if ItemList.IndexOf(AUnitName) = -1 then
|
||||||
ItemList.AddObject(AUnitName,
|
ItemList.AddObject(AUnitName,
|
||||||
TViewUnitsEntry.Create(AUnitName, i, Project1.Units[i] = ActiveUnitInfo));
|
TViewUnitsEntry.Create(AUnitName, i, CurUnitInfo = ActiveUnitInfo));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if Project1.MainUnitID = i then
|
if Project1.MainUnitID = i then
|
||||||
|
@ -487,6 +487,8 @@ procedure ReadLFMHeader(const LFMSource: string;
|
|||||||
out LFMClassName: String; out LFMType: String);
|
out LFMClassName: String; out LFMType: String);
|
||||||
procedure ReadLFMHeader(const LFMSource: string;
|
procedure ReadLFMHeader(const LFMSource: string;
|
||||||
out LFMType, LFMComponentName, LFMClassName: String);
|
out LFMType, LFMComponentName, LFMClassName: String);
|
||||||
|
function ReadLFMHeaderFromFile(const Filename: string;
|
||||||
|
out LFMType, LFMComponentName, LFMClassName: String): boolean;
|
||||||
function CreateLFMFile(AComponent: TComponent; LFMStream: TStream): integer;
|
function CreateLFMFile(AComponent: TComponent; LFMStream: TStream): integer;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -2048,6 +2050,29 @@ begin
|
|||||||
LFMClassName:=copy(LFMSource,StartPos,p-StartPos);
|
LFMClassName:=copy(LFMSource,StartPos,p-StartPos);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ReadLFMHeaderFromFile(const Filename: string; out LFMType,
|
||||||
|
LFMComponentName, LFMClassName: String): boolean;
|
||||||
|
var
|
||||||
|
fs: TFileStream;
|
||||||
|
Header: string;
|
||||||
|
Cnt: LongInt;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
try
|
||||||
|
fs:=TFileStream.Create(Filename,fmOpenRead);
|
||||||
|
try
|
||||||
|
SetLength(Header,600);
|
||||||
|
Cnt:=fs.Read(Header[1],length(Header));
|
||||||
|
SetLength(Header,Cnt);
|
||||||
|
ReadLFMHeader(Header,LFMType,LFMComponentName,LFMClassName);
|
||||||
|
Result:=LFMClassName<>'';
|
||||||
|
finally
|
||||||
|
fs.Free;
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function CreateLFMFile(AComponent: TComponent; LFMStream: TStream): integer;
|
function CreateLFMFile(AComponent: TComponent; LFMStream: TStream): integer;
|
||||||
// 0 = ok
|
// 0 = ok
|
||||||
// -1 = error while streaming AForm to binary stream
|
// -1 = error while streaming AForm to binary stream
|
||||||
|
Loading…
Reference in New Issue
Block a user