mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 21:58:29 +02:00
ide: a bit of code formatting
git-svn-id: trunk@17018 -
This commit is contained in:
parent
94618453db
commit
5d500b08d0
26
ide/main.pp
26
ide/main.pp
@ -6636,12 +6636,14 @@ begin
|
|||||||
NewFileName:=ExtractFilePath(NewFilename)
|
NewFileName:=ExtractFilePath(NewFilename)
|
||||||
+lowercase(ExtractFileName(NewFilename));
|
+lowercase(ExtractFileName(NewFilename));
|
||||||
|
|
||||||
if Project1.MainUnitID>=0 then begin
|
if Project1.MainUnitID >= 0 then
|
||||||
|
begin
|
||||||
// check mainunit filename
|
// check mainunit filename
|
||||||
Ext:=ExtractFileExt(Project1.MainUnitInfo.Filename);
|
Ext:=ExtractFileExt(Project1.MainUnitInfo.Filename);
|
||||||
if Ext='' then Ext:='.pas';
|
if Ext='' then Ext:='.pas';
|
||||||
NewProgramFilename:=ChangeFileExt(NewFilename,Ext);
|
NewProgramFilename:=ChangeFileExt(NewFilename,Ext);
|
||||||
if CompareFilenames(NewFilename,NewProgramFilename)=0 then begin
|
if CompareFilenames(NewFilename,NewProgramFilename)=0 then
|
||||||
|
begin
|
||||||
ACaption:=lisChooseADifferentName;
|
ACaption:=lisChooseADifferentName;
|
||||||
AText:=Format(lisTheProjectInfoFileIsEqualToTheProjectMainSource, [
|
AText:=Format(lisTheProjectInfoFileIsEqualToTheProjectMainSource, [
|
||||||
'"', NewFilename, '"', #13]);
|
'"', NewFilename, '"', #13]);
|
||||||
@ -6673,14 +6675,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// check if info file or source file already exists
|
// check if info file or source file already exists
|
||||||
if FileExistsUTF8(NewFilename) then begin
|
if FileExistsUTF8(NewFilename) then
|
||||||
|
begin
|
||||||
ACaption:=lisOverwriteFile;
|
ACaption:=lisOverwriteFile;
|
||||||
AText:=Format(lisAFileAlreadyExistsReplaceIt, ['"', NewFilename, '"', #13]);
|
AText:=Format(lisAFileAlreadyExistsReplaceIt, ['"', NewFilename, '"', #13]);
|
||||||
Result:=MessageDlg(ACaption, AText, mtConfirmation, [mbOk, mbCancel], 0);
|
Result:=MessageDlg(ACaption, AText, mtConfirmation, [mbOk, mbCancel], 0);
|
||||||
if Result=mrCancel then exit;
|
if Result=mrCancel then exit;
|
||||||
end
|
end
|
||||||
else begin
|
else
|
||||||
if FileExistsUTF8(NewProgramFilename) then begin
|
begin
|
||||||
|
if FileExistsUTF8(NewProgramFilename) then
|
||||||
|
begin
|
||||||
ACaption:=lisOverwriteFile;
|
ACaption:=lisOverwriteFile;
|
||||||
AText:=Format(lisAFileAlreadyExistsReplaceIt, ['"', NewProgramFilename,
|
AText:=Format(lisAFileAlreadyExistsReplaceIt, ['"', NewProgramFilename,
|
||||||
'"', #13]);
|
'"', #13]);
|
||||||
@ -6689,7 +6694,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TitleWasDefault:=Project1.TitleIsDefault(true);
|
TitleWasDefault := Project1.TitleIsDefault(true);
|
||||||
|
|
||||||
// set new project filename
|
// set new project filename
|
||||||
Project1.ProjectInfoFile:=NewFilename;
|
Project1.ProjectInfoFile:=NewFilename;
|
||||||
@ -6697,15 +6702,16 @@ begin
|
|||||||
SetRecentProjectFilesMenu;
|
SetRecentProjectFilesMenu;
|
||||||
|
|
||||||
// change main source
|
// change main source
|
||||||
if (Project1.MainUnitID>=0) then begin
|
if (Project1.MainUnitID >= 0) then
|
||||||
GetMainUnit(MainUnitInfo,MainUnitSrcEdit,true);
|
begin
|
||||||
|
GetMainUnit(MainUnitInfo, MainUnitSrcEdit, true);
|
||||||
|
|
||||||
// Save old source code, to prevent overwriting it,
|
// Save old source code, to prevent overwriting it,
|
||||||
// if the file name didn't actually change.
|
// if the file name didn't actually change.
|
||||||
OldSource:=MainUnitInfo.Source.Source;
|
OldSource := MainUnitInfo.Source.Source;
|
||||||
|
|
||||||
// switch MainUnitInfo.Source to new code
|
// switch MainUnitInfo.Source to new code
|
||||||
NewBuf:=CodeToolBoss.CreateFile(NewProgramFilename);
|
NewBuf := CodeToolBoss.CreateFile(NewProgramFilename);
|
||||||
if NewBuf=nil then begin
|
if NewBuf=nil then begin
|
||||||
Result:=MessageDlg(lisErrorCreatingFile, Format(lisUnableToCreateFile3, [
|
Result:=MessageDlg(lisErrorCreatingFile, Format(lisUnableToCreateFile3, [
|
||||||
#13, '"', NewProgramFilename, '"']), mtError, [mbCancel], 0);
|
#13, '"', NewProgramFilename, '"']), mtError, [mbCancel], 0);
|
||||||
|
@ -1299,23 +1299,26 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitInfo.SetUnitName(const NewUnitName:string);
|
procedure TUnitInfo.SetUnitName(const NewUnitName:string);
|
||||||
var Allowed:boolean;
|
var
|
||||||
|
Allowed: boolean;
|
||||||
OldUnitName: String;
|
OldUnitName: String;
|
||||||
begin
|
begin
|
||||||
if (fUnitName<>NewUnitName) and (NewUnitName<>'') then begin
|
if (fUnitName <> NewUnitName) and (NewUnitName <> '') then
|
||||||
Allowed:=true;
|
begin
|
||||||
OldUnitName:=fUnitName;
|
Allowed := true;
|
||||||
if OldUnitName='' then
|
OldUnitName := fUnitName;
|
||||||
OldUnitName:=ExtractFileNameOnly(Filename);
|
if OldUnitName = '' then
|
||||||
|
OldUnitName := ExtractFileNameOnly(Filename);
|
||||||
if Assigned(FOnUnitNameChange) then
|
if Assigned(FOnUnitNameChange) then
|
||||||
FOnUnitNameChange(Self,OldUnitName,NewUnitName,false,Allowed);
|
FOnUnitNameChange(Self, OldUnitName, NewUnitName, false, Allowed);
|
||||||
// (ignore Allowed)
|
// (ignore Allowed)
|
||||||
if (fSource<>nil) then begin
|
if (fSource <> nil) then
|
||||||
|
begin
|
||||||
CodeToolBoss.RenameSource(fSource,NewUnitName);
|
CodeToolBoss.RenameSource(fSource,NewUnitName);
|
||||||
end;
|
end;
|
||||||
fUnitName:=NewUnitName;
|
fUnitName := NewUnitName;
|
||||||
Modified:=true;
|
Modified := true;
|
||||||
if (Project<>nil) then Project.UnitModified(Self);
|
if (Project <> nil) then Project.UnitModified(Self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user