mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 11:10:16 +02:00
IDE: read .dfm files if lfm not present, no write support, bug #16475
git-svn-id: trunk@25511 -
This commit is contained in:
parent
466e7cf010
commit
fb5e62291a
@ -329,7 +329,7 @@ begin
|
||||
OpenDialog.Filter:=dlgAllFiles+' ('+GetAllFilesMask+')|'+GetAllFilesMask
|
||||
+'|'+lisLazarusUnit+' (*.pas;*.pp)|*.pas;*.pp'
|
||||
+'|'+lisLazarusInclude+' (*.inc)|*.inc'
|
||||
+'|'+lisLazarusForm+' (*.lfm)|*.lfm';
|
||||
+'|'+lisLazarusForm+' (*.lfm;*.dfm)|*.lfm;*.dfm';
|
||||
if OpenDialog.Execute then begin
|
||||
for i:=0 to OpenDialog.Files.Count-1 do begin
|
||||
AFilename:=CleanAndExpandFilename(OpenDialog.Files[i]);
|
||||
|
@ -280,7 +280,7 @@ begin
|
||||
dlgOpen.Filter:=dlgAllFiles+' ('+GetAllFilesMask+')|'+GetAllFilesMask
|
||||
+'|'+lisLazarusUnit+' (*.pas;*.pp)|*.pas;*.pp'
|
||||
+'|'+lisLazarusProject+' (*.lpi)|*.lpi'
|
||||
+'|'+lisLazarusForm+' (*.lfm)|*.lfm'
|
||||
+'|'+lisLazarusForm+' (*.lfm;*.dfm)|*.lfm;*.dfm'
|
||||
+'|'+lisLazarusPackage+' (*.lpk)|*.lpk'
|
||||
+'|'+lisLazarusProjectSource+' (*.lpr)|*.lpr';
|
||||
dlgSave.Title:=lisSaveFileAs;
|
||||
|
40
ide/main.pp
40
ide/main.pp
@ -2692,10 +2692,11 @@ begin
|
||||
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
||||
OpenDialog.Title:=lisOpenFile;
|
||||
OpenDialog.Options:=OpenDialog.Options+[ofAllowMultiSelect];
|
||||
OpenDialog.Filter := lisLazarusFile + ' (*.lpi;*.lpr;*.lpk;*.pas;*.pp;*.inc;*.lfm)|*.lpi;*.lpr;*.lpk;*.pas;*.pp;*.inc;*.lfm'
|
||||
OpenDialog.Filter := lisLazarusFile + ' (*.lpi;*.lpr;*.lpk;*.pas;*.pp;*.inc;*.lfm;*.dfm)|' +
|
||||
'*.lpi;*.lpr;*.lpk;*.pas;*.pp;*.inc;*.lfm;*.dfm'
|
||||
+ '|' + lisLazarusUnit + ' (*.pas;*.pp)|*.pas;*.pp'
|
||||
+ '|' + lisLazarusProject + ' (*.lpi)|*.lpi'
|
||||
+ '|' + lisLazarusForm + ' (*.lfm)|*.lfm'
|
||||
+ '|' + lisLazarusForm + ' (*.lfm;*.dfm)|*.lfm;*.dfm'
|
||||
+ '|' + lisLazarusPackage + ' (*.lpk)|*.lpk'
|
||||
+ '|' + lisLazarusProjectSource + ' (*.lpr)|*.lpr'
|
||||
+ '|' + dlgAllFiles + ' (' + GetAllFilesMask + ')|' + GetAllFilesMask;
|
||||
@ -4777,6 +4778,8 @@ begin
|
||||
// then load the lfm file (without parsing)
|
||||
if (not AnUnitInfo.IsVirtual) and (AnUnitInfo.Component<>nil) then begin
|
||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.lfm');
|
||||
if not FileExistsUTF8(LFMFilename) then
|
||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.dfm');
|
||||
if (FileExistsUTF8(LFMFilename)) then begin
|
||||
Result:=LoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText],ShowAbort);
|
||||
if not (Result in [mrOk,mrIgnore]) then exit;
|
||||
@ -4809,6 +4812,8 @@ begin
|
||||
end;
|
||||
|
||||
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
||||
if not FileExistsInIDE(LFMFilename,[]) then
|
||||
LFMFilename:=ChangeFileExt(UnitFilename,'.dfm');
|
||||
if not FileExistsInIDE(LFMFilename,[]) then begin
|
||||
DebugLn(['TMainIDE.DoOpenComponent file not found ',LFMFilename]);
|
||||
exit(mrCancel);
|
||||
@ -5454,6 +5459,8 @@ begin
|
||||
OldFilename:=AnUnitInfo.Filename;
|
||||
OldFilePath:=ExtractFilePath(OldFilename);
|
||||
OldLFMFilename:=ChangeFileExt(OldFilename,'.lfm');
|
||||
if not FileExistsUTF8(OldLFMFilename) then
|
||||
OldLFMFilename:=ChangeFileExt(OldFilename,'.dfm');
|
||||
if NewUnitName='' then
|
||||
NewUnitName:=AnUnitInfo.Unit_Name;
|
||||
debugln(['TMainIDE.DoRenameUnit ',AnUnitInfo.Filename,' NewUnitName=',NewUnitName,' OldUnitName=',AnUnitInfo.Unit_Name,' ResourceCode=',ResourceCode<>nil,' NewFilename="',NewFilename,'"']);
|
||||
@ -5906,6 +5913,8 @@ begin
|
||||
|
||||
// Note: think about virtual and normal .lfm files.
|
||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.lfm');
|
||||
if not FileExistsInIDE(LFMFilename,[pfsfOnlyEditorFiles]) then
|
||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.dfm');
|
||||
LFMBuf:=nil;
|
||||
if not FileExistsInIDE(LFMFilename,[pfsfOnlyEditorFiles]) then begin
|
||||
// there is no LFM file -> ok
|
||||
@ -6309,6 +6318,8 @@ var
|
||||
for i:=0 to UnitFilenames.Count-1 do begin
|
||||
UnitFilename:=UnitFilenames[i];
|
||||
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
||||
if not FileExistsCached(LFMFilename) then
|
||||
LFMFilename:=ChangeFileExt(UnitFilename,'.dfm');
|
||||
if FileExistsCached(LFMFilename) then begin
|
||||
// load the lfm file
|
||||
ModalResult:=LoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText],true);
|
||||
@ -6372,6 +6383,8 @@ var
|
||||
exit(mrCancel);
|
||||
end;
|
||||
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
||||
if not FileExistsUTF8(LFMFilename) then
|
||||
LFMFilename:=ChangeFileExt(UnitFilename,'.dfm');
|
||||
ModalResult:=LoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText],false);
|
||||
if ModalResult<>mrOk then begin
|
||||
debugln('TMainIDE.DoFixupComponentReferences Failed loading ',LFMFilename);
|
||||
@ -6709,6 +6722,8 @@ var
|
||||
|
||||
if not TryWithoutLFM then begin
|
||||
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
||||
if not FileExistsUTF8(LFMFilename) then
|
||||
LFMFilename:=ChangeFileExt(UnitFilename,'.dfm');
|
||||
if FileExistsUTF8(LFMFilename) then begin
|
||||
// load the lfm file
|
||||
TheModalResult:=LoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText],true);
|
||||
@ -10271,11 +10286,9 @@ begin
|
||||
and (not AnUnitInfo.IsVirtual) and FilenameIsPascalUnit(AnUnitInfo.Filename)
|
||||
then begin
|
||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.lfm');
|
||||
if FileExistsUTF8(LFMFilename) then begin
|
||||
AnUnitInfo.HasResources:=true;
|
||||
end else begin
|
||||
AnUnitInfo.HasResources:=false;
|
||||
end;
|
||||
if not FileExistsUTF8(LFMFilename) then
|
||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.dfm');
|
||||
AnUnitInfo.HasResources:=FileExistsUTF8(LFMFilename);
|
||||
end;
|
||||
AnUnitInfo:=AnUnitInfo.NextPartOfProject;
|
||||
end;
|
||||
@ -11532,8 +11545,10 @@ var
|
||||
begin
|
||||
// check, if a .lfm file is opened in the source editor
|
||||
GetCurrentUnit(LFMSrcEdit,LFMUnitInfo);
|
||||
if (LFMUnitInfo=nil)
|
||||
or (CompareFileExt(LFMUnitInfo.Filename,'.lfm',false)<>0) then begin
|
||||
if (LFMUnitInfo=nil) or
|
||||
((CompareFileExt(LFMUnitInfo.Filename,'.lfm',false)<>0) and
|
||||
(CompareFileExt(LFMUnitInfo.Filename,'.dfm',false)<>0)) then
|
||||
begin
|
||||
if not Quiet then
|
||||
begin
|
||||
MessageDlg(lisNoLFMFile,
|
||||
@ -15462,6 +15477,7 @@ var
|
||||
ASrcEdit: TSourceEditor;
|
||||
AnUnitInfo: TUnitInfo;
|
||||
EditorInfo: TUnitEditorInfo;
|
||||
LFMFilename: String;
|
||||
begin
|
||||
ADesigner:=TDesigner(Sender);
|
||||
GetDesignerUnit(ADesigner,ASrcEdit,AnUnitInfo);
|
||||
@ -15471,8 +15487,10 @@ begin
|
||||
EditorInfo := AnUnitInfo.OpenEditorInfo[0]
|
||||
else
|
||||
EditorInfo := AnUnitInfo.EditorInfo[0];
|
||||
DoOpenEditorFile(ChangeFileExt(AnUnitInfo.Filename, '.lfm'),
|
||||
EditorInfo.PageIndex+1, EditorInfo.WindowIndex, []);
|
||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename, '.lfm');
|
||||
if not FileExistsUTF8(LFMFilename) then
|
||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename, '.dfm');
|
||||
DoOpenEditorFile(LFMFilename, EditorInfo.PageIndex+1, EditorInfo.WindowIndex, []);
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnDesignerSaveAsXML(Sender: TObject);
|
||||
|
@ -601,6 +601,7 @@ type
|
||||
procedure OnPopupMenuOpenPPFile(Sender: TObject);
|
||||
procedure OnPopupMenuOpenPFile(Sender: TObject);
|
||||
procedure OnPopupMenuOpenLFMFile(Sender: TObject);
|
||||
procedure OnPopupMenuOpenDFMFile(Sender: TObject);
|
||||
procedure OnPopupMenuOpenLRSFile(Sender: TObject);
|
||||
procedure OnPopupMenuOpenSFile(Sender: TObject);
|
||||
procedure OnPopupMenuOpenFile(Sender: TObject);
|
||||
@ -5059,6 +5060,16 @@ begin
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.SrcPopUpMenuPopup(Sender: TObject);
|
||||
var
|
||||
CurFilename, FileName: String;
|
||||
|
||||
procedure MaybeAddPopup(const ASuffix: String; const ANewOnClick: TNotifyEvent);
|
||||
begin
|
||||
if FileExistsUTF8(ChangeFileExt(CurFilename,ASuffix)) then
|
||||
AddContextPopupMenuItem(Format(lisOpenLfm,
|
||||
[ChangeFileExt(FileName,ASuffix)]),true,ANewOnClick);
|
||||
end;
|
||||
|
||||
var
|
||||
ASrcEdit: TSourceEditor;
|
||||
BookMarkID, BookMarkX, BookMarkY: integer;
|
||||
@ -5074,7 +5085,6 @@ var
|
||||
EditorPopupPoint, EditorCaret: TPoint;
|
||||
SelAvail: Boolean;
|
||||
SelAvailAndWritable: Boolean;
|
||||
CurFilename: String;
|
||||
CurWordAtCursor: String;
|
||||
AtIdentifier: Boolean;
|
||||
begin
|
||||
@ -5183,40 +5193,23 @@ begin
|
||||
|
||||
// add context specific menu items
|
||||
CurFilename:=ASrcEdit.FileName;
|
||||
FileName:=ExtractFileName(CurFilename);
|
||||
if (FilenameIsAbsolute(CurFilename)) then begin
|
||||
if FilenameIsPascalUnit(CurFilename) then begin
|
||||
if FileExistsUTF8(ChangeFileExt(CurFilename,'.lfm')) then
|
||||
AddContextPopupMenuItem(Format(lisOpenLfm,
|
||||
[ChangeFileExt(ExtractFileName(CurFilename),'.lfm')]),
|
||||
true,@OnPopupMenuOpenLFMFile);
|
||||
if FileExistsUTF8(ChangeFileExt(CurFilename,'.lrs')) then
|
||||
AddContextPopupMenuItem(Format(lisOpenLfm,
|
||||
[ChangeFileExt(ExtractFileName(CurFilename),'.lrs')]),
|
||||
true,@OnPopupMenuOpenLRSFile);
|
||||
if FileExistsUTF8(ChangeFileExt(CurFilename,'.s')) then
|
||||
AddContextPopupMenuItem(Format(lisOpenLfm,
|
||||
[ChangeFileExt(ExtractFileName(CurFilename),'.s')]),
|
||||
true,@OnPopupMenuOpenSFile);
|
||||
MaybeAddPopup('.lfm', @OnPopupMenuOpenLFMFile);
|
||||
MaybeAddPopup('.dfm', @OnPopupMenuOpenDFMFile);
|
||||
MaybeAddPopup('.lrs', @OnPopupMenuOpenLRSFile);
|
||||
MaybeAddPopup('.s', @OnPopupMenuOpenSFile);
|
||||
end;
|
||||
if (CompareFileExt(CurFilename,'.lfm',true)=0) then begin
|
||||
if FileExistsUTF8(ChangeFileExt(CurFilename,'.pas')) then
|
||||
AddContextPopupMenuItem(Format(lisOpenLfm,
|
||||
[ChangeFileExt(ExtractFileName(CurFilename),'.pas')]),
|
||||
true,@OnPopupMenuOpenPasFile);
|
||||
if FileExistsUTF8(ChangeFileExt(CurFilename,'.pp')) then
|
||||
AddContextPopupMenuItem(Format(lisOpenLfm,
|
||||
[ChangeFileExt(ExtractFileName(CurFilename),'.pp')]),
|
||||
true,@OnPopupMenuOpenPPFile);
|
||||
if FileExistsUTF8(ChangeFileExt(CurFilename,'.p')) then
|
||||
AddContextPopupMenuItem(Format(lisOpenLfm,
|
||||
[ChangeFileExt(ExtractFileName(CurFilename),'.p')]),
|
||||
true,@OnPopupMenuOpenPFile);
|
||||
if (CompareFileExt(CurFilename,'.lfm',true)=0)
|
||||
or (CompareFileExt(CurFilename,'.dfm',true)=0) then begin
|
||||
MaybeAddPopup('.pas', @OnPopupMenuOpenPasFile);
|
||||
MaybeAddPopup('.pp', @OnPopupMenuOpenPPFile);
|
||||
MaybeAddPopup('.p', @OnPopupMenuOpenPFile);
|
||||
end;
|
||||
if (CompareFileExt(CurFilename,'.lpi',true)=0)
|
||||
or (CompareFileExt(CurFilename,'.lpk',true)=0) then begin
|
||||
AddContextPopupMenuItem(Format(lisOpenLfm,
|
||||
[ExtractFileName(CurFilename)]),true,@OnPopupMenuOpenFile);
|
||||
end;
|
||||
or (CompareFileExt(CurFilename,'.lpk',true)=0) then
|
||||
AddContextPopupMenuItem(Format(lisOpenLfm,[FileName]),true,@OnPopupMenuOpenFile);
|
||||
end;
|
||||
|
||||
{$IFnDEF SingleSrcWindow}
|
||||
@ -6242,6 +6235,13 @@ begin
|
||||
[ofOnlyIfExists,ofAddToRecent,ofRegularFile,ofUseCache,ofDoNotLoadResource]);
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.OnPopupMenuOpenDFMFile(Sender: TObject);
|
||||
begin
|
||||
MainIDEInterface.DoOpenEditorFile(ChangeFileExt(GetActiveSE.Filename,'.dfm'),
|
||||
PageIndex+1, Manager.IndexOfSourceWindow(self),
|
||||
[ofOnlyIfExists,ofAddToRecent,ofRegularFile,ofUseCache,ofDoNotLoadResource]);
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.OnPopupMenuOpenLRSFile(Sender: TObject);
|
||||
begin
|
||||
MainIDEInterface.DoOpenEditorFile(ChangeFileExt(GetActiveSE.Filename,'.lrs'),
|
||||
|
Loading…
Reference in New Issue
Block a user