mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 21:40:25 +02:00
IDE, FindInFiles: Refactored, moved away from SourceNotebook
git-svn-id: trunk@24089 -
This commit is contained in:
parent
2307785cf3
commit
2b5156b908
@ -25,7 +25,8 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, LCLIntf, Controls, StdCtrls, Forms, Buttons,
|
Classes, SysUtils, LCLProc, LCLIntf, Controls, StdCtrls, Forms, Buttons,
|
||||||
ExtCtrls, FileUtil, LazarusIDEStrConsts, Dialogs, SynEditTypes,
|
ExtCtrls, FileUtil, LazarusIDEStrConsts, Dialogs, SynEditTypes,
|
||||||
IDEDialogs, IDEWindowIntf, InputHistory, IDEContextHelpEdit, ButtonPanel;
|
IDEDialogs, IDEWindowIntf, InputHistory, IDEContextHelpEdit, ButtonPanel,
|
||||||
|
SrcEditorIntf, EditorOptions, SearchFrm, Project, SynEdit, SearchResultView;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TLazFindInFilesDialog }
|
{ TLazFindInFilesDialog }
|
||||||
@ -70,14 +71,28 @@ type
|
|||||||
property ReplaceText: string read GetReplaceText write SetReplaceText;
|
property ReplaceText: string read GetReplaceText write SetReplaceText;
|
||||||
property SynSearchOptions: TSynSearchOptions read GetSynOptions
|
property SynSearchOptions: TSynSearchOptions read GetSynOptions
|
||||||
write SetSynOptions;
|
write SetSynOptions;
|
||||||
|
procedure LoadHistory;
|
||||||
|
procedure SaveHistory;
|
||||||
|
procedure FindInFilesPerDialog(AProject: TProject);
|
||||||
|
procedure InitFromLazSearch(Sender: TObject);
|
||||||
|
procedure FindInFiles(AProject: TProject; const AFindText: string);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function FindInFilesDialog: TLazFindInFilesDialog;
|
||||||
var
|
|
||||||
FindInFilesDialog: TLazFindInFilesDialog = nil;
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
var
|
||||||
|
FindInFilesDialogSingleton: TLazFindInFilesDialog = nil;
|
||||||
|
|
||||||
|
function FindInFilesDialog: TLazFindInFilesDialog;
|
||||||
|
begin
|
||||||
|
Result := FindInFilesDialogSingleton;
|
||||||
|
if FindInFilesDialogSingleton <> nil then exit;
|
||||||
|
FindInFilesDialogSingleton := TLazFindInFilesDialog.Create(Application);
|
||||||
|
Result := FindInFilesDialogSingleton;
|
||||||
|
end;
|
||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
{ TLazFindInFilesDialog }
|
{ TLazFindInFilesDialog }
|
||||||
@ -249,5 +264,141 @@ begin
|
|||||||
ButtonPanel1.OKButton.Caption := lisBtnFind;
|
ButtonPanel1.OKButton.Caption := lisBtnFind;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLazFindInFilesDialog.LoadHistory;
|
||||||
|
|
||||||
|
procedure AssignToComboBox(AComboBox: TComboBox; Strings: TStrings);
|
||||||
|
begin
|
||||||
|
AComboBox.Items.Assign(Strings);
|
||||||
|
if AComboBox.Items.Count>0 then
|
||||||
|
AComboBox.ItemIndex := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AddFileToComboBox(AComboBox: TComboBox; const Filename: string);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
if Filename='' then exit;
|
||||||
|
for i:=0 to AComboBox.Items.Count-1 do begin
|
||||||
|
if CompareFilenames(Filename,AComboBox.Items[i])=0 then begin
|
||||||
|
// move to front (but not top, top should be the last used directory)
|
||||||
|
if i>2 then
|
||||||
|
AComboBox.Items.Move(i,1);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
// insert in front (but not top, top should be the last used directory)
|
||||||
|
if AComboBox.Items.Count>0 then
|
||||||
|
i:=1
|
||||||
|
else
|
||||||
|
i:=0;
|
||||||
|
AComboBox.Items.Insert(i,Filename);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
SrcEdit: TSourceEditorInterface;
|
||||||
|
begin
|
||||||
|
SrcEdit := SourceEditorManagerIntf.ActiveEditor;
|
||||||
|
//DebugLn('TSourceNotebook.LoadFindInFilesHistory ',dbgsName(TextToFindComboBox),' ',dbgsName(FindHistory));
|
||||||
|
TextToFindComboBox.Items.Assign(InputHistories.FindHistory);
|
||||||
|
ReplaceTextComboBox.Items.Assign(InputHistories.ReplaceHistory);
|
||||||
|
if not EditorOpts.FindTextAtCursor then begin
|
||||||
|
if TextToFindComboBox.Items.Count>0 then begin
|
||||||
|
//debugln('TSourceNotebook.LoadFindInFilesHistory A TextToFindComboBox.Text=',TextToFindComboBox.Text);
|
||||||
|
TextToFindComboBox.ItemIndex:=0;
|
||||||
|
TextToFindComboBox.SelectAll;
|
||||||
|
//debugln('TSourceNotebook.LoadFindInFilesHistory B TextToFindComboBox.Text=',TextToFindComboBox.Text);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
// show last used directories and directory of current file
|
||||||
|
AssignToComboBox(DirectoryComboBox, InputHistories.FindInFilesPathHistory);
|
||||||
|
if (SrcEdit<>nil) and (FilenameIsAbsolute(SrcEdit.FileName)) then
|
||||||
|
AddFileToComboBox(DirectoryComboBox, ExtractFilePath(SrcEdit.FileName));
|
||||||
|
// show last used file masks
|
||||||
|
AssignToComboBox(FileMaskComboBox, InputHistories.FindInFilesMaskHistory);
|
||||||
|
Options := InputHistories.FindInFilesSearchOptions;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLazFindInFilesDialog.SaveHistory;
|
||||||
|
begin
|
||||||
|
InputHistories.AddToFindHistory(FindText);
|
||||||
|
InputHistories.AddToFindInFilesPathHistory(DirectoryComboBox.Text);
|
||||||
|
InputHistories.AddToFindInFilesMaskHistory(FileMaskComboBox.Text);
|
||||||
|
InputHistories.FindInFilesSearchOptions:=Options;
|
||||||
|
InputHistories.Save;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLazFindInFilesDialog.FindInFilesPerDialog(AProject: TProject);
|
||||||
|
var
|
||||||
|
TempEditor: TSourceEditorInterface;
|
||||||
|
Begin
|
||||||
|
FindText:='';
|
||||||
|
TempEditor := SourceEditorManagerIntf.ActiveEditor;
|
||||||
|
if TempEditor <> nil
|
||||||
|
then //with TempEditor.EditorComponent do
|
||||||
|
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);
|
||||||
|
end else begin
|
||||||
|
if InputHistories.FindHistory.Count>0 then
|
||||||
|
FindText:=InputHistories.FindHistory[0];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
FindInFiles(AProject, FindText);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLazFindInFilesDialog.InitFromLazSearch(Sender: TObject);
|
||||||
|
begin
|
||||||
|
DirectoryComboBox.Text:= TLazSearch(Sender).SearchDirectory;
|
||||||
|
Options:= TLazSearch(Sender).SearchOptions;
|
||||||
|
FileMaskComboBox.Text:= TLazSearch(Sender).SearchMask;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLazFindInFilesDialog.FindInFiles(AProject: TProject;
|
||||||
|
const AFindText: string);
|
||||||
|
var
|
||||||
|
SearchForm: TSearchForm;
|
||||||
|
begin
|
||||||
|
LoadHistory;
|
||||||
|
|
||||||
|
// if there is no FindText, use the most recently used FindText
|
||||||
|
FindText:= AFindText;
|
||||||
|
if (FindText = '') and (InputHistories.FindHistory.Count > 0) then
|
||||||
|
FindText := InputHistories.FindHistory[0];
|
||||||
|
|
||||||
|
// disable replace. Find in files is often called,
|
||||||
|
// but almost never to replace with the same parameters
|
||||||
|
Options := Options-[fifReplace,fifReplaceAll];
|
||||||
|
if ShowModal=mrOk then
|
||||||
|
begin
|
||||||
|
SaveHistory;
|
||||||
|
|
||||||
|
SearchForm:= TSearchForm.Create(SearchResultsView);
|
||||||
|
with SearchForm do begin
|
||||||
|
SearchOptions := self.Options;
|
||||||
|
SearchText := self.FindText;
|
||||||
|
ReplaceText := self.ReplaceText;
|
||||||
|
SearchMask := self.FileMaskComboBox.Text;
|
||||||
|
SearchDirectory := self.DirectoryComboBox.Text;
|
||||||
|
end;
|
||||||
|
|
||||||
|
try
|
||||||
|
if FindText <> '' then
|
||||||
|
begin
|
||||||
|
case WhereRadioGroup.ItemIndex of
|
||||||
|
0: SearchForm.DoSearchProject(AProject);
|
||||||
|
1: SearchForm.DoSearchOpenFiles;
|
||||||
|
2: SearchForm.DoSearchDir;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
FreeAndNil(SearchForm);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
28
ide/main.pp
28
ide/main.pp
@ -412,7 +412,6 @@ type
|
|||||||
procedure OnSrcNotebookToggleFormUnit(Sender: TObject);
|
procedure OnSrcNotebookToggleFormUnit(Sender: TObject);
|
||||||
procedure OnSrcNotebookToggleObjectInsp(Sender: TObject);
|
procedure OnSrcNotebookToggleObjectInsp(Sender: TObject);
|
||||||
procedure OnSrcNotebookViewJumpHistory(Sender: TObject);
|
procedure OnSrcNotebookViewJumpHistory(Sender: TObject);
|
||||||
procedure OnSrcNotebookShowSearchResultsView(Sender: TObject);
|
|
||||||
procedure OnSrcNoteBookPopupMenu(const AddMenuItemProc: TAddMenuItemProc);
|
procedure OnSrcNoteBookPopupMenu(const AddMenuItemProc: TAddMenuItemProc);
|
||||||
|
|
||||||
// ObjectInspector + PropertyEditorHook events
|
// ObjectInspector + PropertyEditorHook events
|
||||||
@ -729,7 +728,6 @@ type
|
|||||||
procedure StartIDE; override;
|
procedure StartIDE; override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure CreateOftenUsedForms; override;
|
procedure CreateOftenUsedForms; override;
|
||||||
procedure CreateSearchResultWindow;
|
|
||||||
procedure UpdateDefaultPascalFileExtensions;
|
procedure UpdateDefaultPascalFileExtensions;
|
||||||
function DoResetToolStatus(AFlags: TResetToolFlags): boolean; override;
|
function DoResetToolStatus(AFlags: TResetToolFlags): boolean; override;
|
||||||
|
|
||||||
@ -1411,15 +1409,6 @@ begin
|
|||||||
LazFindReplaceDialog:=TLazFindReplaceDialog.Create(nil);
|
LazFindReplaceDialog:=TLazFindReplaceDialog.Create(nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.CreateSearchResultWindow;
|
|
||||||
begin
|
|
||||||
if SearchResultsView<>nil then exit;
|
|
||||||
Application.CreateForm(TSearchResultsView, SearchResultsView);
|
|
||||||
with SearchResultsView do begin
|
|
||||||
OnSelectionChanged:= @SearchResultsViewSelectionChanged;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMainIDE.OIOnSelectPersistents(Sender: TObject);
|
procedure TMainIDE.OIOnSelectPersistents(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
TheControlSelection.AssignSelection(ObjectInspector1.Selection);
|
TheControlSelection.AssignSelection(ObjectInspector1.Selection);
|
||||||
@ -1922,9 +1911,11 @@ begin
|
|||||||
SourceEditorManager.OnToggleFormUnitClicked := @OnSrcNotebookToggleFormUnit;
|
SourceEditorManager.OnToggleFormUnitClicked := @OnSrcNotebookToggleFormUnit;
|
||||||
SourceEditorManager.OnToggleObjectInspClicked:= @OnSrcNotebookToggleObjectInsp;
|
SourceEditorManager.OnToggleObjectInspClicked:= @OnSrcNotebookToggleObjectInsp;
|
||||||
SourceEditorManager.OnViewJumpHistory := @OnSrcNotebookViewJumpHistory;
|
SourceEditorManager.OnViewJumpHistory := @OnSrcNotebookViewJumpHistory;
|
||||||
SourceEditorManager.OnShowSearchResultsView := @OnSrcNotebookShowSearchResultsView;
|
|
||||||
SourceEditorManager.OnPopupMenu := @OnSrcNoteBookPopupMenu;
|
SourceEditorManager.OnPopupMenu := @OnSrcNoteBookPopupMenu;
|
||||||
DebugBoss.ConnectSourceNotebookEvents;
|
DebugBoss.ConnectSourceNotebookEvents;
|
||||||
|
|
||||||
|
OnSearchResultsViewSelectionChanged := @SearchResultsViewSelectionChanged;
|
||||||
|
OnSearchAgainClicked := @FindInFilesDialog.InitFromLazSearch;
|
||||||
|
|
||||||
// connect search menu to sourcenotebook
|
// connect search menu to sourcenotebook
|
||||||
MainIDEBar.itmSearchFind.OnClick := @SourceNotebook.FindClicked;
|
MainIDEBar.itmSearchFind.OnClick := @SourceNotebook.FindClicked;
|
||||||
@ -3508,7 +3499,6 @@ end;
|
|||||||
|
|
||||||
Procedure TMainIDE.mnuViewSearchResultsClick(Sender: TObject);
|
Procedure TMainIDE.mnuViewSearchResultsClick(Sender: TObject);
|
||||||
Begin
|
Begin
|
||||||
CreateSearchResultWindow;
|
|
||||||
SearchResultsView.ShowOnTop;
|
SearchResultsView.ShowOnTop;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
@ -12156,7 +12146,6 @@ var
|
|||||||
SrcEdit: TSourceEditor;
|
SrcEdit: TSourceEditor;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
CreateSearchResultWindow;
|
|
||||||
if pos('(',SearchResultsView.GetSelectedText) > 0 then
|
if pos('(',SearchResultsView.GetSelectedText) > 0 then
|
||||||
begin
|
begin
|
||||||
AFileName:= SearchResultsView.GetSourceFileName;
|
AFileName:= SearchResultsView.GetSourceFileName;
|
||||||
@ -12243,7 +12232,6 @@ var
|
|||||||
WasVisible: boolean;
|
WasVisible: boolean;
|
||||||
ALayout: TIDEWindowLayout;
|
ALayout: TIDEWindowLayout;
|
||||||
begin
|
begin
|
||||||
CreateSearchResultWindow;
|
|
||||||
WasVisible := SearchResultsView.Visible;
|
WasVisible := SearchResultsView.Visible;
|
||||||
SearchResultsView.Visible:=true;
|
SearchResultsView.Visible:=true;
|
||||||
ALayout:=EnvironmentOptions.IDEWindowLayoutList.
|
ALayout:=EnvironmentOptions.IDEWindowLayoutList.
|
||||||
@ -13819,7 +13807,6 @@ begin
|
|||||||
|
|
||||||
// show result
|
// show result
|
||||||
if (not Options.Rename) or (not Rename) then begin
|
if (not Options.Rename) or (not Rename) then begin
|
||||||
CreateSearchResultWindow;
|
|
||||||
Result:=ShowIdentifierReferences(DeclarationUnitInfo.Source,
|
Result:=ShowIdentifierReferences(DeclarationUnitInfo.Source,
|
||||||
DeclarationCaretXY,PascalReferences);
|
DeclarationCaretXY,PascalReferences);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
@ -14217,7 +14204,7 @@ function TMainIDE.DoFindInFiles: TModalResult;
|
|||||||
begin
|
begin
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
DoArrangeSourceEditorAndMessageView(true);
|
DoArrangeSourceEditorAndMessageView(true);
|
||||||
SourceNotebook.FindInFilesPerDialog(Project1);
|
FindInFilesDialog.FindInFilesPerDialog(Project1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.DoCompleteCodeAtCursor;
|
procedure TMainIDE.DoCompleteCodeAtCursor;
|
||||||
@ -15019,11 +15006,6 @@ begin
|
|||||||
JumpHistoryViewWin.ShowOnTop;
|
JumpHistoryViewWin.ShowOnTop;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.OnSrcNotebookShowSearchResultsView(Sender: TObject);
|
|
||||||
begin
|
|
||||||
CreateSearchResultWindow;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMainIDE.OnSrcNoteBookPopupMenu(
|
procedure TMainIDE.OnSrcNoteBookPopupMenu(
|
||||||
const AddMenuItemProc: TAddMenuItemProc);
|
const AddMenuItemProc: TAddMenuItemProc);
|
||||||
begin
|
begin
|
||||||
|
@ -68,7 +68,7 @@ uses
|
|||||||
TransferMacros, ObjectInspector, PropEdits, IDEDefs, MsgView,
|
TransferMacros, ObjectInspector, PropEdits, IDEDefs, MsgView,
|
||||||
EnvironmentOpts, EditorOptions, CompilerOptions, KeyMapping, IDEProcs,
|
EnvironmentOpts, EditorOptions, CompilerOptions, KeyMapping, IDEProcs,
|
||||||
Debugger, IDEOptionDefs, CodeToolsDefines, Splash, Designer,
|
Debugger, IDEOptionDefs, CodeToolsDefines, Splash, Designer,
|
||||||
SourceEditor, BuildManager,
|
SourceEditor, BuildManager, FindInFilesDlg,
|
||||||
MainBar, MainIntf;
|
MainBar, MainIntf;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -1150,12 +1150,12 @@ end;
|
|||||||
|
|
||||||
procedure TMainIDEBase.FindInFilesPerDialog(AProject: TProject);
|
procedure TMainIDEBase.FindInFilesPerDialog(AProject: TProject);
|
||||||
begin
|
begin
|
||||||
SourceNotebook.FindInFilesPerDialog(AProject);
|
FindInFilesDialog.FindInFilesPerDialog(AProject);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDEBase.FindInFiles(AProject: TProject; const FindText: string);
|
procedure TMainIDEBase.FindInFiles(AProject: TProject; const FindText: string);
|
||||||
begin
|
begin
|
||||||
SourceNotebook.FindInFiles(AProject, FindText);
|
FindInFilesDialog.FindInFiles(AProject, FindText);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -37,9 +37,9 @@ uses
|
|||||||
// synedit, codetools
|
// synedit, codetools
|
||||||
SynEditSearch, SynRegExpr, SourceLog, KeywordFuncLists, BasicCodeTools,
|
SynEditSearch, SynRegExpr, SourceLog, KeywordFuncLists, BasicCodeTools,
|
||||||
// IDEIntf
|
// IDEIntf
|
||||||
LazIDEIntf, SrcEditorIntf,
|
LazIDEIntf, SrcEditorIntf, MainIntf,
|
||||||
// ide
|
// ide
|
||||||
LazarusIDEStrConsts, InputHistory, FindInFilesDlg, SearchResultView;
|
LazarusIDEStrConsts, InputHistory, SearchResultView, Project;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -89,6 +89,11 @@ type
|
|||||||
function GetOptions: TLazFindInFileSearchOptions;
|
function GetOptions: TLazFindInFileSearchOptions;
|
||||||
procedure SearchFile(const aFilename: string);
|
procedure SearchFile(const aFilename: string);
|
||||||
procedure SetFlag(Flag: TSrcEditSearchOption; AValue: boolean);
|
procedure SetFlag(Flag: TSrcEditSearchOption; AValue: boolean);
|
||||||
|
procedure DoSearchAndAddToSearchResults;
|
||||||
|
public
|
||||||
|
procedure DoSearchOpenFiles;
|
||||||
|
procedure DoSearchDir;
|
||||||
|
procedure DoSearchProject(AProject: TProject);
|
||||||
public
|
public
|
||||||
procedure DoSearch;
|
procedure DoSearch;
|
||||||
property SearchDirectory: string read fTheDirectory write fTheDirectory;
|
property SearchDirectory: string read fTheDirectory write fTheDirectory;
|
||||||
@ -878,6 +883,89 @@ begin
|
|||||||
Exclude(fFlags,Flag);
|
Exclude(fFlags,Flag);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSearchForm.DoSearchAndAddToSearchResults;
|
||||||
|
var
|
||||||
|
ListIndex: integer;
|
||||||
|
begin
|
||||||
|
ListIndex:=SearchResultsView.AddSearch(SearchText,
|
||||||
|
SearchText,
|
||||||
|
ReplaceText,
|
||||||
|
SearchDirectory,
|
||||||
|
SearchMask,
|
||||||
|
SearchOptions);
|
||||||
|
|
||||||
|
try
|
||||||
|
SearchResultsView.BeginUpdate(ListIndex);
|
||||||
|
ResultsList := SearchResultsView.Items[ListIndex];
|
||||||
|
SearchResultsView.Items[ListIndex].Clear;
|
||||||
|
ResultsWindow:= ListIndex;
|
||||||
|
try
|
||||||
|
Show;
|
||||||
|
// update Window Menu, the OnIdle event does not occur while searching
|
||||||
|
MainIDEInterface.UpdateWindowMenu;
|
||||||
|
DoSearch;
|
||||||
|
except
|
||||||
|
on E: ERegExpr do
|
||||||
|
MessageDlg(lisUEErrorInRegularExpression, E.Message,mtError,
|
||||||
|
[mbCancel],0);
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
SearchResultsView.EndUpdate(ListIndex);
|
||||||
|
SearchResultsView.ShowOnTop;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSearchForm.DoSearchOpenFiles;
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
TheFileList: TStringList;
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
TheFileList:= TStringList.Create;
|
||||||
|
for i:= 0 to SourceEditorManagerIntf.SourceEditorCount -1 do
|
||||||
|
begin
|
||||||
|
//only if file exists on disk
|
||||||
|
if FilenameIsAbsolute(SourceEditorManagerIntf.SourceEditors[i].FileName) and
|
||||||
|
FileExistsUTF8(SourceEditorManagerIntf.SourceEditors[i].FileName) then
|
||||||
|
begin
|
||||||
|
TheFileList.Add(SourceEditorManagerIntf.SourceEditors[i].FileName);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
SearchFileList:= TheFileList;
|
||||||
|
DoSearchAndAddToSearchResults;
|
||||||
|
finally
|
||||||
|
FreeAndNil(TheFileList);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSearchForm.DoSearchDir;
|
||||||
|
begin
|
||||||
|
SearchFileList:= Nil;
|
||||||
|
DoSearchAndAddToSearchResults;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSearchForm.DoSearchProject(AProject: TProject);
|
||||||
|
var
|
||||||
|
AnUnitInfo: TUnitInfo;
|
||||||
|
TheFileList: TStringList;
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
TheFileList:= TStringList.Create;
|
||||||
|
AnUnitInfo:=AProject.FirstPartOfProject;
|
||||||
|
while AnUnitInfo<>nil do begin
|
||||||
|
//Only if file exists on disk.
|
||||||
|
if FilenameIsAbsolute(AnUnitInfo.FileName)
|
||||||
|
and FileExistsUTF8(AnUnitInfo.FileName) then
|
||||||
|
TheFileList.Add(AnUnitInfo.FileName);
|
||||||
|
AnUnitInfo:=AnUnitInfo.NextPartOfProject;
|
||||||
|
end;
|
||||||
|
SearchFileList:= TheFileList;
|
||||||
|
DoSearchAndAddToSearchResults;
|
||||||
|
finally
|
||||||
|
FreeAndNil(TheFileList);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TSearchForm.PadAndShorten(FileName: string): string;
|
function TSearchForm.PadAndShorten(FileName: string): string;
|
||||||
var
|
var
|
||||||
FoundAt: integer;
|
FoundAt: integer;
|
||||||
|
@ -39,8 +39,8 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs,
|
||||||
ComCtrls, ExtCtrls, StdCtrls, Buttons, LCLType, LCLIntf, Menus,
|
ComCtrls, ExtCtrls, StdCtrls, Buttons, LCLType, LCLIntf, Menus,
|
||||||
IDEOptionDefs, LazarusIDEStrConsts, EnvironmentOpts, EditorOptions, InputHistory,
|
IDEOptionDefs, LazarusIDEStrConsts, EnvironmentOpts, InputHistory,
|
||||||
IDEProcs, FindInFilesDlg, Project, MainIntf, Clipbrd;
|
IDEProcs, Project, MainIntf, Clipbrd;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TLazSearchMatchPos }
|
{ TLazSearchMatchPos }
|
||||||
@ -206,8 +206,11 @@ type
|
|||||||
property MaxItems: integer read FMaxItems write SetMaxItems;
|
property MaxItems: integer read FMaxItems write SetMaxItems;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function SearchResultsView: TSearchResultsView;
|
||||||
|
|
||||||
var
|
var
|
||||||
SearchResultsView: TSearchResultsView;
|
OnSearchResultsViewSelectionChanged: TNotifyEvent = nil;
|
||||||
|
OnSearchAgainClicked: TNotifyEvent = nil;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -217,7 +220,9 @@ implementation
|
|||||||
|
|
||||||
const
|
const
|
||||||
MaxTextLen = 80;
|
MaxTextLen = 80;
|
||||||
|
var
|
||||||
|
SearchResultsViewSingleton: TSearchResultsView = nil;
|
||||||
|
|
||||||
function CopySearchMatchPos(var Src, Dest: TLazSearchMatchPos): Boolean;
|
function CopySearchMatchPos(var Src, Dest: TLazSearchMatchPos): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
@ -248,6 +253,15 @@ begin
|
|||||||
sl.Free;
|
sl.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function SearchResultsView: TSearchResultsView;
|
||||||
|
begin
|
||||||
|
Result := SearchResultsViewSingleton;
|
||||||
|
if SearchResultsViewSingleton <> nil then exit;
|
||||||
|
Application.CreateForm(TSearchResultsView, SearchResultsViewSingleton);
|
||||||
|
SearchResultsViewSingleton.OnSelectionChanged := OnSearchResultsViewSelectionChanged;
|
||||||
|
Result := SearchResultsViewSingleton;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSearchResultsView.Form1Create(Sender: TObject);
|
procedure TSearchResultsView.Form1Create(Sender: TObject);
|
||||||
var
|
var
|
||||||
ALayout: TIDEWindowLayout;
|
ALayout: TIDEWindowLayout;
|
||||||
@ -727,16 +741,8 @@ begin
|
|||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
SearchObj:= CurrentTV.SearchObject;
|
SearchObj:= CurrentTV.SearchObject;
|
||||||
if Assigned(FindInFilesDialog) then
|
OnSearchAgainClicked(SearchObj);
|
||||||
begin
|
MainIDEInterface.FindInFiles(Project1, SearchObj.SearchString);
|
||||||
with FindInFilesDialog do
|
|
||||||
begin
|
|
||||||
DirectoryComboBox.Text:= SearchObj.SearchDirectory;
|
|
||||||
Options:= SearchObj.SearchOptions;
|
|
||||||
FileMaskComboBox.Text:= SearchObj.SearchMask;
|
|
||||||
end;//with
|
|
||||||
MainIDEInterface.FindInFiles(Project1, SearchObj.SearchString);
|
|
||||||
end;//if
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -41,25 +41,22 @@ uses
|
|||||||
MemCheck,
|
MemCheck,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, SysUtils, Math, Controls, LCLProc, LCLType, LResources, LCLIntf,
|
Classes, SysUtils, Math, Controls, LCLProc, LCLType, LResources, LCLIntf,
|
||||||
FileUtil, Forms, Buttons, ComCtrls, Dialogs, StdCtrls, GraphType, Graphics,
|
FileUtil, Forms, ComCtrls, Dialogs, StdCtrls, Graphics,
|
||||||
Translations, ClipBrd, TypInfo, types, Extctrls, Menus, HelpIntfs,
|
Translations, ClipBrd, types, Extctrls, Menus, HelpIntfs, LConvEncoding, LDockCtrl,
|
||||||
LazHelpIntf, LConvEncoding, LDockCtrl,
|
|
||||||
// codetools
|
// codetools
|
||||||
BasicCodeTools, CodeBeautifier, CodeToolManager, CodeCache, SourceLog,
|
BasicCodeTools, CodeBeautifier, CodeToolManager, CodeCache, SourceLog,
|
||||||
// synedit
|
// synedit
|
||||||
SynEditLines, SynEditStrConst, SynEditTypes, SynEdit, SynRegExpr,
|
SynEditLines, SynEditStrConst, SynEditTypes, SynEdit, SynRegExpr,
|
||||||
SynEditHighlighter, SynEditAutoComplete, SynEditKeyCmds, SynCompletion,
|
SynEditHighlighter, SynEditAutoComplete, SynEditKeyCmds, SynCompletion,
|
||||||
SynEditMiscClasses, SynEditMarkupHighAll, SynGutterLineNumber, SynEditMarks,
|
SynEditMiscClasses, SynEditMarkupHighAll, SynEditMarks,
|
||||||
SynBeautifier, SynEditTextBase, SynPluginTemplateEdit, SynPluginSyncroEdit,
|
SynBeautifier, SynEditTextBase, SynPluginTemplateEdit, SynPluginSyncroEdit,
|
||||||
SynPluginSyncronizedEditBase,
|
SynPluginSyncronizedEditBase, ProjectIntf, SrcEditorIntf, MenuIntf, LazIDEIntf, PackageIntf,
|
||||||
// IDE interface
|
IDEDialogs, IDEHelpIntf, IDEImagesIntf,
|
||||||
MacroIntf, ProjectIntf, SrcEditorIntf, MenuIntf, LazIDEIntf, PackageIntf,
|
|
||||||
IDEDialogs, IDEHelpIntf, IDEWindowIntf, IDEImagesIntf,
|
|
||||||
// IDE units
|
// IDE units
|
||||||
LazarusIDEStrConsts, LazConf, IDECommands, EditorOptions, KeyMapping, Project,
|
LazarusIDEStrConsts, IDECommands, EditorOptions, Project,
|
||||||
WordCompletion, FindReplaceDialog, FindInFilesDlg, IDEProcs, IDEOptionDefs,
|
WordCompletion, FindReplaceDialog, IDEProcs, IDEOptionDefs,
|
||||||
MacroPromptDlg, TransferMacros, CodeContextForm, SrcEditHintFrm,
|
MacroPromptDlg, TransferMacros, CodeContextForm, SrcEditHintFrm,
|
||||||
EnvironmentOpts, MsgView, SearchResultView, InputHistory, CodeMacroPrompt,
|
EnvironmentOpts, MsgView, InputHistory, CodeMacroPrompt,
|
||||||
CodeTemplatesDlg, TodoDlg, TodoList, CodeToolsOptions,
|
CodeTemplatesDlg, TodoDlg, TodoList, CodeToolsOptions,
|
||||||
SortSelectionDlg, EncloseSelectionDlg, DiffDialog, ConDef, InvertAssignTool,
|
SortSelectionDlg, EncloseSelectionDlg, DiffDialog, ConDef, InvertAssignTool,
|
||||||
SourceEditProcs, SourceMarks, CharacterMapDlg, SearchFrm,
|
SourceEditProcs, SourceMarks, CharacterMapDlg, SearchFrm,
|
||||||
@ -753,20 +750,6 @@ type
|
|||||||
property IncrementalSearchStr: string
|
property IncrementalSearchStr: string
|
||||||
read FIncrementalSearchStr write SetIncrementalSearchStr;
|
read FIncrementalSearchStr write SetIncrementalSearchStr;
|
||||||
|
|
||||||
// FindInFiles
|
|
||||||
procedure FindInFilesPerDialog(AProject: TProject);
|
|
||||||
procedure FindInFiles(AProject: TProject; const FindText: string);
|
|
||||||
procedure ShowSearchResultsView;
|
|
||||||
function CreateFindInFilesDialog: TLazFindInFilesDialog;
|
|
||||||
procedure LoadFindInFilesHistory(ADialog: TLazFindInFilesDialog);
|
|
||||||
procedure SaveFindInFilesHistory(ADialog: TLazFindInFilesDialog);
|
|
||||||
procedure FIFSearchProject(AProject: TProject;
|
|
||||||
ADialog: TLazFindInFilesDialog);
|
|
||||||
procedure FIFSearchOpenFiles(ADialog: TLazFindInFilesDialog);
|
|
||||||
procedure FIFSearchDir(ADialog: TLazFindInFilesDialog);
|
|
||||||
function FIFCreateSearchForm(ADialog:TLazFindInFilesDialog): TSearchForm;
|
|
||||||
procedure DoFindInFiles(ASearchForm: TSearchForm);
|
|
||||||
|
|
||||||
// goto line number
|
// goto line number
|
||||||
procedure GotoLineClicked(Sender: TObject);
|
procedure GotoLineClicked(Sender: TObject);
|
||||||
|
|
||||||
@ -919,7 +902,6 @@ type
|
|||||||
fOnReadOnlyChanged: TNotifyEvent;
|
fOnReadOnlyChanged: TNotifyEvent;
|
||||||
FOnShowCodeContext: TOnShowCodeContext;
|
FOnShowCodeContext: TOnShowCodeContext;
|
||||||
FOnShowHintForSource: TOnShowHintForSource;
|
FOnShowHintForSource: TOnShowHintForSource;
|
||||||
FOnShowSearchResultsView: TNotifyEvent;
|
|
||||||
FOnShowUnitInfo: TNotifyEvent;
|
FOnShowUnitInfo: TNotifyEvent;
|
||||||
FOnToggleFormUnitClicked: TNotifyEvent;
|
FOnToggleFormUnitClicked: TNotifyEvent;
|
||||||
FOnToggleObjectInspClicked: TNotifyEvent;
|
FOnToggleObjectInspClicked: TNotifyEvent;
|
||||||
@ -975,8 +957,6 @@ type
|
|||||||
read FOnToggleObjectInspClicked write FOnToggleObjectInspClicked;
|
read FOnToggleObjectInspClicked write FOnToggleObjectInspClicked;
|
||||||
property OnViewJumpHistory: TNotifyEvent
|
property OnViewJumpHistory: TNotifyEvent
|
||||||
read FOnViewJumpHistory write FOnViewJumpHistory;
|
read FOnViewJumpHistory write FOnViewJumpHistory;
|
||||||
property OnShowSearchResultsView: TNotifyEvent
|
|
||||||
read FOnShowSearchResultsView write FOnShowSearchResultsView;
|
|
||||||
property OnPopupMenu: TSrcEditPopupMenuEvent read FOnPopupMenu write FOnPopupMenu;
|
property OnPopupMenu: TSrcEditPopupMenuEvent read FOnPopupMenu write FOnPopupMenu;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -5804,262 +5784,6 @@ Begin
|
|||||||
if TempEditor <> nil then TempEditor.FindPrevious;
|
if TempEditor <> nil then TempEditor.FindPrevious;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
function TSourceNotebook.CreateFindInFilesDialog: TLazFindInFilesDialog;
|
|
||||||
begin
|
|
||||||
Result := TLazFindInFilesDialog.Create(Application);
|
|
||||||
LoadFindInFilesHistory(Result);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSourceNotebook.LoadFindInFilesHistory(ADialog: TLazFindInFilesDialog);
|
|
||||||
|
|
||||||
procedure AssignToComboBox(AComboBox: TComboBox; Strings: TStrings);
|
|
||||||
begin
|
|
||||||
AComboBox.Items.Assign(Strings);
|
|
||||||
if AComboBox.Items.Count>0 then
|
|
||||||
AComboBox.ItemIndex := 0;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure AddFileToComboBox(AComboBox: TComboBox; const Filename: string);
|
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
|
||||||
if Filename='' then exit;
|
|
||||||
for i:=0 to AComboBox.Items.Count-1 do begin
|
|
||||||
if CompareFilenames(Filename,AComboBox.Items[i])=0 then begin
|
|
||||||
// move to front (but not top, top should be the last used directory)
|
|
||||||
if i>2 then
|
|
||||||
AComboBox.Items.Move(i,1);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
// insert in front (but not top, top should be the last used directory)
|
|
||||||
if AComboBox.Items.Count>0 then
|
|
||||||
i:=1
|
|
||||||
else
|
|
||||||
i:=0;
|
|
||||||
AComboBox.Items.Insert(i,Filename);
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
|
||||||
SrcEdit: TSourceEditor;
|
|
||||||
begin
|
|
||||||
if not Assigned(ADialog) then exit;
|
|
||||||
SrcEdit:=GetActiveSE;
|
|
||||||
with ADialog, InputHistories do
|
|
||||||
begin
|
|
||||||
//DebugLn('TSourceNotebook.LoadFindInFilesHistory ',dbgsName(TextToFindComboBox),' ',dbgsName(FindHistory));
|
|
||||||
TextToFindComboBox.Items.Assign(FindHistory);
|
|
||||||
ReplaceTextComboBox.Items.Assign(ReplaceHistory);
|
|
||||||
if not EditorOpts.FindTextAtCursor then begin
|
|
||||||
if TextToFindComboBox.Items.Count>0 then begin
|
|
||||||
//debugln('TSourceNotebook.LoadFindInFilesHistory A TextToFindComboBox.Text=',TextToFindComboBox.Text);
|
|
||||||
TextToFindComboBox.ItemIndex:=0;
|
|
||||||
TextToFindComboBox.SelectAll;
|
|
||||||
//debugln('TSourceNotebook.LoadFindInFilesHistory B TextToFindComboBox.Text=',TextToFindComboBox.Text);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
// show last used directories and directory of current file
|
|
||||||
AssignToComboBox(DirectoryComboBox, FindInFilesPathHistory);
|
|
||||||
if (SrcEdit<>nil) and (FilenameIsAbsolute(SrcEdit.FileName)) then
|
|
||||||
AddFileToComboBox(DirectoryComboBox, ExtractFilePath(SrcEdit.FileName));
|
|
||||||
// show last used file masks
|
|
||||||
AssignToComboBox(FileMaskComboBox, FindInFilesMaskHistory);
|
|
||||||
Options:=FindInFilesSearchOptions;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSourceNotebook.SaveFindInFilesHistory(ADialog: TLazFindInFilesDialog);
|
|
||||||
begin
|
|
||||||
if Assigned(ADialog) then
|
|
||||||
begin
|
|
||||||
with ADialog do
|
|
||||||
begin
|
|
||||||
InputHistories.AddToFindHistory(FindText);
|
|
||||||
InputHistories.AddToFindInFilesPathHistory(DirectoryComboBox.Text);
|
|
||||||
InputHistories.AddToFindInFilesMaskHistory(FileMaskComboBox.Text);
|
|
||||||
InputHistories.FindInFilesSearchOptions:=Options;
|
|
||||||
end;
|
|
||||||
InputHistories.Save;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{Search All the files in a project and add the results to the SearchResultsView
|
|
||||||
Dialog}
|
|
||||||
procedure TSourceNotebook.FIFSearchProject(AProject: TProject;
|
|
||||||
ADialog: TLazFindInFilesDialog);
|
|
||||||
var
|
|
||||||
AnUnitInfo: TUnitInfo;
|
|
||||||
TheFileList: TStringList;
|
|
||||||
SearchForm: TSearchForm;
|
|
||||||
begin
|
|
||||||
try
|
|
||||||
TheFileList:= TStringList.Create;
|
|
||||||
AnUnitInfo:=AProject.FirstPartOfProject;
|
|
||||||
while AnUnitInfo<>nil do begin
|
|
||||||
//Only if file exists on disk.
|
|
||||||
if FilenameIsAbsolute(AnUnitInfo.FileName)
|
|
||||||
and FileExistsUTF8(AnUnitInfo.FileName) then
|
|
||||||
TheFileList.Add(AnUnitInfo.FileName);
|
|
||||||
AnUnitInfo:=AnUnitInfo.NextPartOfProject;
|
|
||||||
end;
|
|
||||||
SearchForm:= FIFCreateSearchForm(ADialog);
|
|
||||||
SearchForm.SearchFileList:= TheFileList;
|
|
||||||
DoFindInFiles(SearchForm);
|
|
||||||
finally
|
|
||||||
FreeAndNil(TheFileList);
|
|
||||||
FreeAndNil(SearchForm);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSourceNotebook.FIFSearchDir(ADialog: TLazFindInFilesDialog);
|
|
||||||
var
|
|
||||||
SearchForm: TSearchForm;
|
|
||||||
begin
|
|
||||||
try
|
|
||||||
SearchForm:= FIFCreateSearchForm(ADialog);
|
|
||||||
SearchForm.SearchFileList:= Nil;
|
|
||||||
DoFindInFiles(SearchForm);
|
|
||||||
finally
|
|
||||||
FreeAndNil(SearchForm);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Procedure TSourceNotebook.DoFindInFiles(ASearchForm: TSearchForm);
|
|
||||||
var
|
|
||||||
ListIndex: integer;
|
|
||||||
begin
|
|
||||||
ShowSearchResultsView;
|
|
||||||
ListIndex:=SearchResultsView.AddSearch(ASearchForm.SearchText,
|
|
||||||
ASearchForm.SearchText,
|
|
||||||
ASearchForm.ReplaceText,
|
|
||||||
ASearchForm.SearchDirectory,
|
|
||||||
ASearchForm.SearchMask,
|
|
||||||
ASearchForm.SearchOptions);
|
|
||||||
|
|
||||||
try
|
|
||||||
SearchResultsView.BeginUpdate(ListIndex);
|
|
||||||
ASearchForm.ResultsList:= SearchResultsView.Items[ListIndex];
|
|
||||||
SearchResultsView.Items[ListIndex].Clear;
|
|
||||||
ASearchForm.ResultsWindow:= ListIndex;
|
|
||||||
try
|
|
||||||
ASearchForm.Show;
|
|
||||||
// update Window Menu, the OnIdle event does not occur while searching
|
|
||||||
MainIDEInterface.UpdateWindowMenu;
|
|
||||||
ASearchForm.DoSearch;
|
|
||||||
except
|
|
||||||
on E: ERegExpr do
|
|
||||||
MessageDlg(lisUEErrorInRegularExpression, E.Message,mtError,
|
|
||||||
[mbCancel],0);
|
|
||||||
end;
|
|
||||||
finally
|
|
||||||
SearchResultsView.EndUpdate(ListIndex);
|
|
||||||
SearchResultsView.ShowOnTop;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSourceNotebook.FIFSearchOpenFiles(ADialog: TLazFindInFilesDialog);
|
|
||||||
var
|
|
||||||
i: integer;
|
|
||||||
TheFileList: TStringList;
|
|
||||||
SearchForm: TSearchForm;
|
|
||||||
begin
|
|
||||||
try
|
|
||||||
TheFileList:= TStringList.Create;
|
|
||||||
for i:= 0 to EditorCount -1 do
|
|
||||||
begin
|
|
||||||
//only if file exists on disk
|
|
||||||
if FilenameIsAbsolute(Editors[i].FileName) and
|
|
||||||
FileExistsUTF8(Editors[i].FileName) then
|
|
||||||
begin
|
|
||||||
TheFileList.Add(Editors[i].FileName);
|
|
||||||
end;//if
|
|
||||||
end;//for
|
|
||||||
SearchForm:= FIFCreateSearchForm(ADialog);
|
|
||||||
SearchForm.SearchFileList:= TheFileList;
|
|
||||||
DoFindInFiles(SearchForm);
|
|
||||||
finally
|
|
||||||
FreeAndNil(TheFileList);
|
|
||||||
FreeAndNil(SearchForm);
|
|
||||||
end;//finally
|
|
||||||
end;//FIFSearchOpenFiles
|
|
||||||
|
|
||||||
{Creates the search form and loads the options selected in the
|
|
||||||
findinfilesdialog}
|
|
||||||
function TSourceNotebook.FIFCreateSearchForm
|
|
||||||
(ADialog: TLazFindInFilesDialog): TSearchForm;
|
|
||||||
begin
|
|
||||||
result:= TSearchForm.Create(SearchResultsView);
|
|
||||||
with result do
|
|
||||||
begin
|
|
||||||
SearchOptions:= ADialog.Options;
|
|
||||||
SearchText:= ADialog.FindText;
|
|
||||||
ReplaceText:= ADialog.ReplaceText;
|
|
||||||
SearchMask:= ADialog.FileMaskComboBox.Text;
|
|
||||||
SearchDirectory:= ADialog.DirectoryComboBox.Text;
|
|
||||||
end;//with
|
|
||||||
end;//FIFCreateSearchForm
|
|
||||||
|
|
||||||
Procedure TSourceNotebook.FindInFilesPerDialog(AProject: TProject);
|
|
||||||
var
|
|
||||||
TempEditor: TSourceEditor;
|
|
||||||
FindText: string;
|
|
||||||
Begin
|
|
||||||
FindText:='';
|
|
||||||
TempEditor := GetActiveSE;
|
|
||||||
if TempEditor <> nil
|
|
||||||
then with TempEditor, EditorComponent do
|
|
||||||
begin
|
|
||||||
if EditorOpts.FindTextAtCursor
|
|
||||||
then begin
|
|
||||||
if SelAvail and (BlockBegin.Y = BlockEnd.Y)
|
|
||||||
then FindText := SelText
|
|
||||||
else FindText := GetWordAtRowCol(LogicalCaretXY);
|
|
||||||
end else begin
|
|
||||||
if InputHistories.FindHistory.Count>0 then
|
|
||||||
FindText:=InputHistories.FindHistory[0];
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
FindInFiles(AProject, FindText);
|
|
||||||
End;
|
|
||||||
|
|
||||||
procedure TSourceNotebook.FindInFiles(AProject: TProject;
|
|
||||||
const FindText: string);
|
|
||||||
begin
|
|
||||||
if FindInFilesDialog = nil then
|
|
||||||
FindInFilesDialog := CreateFindInFilesDialog
|
|
||||||
else
|
|
||||||
LoadFindInFilesHistory(FindInFilesDialog);
|
|
||||||
|
|
||||||
// if there is no FindText, use the most recently used FindText
|
|
||||||
FindInFilesDialog.FindText:= FindText;
|
|
||||||
if (FindInFilesDialog.FindText='') and (InputHistories.FindHistory.Count > 0) then
|
|
||||||
FindInFilesDialog.FindText:=InputHistories.FindHistory[0];
|
|
||||||
|
|
||||||
// disable replace. Find in files is often called,
|
|
||||||
// but almost never to replace with the same parameters
|
|
||||||
FindInFilesDialog.Options:=
|
|
||||||
FindInFilesDialog.Options-[fifReplace,fifReplaceAll];
|
|
||||||
if FindInFilesDialog.ShowModal=mrOk then
|
|
||||||
begin
|
|
||||||
SaveFindInFilesHistory(FindInFilesDialog);
|
|
||||||
|
|
||||||
if FindInFilesDialog.FindText <>'' then
|
|
||||||
begin
|
|
||||||
case FindInFilesDialog.WhereRadioGroup.ItemIndex of
|
|
||||||
0: FIFSearchProject(AProject, FindInFilesDialog);
|
|
||||||
1: FIFSearchOpenFiles(FindInFilesDialog);
|
|
||||||
2: FIFSearchDir(FindInFilesDialog);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSourceNotebook.ShowSearchResultsView;
|
|
||||||
begin
|
|
||||||
if Assigned(Manager.OnShowSearchResultsView) then Manager.OnShowSearchResultsView(Self);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSourceNotebook.GotoLineClicked(Sender: TObject);
|
procedure TSourceNotebook.GotoLineClicked(Sender: TObject);
|
||||||
var
|
var
|
||||||
SrcEdit: TSourceEditor;
|
SrcEdit: TSourceEditor;
|
||||||
|
Loading…
Reference in New Issue
Block a user