mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 20:59:12 +02:00
IDE: adding unit to project now asks if unit path should be extended
git-svn-id: trunk@12898 -
This commit is contained in:
parent
588977d5a3
commit
9f7675596c
@ -535,6 +535,9 @@ resourcestring
|
|||||||
+'Project.';
|
+'Project.';
|
||||||
lisAddToProject = 'Add %s to project?';
|
lisAddToProject = 'Add %s to project?';
|
||||||
lisTheFile = 'The file %s%s%s';
|
lisTheFile = 'The file %s%s%s';
|
||||||
|
lisAddToUnitSearchPath = 'Add to unit search path?';
|
||||||
|
lisTheNewUnitIsNotYetInTheUnitSearchPathAddDirectory = 'The new unit is not '
|
||||||
|
+'yet in the unit search path.%sAdd directory %s?';
|
||||||
lisisAlreadyPartOfTheProject = '%s is already part of the Project.';
|
lisisAlreadyPartOfTheProject = '%s is already part of the Project.';
|
||||||
lisRemoveFromProject = 'Remove from project';
|
lisRemoveFromProject = 'Remove from project';
|
||||||
lisCreateAProjectFirst = 'Create a project first!';
|
lisCreateAProjectFirst = 'Create a project first!';
|
||||||
|
24
ide/main.pp
24
ide/main.pp
@ -7995,11 +7995,13 @@ var
|
|||||||
ActiveSourceEditor: TSourceEditor;
|
ActiveSourceEditor: TSourceEditor;
|
||||||
ActiveUnitInfo: TUnitInfo;
|
ActiveUnitInfo: TUnitInfo;
|
||||||
s, ShortUnitName: string;
|
s, ShortUnitName: string;
|
||||||
|
CurUnitPath: String;
|
||||||
|
CurDirectory: String;
|
||||||
begin
|
begin
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
if BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[])
|
if BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[])
|
||||||
and (ActiveUnitInfo<>nil) then begin
|
and (ActiveUnitInfo<>nil) then begin
|
||||||
if ActiveUnitInfo.IsPartOfProject=false then begin
|
if not ActiveUnitInfo.IsPartOfProject then begin
|
||||||
if not ActiveUnitInfo.IsVirtual then
|
if not ActiveUnitInfo.IsVirtual then
|
||||||
s:='"'+ActiveUnitInfo.Filename+'"'
|
s:='"'+ActiveUnitInfo.Filename+'"'
|
||||||
else
|
else
|
||||||
@ -8015,13 +8017,16 @@ begin
|
|||||||
if MessageDlg(Format(lisAddToProject, [s]), mtConfirmation, [mbYes,
|
if MessageDlg(Format(lisAddToProject, [s]), mtConfirmation, [mbYes,
|
||||||
mbCancel], 0) in [mrOk,mrYes]
|
mbCancel], 0) in [mrOk,mrYes]
|
||||||
then begin
|
then begin
|
||||||
|
if FilenameIsPascalUnit(ActiveUnitInfo.Filename) then begin
|
||||||
Result:=DoRenameUnitLowerCase(ActiveUnitInfo,true);
|
Result:=DoRenameUnitLowerCase(ActiveUnitInfo,true);
|
||||||
if Result=mrIgnore then Result:=mrOk;
|
if Result=mrIgnore then Result:=mrOk;
|
||||||
if Result<>mrOk then begin
|
if Result<>mrOk then begin
|
||||||
debugln('TMainIDE.DoAddActiveUnitToProject A DoRenameUnitLowerCase failed ',ActiveUnitInfo.Filename);
|
debugln('TMainIDE.DoAddActiveUnitToProject A DoRenameUnitLowerCase failed ',ActiveUnitInfo.Filename);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
ActiveUnitInfo.IsPartOfProject:=true;
|
ActiveUnitInfo.IsPartOfProject:=true;
|
||||||
|
Project1.Modified:=true;
|
||||||
if (FilenameIsPascalUnit(ActiveUnitInfo.Filename))
|
if (FilenameIsPascalUnit(ActiveUnitInfo.Filename))
|
||||||
and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags)
|
and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags)
|
||||||
then begin
|
then begin
|
||||||
@ -8034,7 +8039,22 @@ begin
|
|||||||
Project1.MainUnitInfo.Modified:=true;
|
Project1.MainUnitInfo.Modified:=true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Project1.Modified:=true;
|
if not ActiveUnitInfo.IsVirtual then begin
|
||||||
|
CurUnitPath:=Project1.CompilerOptions.GetUnitPath(false);
|
||||||
|
CurDirectory:=ActiveUnitInfo.GetDirectory;
|
||||||
|
if SearchDirectoryInSearchPath(CurUnitPath,CurDirectory)<1 then
|
||||||
|
begin
|
||||||
|
if MessageDlg(lisAddToUnitSearchPath,
|
||||||
|
Format(lisTheNewUnitIsNotYetInTheUnitSearchPathAddDirectory, [
|
||||||
|
#13, CurDirectory]),
|
||||||
|
mtConfirmation,[mbYes,mbNo],0)=mrYes
|
||||||
|
then begin
|
||||||
|
Project1.CompilerOptions.OtherUnitFiles:=
|
||||||
|
MergeSearchPaths(Project1.CompilerOptions.OtherUnitFiles,
|
||||||
|
CurDirectory);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
|
Loading…
Reference in New Issue
Block a user