From d0280a2c8ffddd9014973ec95284d67600529051 Mon Sep 17 00:00:00 2001 From: maxim Date: Mon, 9 Oct 2017 22:44:00 +0000 Subject: [PATCH] Merged revision(s) 55986 #1f7440575f, 55992 #053878c753, 55994 #fd4150950b, 55996-55997 #28389af5d2-#28389af5d2, 56001 #c4eba5ff15, 56003-56004 #bfec6d9c02-#bfec6d9c02 from trunk: IDE: Remove an extra IDEDialogLayoutList.ApplyLayout call from NewDialog constructor. ........ IDE: Open a symlinked file without questions if it is found in search path or is open in editor. Issue #32292. ........ IDE: Optimise the logic for symlinked files. Issue #32292. ........ IDE: Simplify symlink loading. Project directory is already in source path. Don't ask questions while IDE starts. ........ IDE: Don't ask questions about symlinks when project is loading. ........ IDE: designer: High-DPI: selection grabber. Issue #32397 ........ IDE: designer: tune up r56001 #c4eba5ff15, issue #32397 ........ IDE: Improve opening symlinks in editor some more. ........ git-svn-id: branches/fixes_1_8@56006 - --- designer/controlselection.pp | 23 +++++++++++++------ ide/dialogprocs.pas | 32 ++++++++------------------ ide/newdialog.pas | 1 - ide/sourcefilemanager.pas | 44 +++++++++++++++++++++++++++--------- 4 files changed, 59 insertions(+), 41 deletions(-) diff --git a/designer/controlselection.pp b/designer/controlselection.pp index 2c5c364f20..3e15ee767e 100644 --- a/designer/controlselection.pp +++ b/designer/controlselection.pp @@ -372,6 +372,7 @@ type function GetBottomGuideLine(var ALine: TRect): boolean; function GetLeftGuideLine(var ALine: TRect): boolean; function GetRightGuideLine(var ALine: TRect): boolean; + function GetRealGrabberSize: integer; function GetTopGuideLine(var ALine: TRect): boolean; procedure FindNearestBottomGuideLine(var NearestInt: TNearestInt); procedure FindNearestClientLeftRight(var NearestInt: TNearestInt); @@ -1230,25 +1231,26 @@ end; procedure TControlSelection.AdjustGrabbers; var g:TGrabIndex; - OutPix, InPix, NewGrabberLeft, NewGrabberTop: integer; + OutPix, InPix, NewGrabberLeft, NewGrabberTop, AGrabberSize: integer; begin - OutPix:=GrabberSize div 2; - InPix:=GrabberSize-OutPix; + AGrabberSize := GetRealGrabberSize; + OutPix:=AGrabberSize div 2; + InPix:=AGrabberSize-OutPix; for g:=Low(TGrabIndex) to High(TGrabIndex) do begin if gpLeft in FGrabbers[g].Positions then NewGrabberLeft:=FRealLeft-OutPix else if gpRight in FGrabbers[g].Positions then NewGrabberLeft:=FRealLeft+FRealWidth-InPix else - NewGrabberLeft:=FRealLeft+((FRealWidth-GrabberSize) div 2); + NewGrabberLeft:=FRealLeft+((FRealWidth-AGrabberSize) div 2); if gpTop in FGrabbers[g].Positions then NewGrabberTop:=FRealTop-OutPix else if gpBottom in FGrabbers[g].Positions then NewGrabberTop:=FRealTop+FRealHeight-InPix else - NewGrabberTop:=FRealTop+((FRealHeight-GrabberSize) div 2); - FGrabbers[g].Width:=GrabberSize; - FGrabbers[g].Height:=GrabberSize; + NewGrabberTop:=FRealTop+((FRealHeight-AGrabberSize) div 2); + FGrabbers[g].Width:=AGrabberSize; + FGrabbers[g].Height:=AGrabberSize; FGrabbers[g].Move(NewGrabberLeft,NewGrabberTop); end; end; @@ -2160,6 +2162,13 @@ begin Result := DesignerProcs.GetParentFormRelativeBounds(AComponent); end; +function TControlSelection.GetRealGrabberSize: integer; +begin + Result := FGrabberSize; + if Assigned(FForm) and Application.Scaled then + Result := FForm.Scale96ToScreen(FGrabberSize); +end; + function TControlSelection.GetItems(Index:integer):TSelectedControl; begin Result:=TSelectedControl(FControls[Index]); diff --git a/ide/dialogprocs.pas b/ide/dialogprocs.pas index d396f1c05a..606707d469 100644 --- a/ide/dialogprocs.pas +++ b/ide/dialogprocs.pas @@ -100,7 +100,7 @@ function CheckExecutable(const OldFilename, SearchInPath: boolean = true): boolean; function CheckDirPathExists(const Dir, ErrorCaption, ErrorMsg: string): TModalResult; -function ChooseSymlink(var Filename: string; AskOnSymlink: boolean): TModalResult; +function ChooseSymlink(var Filename: string; const TargetFilename: string): TModalResult; function CreateSymlinkInteractive(const {%H-}LinkFilename, {%H-}TargetFilename: string; {%H-}ErrorButtons: TMsgDlgButtons = []): TModalResult; function ForceDirectoryInteractive(Directory: string; @@ -506,28 +506,16 @@ begin Result:=mrOk; end; -function ChooseSymlink(var Filename: string; AskOnSymlink: boolean): TModalResult; -var - TargetFilename: String; +function ChooseSymlink(var Filename: string; const TargetFilename: string): TModalResult; begin - if not FileExistsCached(Filename) then - exit(mrOk); // no symlink to choose - TargetFilename:=GetPhysicalFilenameCached(Filename,false); - if TargetFilename=Filename then begin - // no symlink to choose - end else if not AskOnSymlink then begin - // choose physical file - Filename:=TargetFilename; - end else begin - // ask which filename to use - case IDEQuestionDialog(lisFileIsSymlink, - Format(lisTheFileIsASymlinkOpenInstead,[Filename,LineEnding+LineEnding,TargetFilename]), - mtConfirmation, [mrYes, lisOpenTarget, mrNo, lisOpenSymlink, mrCancel]) - of - mrYes: Filename:=TargetFilename; - mrNo: ; - else exit(mrCancel); - end; + // ask which filename to use + case IDEQuestionDialog(lisFileIsSymlink, + Format(lisTheFileIsASymlinkOpenInstead,[Filename,LineEnding+LineEnding,TargetFilename]), + mtConfirmation, [mrYes, lisOpenTarget, mrNo, lisOpenSymlink, mrCancel]) + of + mrYes: Filename:=TargetFilename; + mrNo: ; + else exit(mrCancel); end; Result:=mrOk; end; diff --git a/ide/newdialog.pas b/ide/newdialog.pas index b37cfedc15..4a9416ad0e 100644 --- a/ide/newdialog.pas +++ b/ide/newdialog.pas @@ -435,7 +435,6 @@ begin FillProjectInheritableItemsList; CompFilterEdit.Visible := false; InheritableComponentsListView.Visible := false; - IDEDialogLayoutList.ApplyLayout(Self, 570, 400); Node:=FindItem(InputHistories.NewFileType); if Node=nil then diff --git a/ide/sourcefilemanager.pas b/ide/sourcefilemanager.pas index d46ca5474e..f8c43af24d 100644 --- a/ide/sourcefilemanager.pas +++ b/ide/sourcefilemanager.pas @@ -147,6 +147,7 @@ type function OpenNotExistingFile: TModalResult; function PrepareFile: TModalResult; function PrepareRevert(DiskFilename: String): TModalResult; + function ResolvePossibleSymlink: TModalResult; // Used by OpenFileAtCursor function CheckIfIncludeDirectiveInFront(const Line: string; X: integer): boolean; function FindFile(SearchPath: String): Boolean; @@ -1192,6 +1193,34 @@ begin end; end; +function TFileOpener.ResolvePossibleSymlink: TModalResult; +// Check if symlink and ask user if the real file should be opened instead. +// Compiler never resolves symlinks, files in compiler search path must not be resolved. +// If there already is an editor with a "physical" target of a symlink, use it. +var + SPath, Target: String; // Search path and target file for the symlink. +begin + Result := mrOK; + if ofProjectLoading in FFlags then Exit; // Use the given name when project loads. + Target := GetPhysicalFilenameCached(FFileName,false); + if Target = FFilename then Exit; // Not a symlink, continue with FFilename. + // ToDo: Check if there is an editor with a symlink for this "physical" file. + + SPath := CodeToolBoss.GetCompleteSrcPathForDirectory(''); + // Check if symlink is found in search path or in editor. + if (SearchDirectoryInSearchPath(SPath, ExtractFilePath(FFileName)) > 0) + or Assigned(SourceEditorManager.SourceEditorIntfWithFilename(FFileName)) + then + Exit; // Symlink found -> use it. + // Check if "physical" target for a symlink is found in search path or in editor. + if (SearchDirectoryInSearchPath(SPath, ExtractFilePath(Target)) > 0) + or Assigned(SourceEditorManager.SourceEditorIntfWithFilename(Target)) + then // Target found -> use Target name. + FFileName := Target + else // Not found anywhere, ask user. + Result := ChooseSymlink(FFileName, Target); +end; + function TFileOpener.OpenEditorFile(APageIndex, AWindowIndex: integer; AEditorInfo: TUnitEditorInfo; AFlags: TOpenFlags): TModalResult; var @@ -1239,21 +1268,15 @@ begin if not (ofRegularFile in FFlags) then begin DiskFilename:=GetShellLinkTarget(FFileName); if DiskFilename<>FFilename then begin - // the case is different + // not regular file DebugLn(['TFileOpener.OpenEditorFile Fixing file name: ',FFilename,' -> ',DiskFilename]); FFilename:=DiskFilename; end; end; - // check if symlink and ask user if the real file should be opened instead - // Note that compiler never resolves symlinks, so files in the compiler - // search path must not be resolved. if FilenameIsAbsolute(FFileName) then begin - s:=CodeToolBoss.GetCompleteSrcPathForDirectory(''); - if SearchDirectoryInSearchPath(s,ExtractFilePath(FFileName))<1 then - // the file is not in the project search path => check if it is a symlink - if ChooseSymlink(FFilename,true) <> mrOK then - exit(mrCancel); + Result := ResolvePossibleSymlink; + if Result <> mrOK then exit; end; // check to not open directories @@ -1751,8 +1774,7 @@ begin MainIDE.SaveEnvironment; end; -procedure TLazSourceFileManager.RemoveRecentProjectFile(const AFilename: string - ); +procedure TLazSourceFileManager.RemoveRecentProjectFile(const AFilename: string); begin EnvironmentOptions.RemoveFromRecentProjectFiles(AFilename); MainIDE.SetRecentProjectFilesMenu;