diff --git a/components/ideintf/srceditorintf.pas b/components/ideintf/srceditorintf.pas index a8ce078ff9..7ed76f6f25 100644 --- a/components/ideintf/srceditorintf.pas +++ b/components/ideintf/srceditorintf.pas @@ -115,7 +115,7 @@ type procedure ReplaceText(const StartPos, EndPos: TPoint; const NewText: string); procedure AskReplace(Sender: TObject; const ASearch, AReplace: string; Line, Column: integer; - var Action: TSrcEditReplaceAction); virtual; abstract; + out Action: TSrcEditReplaceAction); virtual; abstract; procedure CopyToClipboard; virtual; abstract; procedure CutToClipboard; virtual; abstract; diff --git a/ide/codemacroselect.pas b/ide/codemacroselect.pas index 8ffa1b4db1..579c65621c 100644 --- a/ide/codemacroselect.pas +++ b/ide/codemacroselect.pas @@ -57,13 +57,13 @@ type end; -function ShowCodeMacroSelectDialog(var Parameter: string): TIDECodeMacro; +function ShowCodeMacroSelectDialog(out Parameter: string): TIDECodeMacro; implementation {$R *.lfm} -function ShowCodeMacroSelectDialog(var Parameter: string): TIDECodeMacro; +function ShowCodeMacroSelectDialog(out Parameter: string): TIDECodeMacro; var CodeMacroSelectDlg: TCodeMacroSelectDlg; begin diff --git a/ide/findinfilesdlg.pas b/ide/findinfilesdlg.pas index c02a27da2c..88e94c22f0 100644 --- a/ide/findinfilesdlg.pas +++ b/ide/findinfilesdlg.pas @@ -53,6 +53,7 @@ type procedure ReplaceCheckBoxChange(Sender: TObject); procedure WhereRadioGroupClick(Sender: TObject); private + FProject: TProject; function GetFindText: string; function GetOptions: TLazFindInFileSearchOptions; function GetReplaceText: string; @@ -72,10 +73,14 @@ type function GetBaseDirectory: string; procedure LoadHistory; procedure SaveHistory; + procedure FindInSearchPath(SearchPath: string); procedure FindInFilesPerDialog(AProject: TProject); + procedure InitFindText; procedure InitFromLazSearch(Sender: TObject); procedure FindInFiles(AProject: TProject; const AFindText: string); function GetResolvedDirectories: string; + function Execute: boolean; + property LazProject: TProject read FProject write FProject; end; function FindInFilesDialog: TLazFindInFilesDialog; @@ -373,11 +378,31 @@ begin InputHistories.Save; end; +procedure TLazFindInFilesDialog.FindInSearchPath(SearchPath: string); +begin + debugln(['TLazFindInFilesDialog.FindInSearchPath ',SearchPath]); + InitFindText; + LoadHistory; + DirectoriesComboBox.Text:=SearchPath; + WhereRadioGroup.ItemIndex:=ItemIndDirectories; + // disable replace. Find in files is often called, + // but almost never to replace with the same parameters + Options := Options-[fifReplace,fifReplaceAll]; + Execute; +end; + procedure TLazFindInFilesDialog.FindInFilesPerDialog(AProject: TProject); +begin + InitFindText; + FindInFiles(AProject, FindText); +end; + +procedure TLazFindInFilesDialog.InitFindText; var TempEditor: TSourceEditorInterface; -Begin - FindText:=''; + NewFindText: String; +begin + NewFindText:=''; TempEditor := SourceEditorManagerIntf.ActiveEditor; if TempEditor <> nil then //with TempEditor.EditorComponent do @@ -385,15 +410,14 @@ Begin if EditorOpts.FindTextAtCursor then begin if TempEditor.SelectionAvailable and (TempEditor.BlockBegin.Y = TempEditor.BlockEnd.Y) - then FindText := TempEditor.Selection - else FindText := TSynEdit(TempEditor.EditorControl).GetWordAtRowCol(TempEditor.CursorTextXY); + then NewFindText := TempEditor.Selection + else NewFindText := TSynEdit(TempEditor.EditorControl).GetWordAtRowCol(TempEditor.CursorTextXY); end else begin if InputHistories.FindHistory.Count>0 then - FindText:=InputHistories.FindHistory[0]; + NewFindText:=InputHistories.FindHistory[0]; end; end; - - FindInFiles(AProject, FindText); + FindText:=NewFindText; end; procedure TLazFindInFilesDialog.InitFromLazSearch(Sender: TObject); @@ -408,9 +432,8 @@ begin end; procedure TLazFindInFilesDialog.FindInFiles(AProject: TProject; const AFindText: string); -var - SearchForm: TSearchProgressForm; begin + LazProject:=AProject; LoadHistory; // if there is no FindText, use the most recently used FindText @@ -421,8 +444,23 @@ begin // disable replace. Find in files is often called, // but almost never to replace with the same parameters Options := Options-[fifReplace,fifReplaceAll]; + Execute; +end; + +function TLazFindInFilesDialog.GetResolvedDirectories: string; +begin + Result:=DirectoriesComboBox.Text; + IDEMacros.SubstituteMacros(Result); + Result:=TrimSearchPath(Result,GetBaseDirectory,true,true); +end; + +function TLazFindInFilesDialog.Execute: boolean; +var + SearchForm: TSearchProgressForm; +begin if ShowModal=mrOk then begin + Result:=true; SaveHistory; SearchForm:= TSearchProgressForm.Create(SearchResultsView); @@ -438,7 +476,11 @@ begin if FindText <> '' then begin case WhereRadioGroup.ItemIndex of - ItemIndProject : SearchForm.DoSearchProject(AProject); + ItemIndProject : + if LazProject=nil then + SearchForm.DoSearchProject(Project1) + else + SearchForm.DoSearchProject(LazProject); ItemIndOpenFiles : SearchForm.DoSearchOpenFiles; ItemIndDirectories: SearchForm.DoSearchDir; ItemIndActiveFile : SearchForm.DoSearchActiveFile; @@ -447,14 +489,10 @@ begin finally FreeAndNil(SearchForm); end; - end; -end; + end else + Result:=false; -function TLazFindInFilesDialog.GetResolvedDirectories: string; -begin - Result:=DirectoriesComboBox.Text; - IDEMacros.SubstituteMacros(Result); - Result:=TrimSearchPath(Result,GetBaseDirectory,true,true); + FProject:=nil; end; end. diff --git a/ide/sourceeditor.pp b/ide/sourceeditor.pp index ef59fd00e6..e095be43e9 100644 --- a/ide/sourceeditor.pp +++ b/ide/sourceeditor.pp @@ -355,7 +355,7 @@ type // find procedure StartFindAndReplace(Replace:boolean); procedure AskReplace(Sender: TObject; const ASearch, AReplace: - string; Line, Column: integer; var Action: TSrcEditReplaceAction); override; + string; Line, Column: integer; out Action: TSrcEditReplaceAction); override; procedure OnReplace(Sender: TObject; const ASearch, AReplace: string; {%H-}Line, {%H-}Column: integer; var Action: TSynReplaceAction); function DoFindAndReplace(aFindText, aReplaceText: String; anOptions: TSynSearchOptions): Integer; @@ -2963,7 +2963,7 @@ begin end; procedure TSourceEditor.AskReplace(Sender: TObject; const ASearch, - AReplace: string; Line, Column: integer; var Action: TSrcEditReplaceAction); + AReplace: string; Line, Column: integer; out Action: TSrcEditReplaceAction); var SynAction: TSynReplaceAction; begin diff --git a/packager/pkgmanager.pas b/packager/pkgmanager.pas index 9fac807c8b..7521400edc 100644 --- a/packager/pkgmanager.pas +++ b/packager/pkgmanager.pas @@ -4982,8 +4982,7 @@ var begin Result:=mrOk; Dlg:=FindInFilesDialog; - Dlg.DirectoriesComboBox.Text:=''; - Dlg.FindInFilesPerDialog(Project1); + Dlg.FindInSearchPath(APackage.SourceDirectories.CreateSearchPathFromAllFiles); end; function TPkgManager.AddDependencyToUnitOwners(const OwnedFilename,