mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 09:16:16 +02:00
IDE: find in files: search in multiple directories
git-svn-id: trunk@45992 -
This commit is contained in:
parent
3e8d8b891e
commit
fc22ff99e3
@ -12,7 +12,7 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
Constraints.MinWidth = 400
|
Constraints.MinWidth = 400
|
||||||
OnClose = FormClose
|
OnClose = FormClose
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
LCLVersion = '1.1'
|
LCLVersion = '1.3'
|
||||||
object OptionsCheckGroupBox: TCheckGroup
|
object OptionsCheckGroupBox: TCheckGroup
|
||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
AnchorSideTop.Control = ReplaceTextComboBox
|
AnchorSideTop.Control = ReplaceTextComboBox
|
||||||
@ -21,7 +21,7 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 83
|
Height = 83
|
||||||
Top = 76
|
Top = 72
|
||||||
Width = 449
|
Width = 449
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
AutoFill = True
|
AutoFill = True
|
||||||
@ -38,8 +38,8 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
ChildSizing.ControlsPerLine = 2
|
ChildSizing.ControlsPerLine = 2
|
||||||
ClientHeight = 62
|
ClientHeight = 66
|
||||||
ClientWidth = 441
|
ClientWidth = 445
|
||||||
Columns = 2
|
Columns = 2
|
||||||
Items.Strings = (
|
Items.Strings = (
|
||||||
'Case sensitive'
|
'Case sensitive'
|
||||||
@ -60,7 +60,7 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 83
|
Height = 83
|
||||||
Top = 165
|
Top = 161
|
||||||
Width = 449
|
Width = 449
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
AutoFill = True
|
AutoFill = True
|
||||||
@ -77,8 +77,8 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
ChildSizing.ControlsPerLine = 2
|
ChildSizing.ControlsPerLine = 2
|
||||||
ClientHeight = 62
|
ClientHeight = 66
|
||||||
ClientWidth = 441
|
ClientWidth = 445
|
||||||
Columns = 2
|
Columns = 2
|
||||||
ItemIndex = 1
|
ItemIndex = 1
|
||||||
Items.Strings = (
|
Items.Strings = (
|
||||||
@ -97,75 +97,77 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
AnchorSideRight.Control = Owner
|
AnchorSideRight.Control = Owner
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 131
|
Height = 125
|
||||||
Top = 254
|
Top = 250
|
||||||
Width = 449
|
Width = 449
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
Caption = 'Directory Options'
|
Caption = 'Directory Options'
|
||||||
ClientHeight = 110
|
ClientHeight = 108
|
||||||
ClientWidth = 441
|
ClientWidth = 445
|
||||||
Enabled = False
|
Enabled = False
|
||||||
TabOrder = 5
|
TabOrder = 5
|
||||||
object DirectoryLabel: TLabel
|
object DirectoriesLabel: TLabel
|
||||||
AnchorSideLeft.Control = DirectoryOptionsGroupBox
|
AnchorSideLeft.Control = DirectoryOptionsGroupBox
|
||||||
AnchorSideTop.Control = DirectoryComboBox
|
AnchorSideTop.Control = DirectoriesComboBox
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 17
|
Height = 15
|
||||||
Top = 12
|
Top = 12
|
||||||
Width = 61
|
Width = 65
|
||||||
BorderSpacing.Left = 6
|
BorderSpacing.Left = 6
|
||||||
Caption = 'Directory:'
|
Caption = 'Directories:'
|
||||||
FocusControl = DirectoryComboBox
|
FocusControl = DirectoriesComboBox
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object FileMaskLabel: TLabel
|
object FileMaskLabel: TLabel
|
||||||
AnchorSideLeft.Control = DirectoryOptionsGroupBox
|
AnchorSideLeft.Control = DirectoryOptionsGroupBox
|
||||||
AnchorSideTop.Control = DirectoryComboBox
|
AnchorSideTop.Control = DirectoriesComboBox
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 17
|
Height = 15
|
||||||
Top = 47
|
Top = 45
|
||||||
Width = 59
|
Width = 49
|
||||||
BorderSpacing.Left = 6
|
BorderSpacing.Left = 6
|
||||||
BorderSpacing.Top = 12
|
BorderSpacing.Top = 12
|
||||||
Caption = 'File mask'
|
Caption = 'File mask'
|
||||||
FocusControl = FileMaskComboBox
|
FocusControl = FileMaskComboBox
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object DirectoryComboBox: TComboBox
|
object DirectoriesComboBox: TComboBox
|
||||||
AnchorSideLeft.Control = DirectoryLabel
|
AnchorSideLeft.Control = DirectoriesLabel
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = DirectoryOptionsGroupBox
|
AnchorSideTop.Control = DirectoryOptionsGroupBox
|
||||||
AnchorSideRight.Control = DirectoryBrowse
|
AnchorSideRight.Control = DirectoriesBrowse
|
||||||
Left = 73
|
Left = 77
|
||||||
Height = 29
|
Height = 27
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 330
|
Width = 335
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
BorderSpacing.Left = 6
|
BorderSpacing.Left = 6
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
BorderSpacing.Right = 6
|
BorderSpacing.Right = 6
|
||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
|
ParentShowHint = False
|
||||||
|
ShowHint = True
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object DirectoryBrowse: TBitBtn
|
object DirectoriesBrowse: TBitBtn
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = DirectoryComboBox
|
AnchorSideTop.Control = DirectoriesComboBox
|
||||||
AnchorSideRight.Control = DirectoryOptionsGroupBox
|
AnchorSideRight.Control = DirectoryOptionsGroupBox
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 409
|
Left = 418
|
||||||
Height = 28
|
Height = 27
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 26
|
Width = 21
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Right = 6
|
BorderSpacing.Right = 6
|
||||||
Caption = '...'
|
Caption = '...'
|
||||||
Layout = blGlyphTop
|
Layout = blGlyphTop
|
||||||
OnClick = DirectoryBrowseClick
|
OnClick = DirectoriesBrowseClick
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object FileMaskComboBox: TComboBox
|
object FileMaskComboBox: TComboBox
|
||||||
@ -173,12 +175,12 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = FileMaskLabel
|
AnchorSideTop.Control = FileMaskLabel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Control = DirectoryComboBox
|
AnchorSideRight.Control = DirectoriesComboBox
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 71
|
Left = 61
|
||||||
Height = 29
|
Height = 27
|
||||||
Top = 41
|
Top = 39
|
||||||
Width = 332
|
Width = 351
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
BorderSpacing.Left = 6
|
BorderSpacing.Left = 6
|
||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
@ -190,9 +192,9 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
AnchorSideTop.Control = FileMaskComboBox
|
AnchorSideTop.Control = FileMaskComboBox
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 22
|
Height = 24
|
||||||
Top = 82
|
Top = 78
|
||||||
Width = 170
|
Width = 151
|
||||||
BorderSpacing.Left = 6
|
BorderSpacing.Left = 6
|
||||||
BorderSpacing.Top = 12
|
BorderSpacing.Top = 12
|
||||||
BorderSpacing.Bottom = 6
|
BorderSpacing.Bottom = 6
|
||||||
@ -204,8 +206,8 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
end
|
end
|
||||||
object ButtonPanel1: TButtonPanel
|
object ButtonPanel1: TButtonPanel
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 33
|
Height = 28
|
||||||
Top = 398
|
Top = 403
|
||||||
Width = 449
|
Width = 449
|
||||||
OKButton.Name = 'OKButton'
|
OKButton.Name = 'OKButton'
|
||||||
OKButton.DefaultCaption = True
|
OKButton.DefaultCaption = True
|
||||||
@ -229,10 +231,10 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = Owner
|
AnchorSideRight.Control = Owner
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 88
|
Left = 82
|
||||||
Height = 29
|
Height = 27
|
||||||
Top = 41
|
Top = 39
|
||||||
Width = 367
|
Width = 373
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
AutoComplete = True
|
AutoComplete = True
|
||||||
AutoCompleteText = [cbactEnabled, cbactEndOfLineComplete, cbactRetainPrefixCase, cbactSearchAscending]
|
AutoCompleteText = [cbactEnabled, cbactEndOfLineComplete, cbactRetainPrefixCase, cbactSearchAscending]
|
||||||
@ -249,9 +251,9 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
AnchorSideTop.Control = ReplaceTextComboBox
|
AnchorSideTop.Control = ReplaceTextComboBox
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 22
|
Height = 24
|
||||||
Top = 44
|
Top = 40
|
||||||
Width = 76
|
Width = 70
|
||||||
BorderSpacing.Left = 6
|
BorderSpacing.Left = 6
|
||||||
Caption = 'Replace'
|
Caption = 'Replace'
|
||||||
Enabled = False
|
Enabled = False
|
||||||
@ -263,9 +265,9 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
AnchorSideTop.Control = TextToFindComboBox
|
AnchorSideTop.Control = TextToFindComboBox
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 17
|
Height = 15
|
||||||
Top = 12
|
Top = 12
|
||||||
Width = 75
|
Width = 69
|
||||||
BorderSpacing.Left = 6
|
BorderSpacing.Left = 6
|
||||||
Caption = 'Text To Find:'
|
Caption = 'Text To Find:'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
@ -276,10 +278,10 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
AnchorSideTop.Control = Owner
|
AnchorSideTop.Control = Owner
|
||||||
AnchorSideRight.Control = Owner
|
AnchorSideRight.Control = Owner
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 87
|
Left = 81
|
||||||
Height = 29
|
Height = 27
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 368
|
Width = 374
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
AutoComplete = True
|
AutoComplete = True
|
||||||
AutoCompleteText = [cbactEnabled, cbactEndOfLineComplete, cbactRetainPrefixCase, cbactSearchAscending]
|
AutoCompleteText = [cbactEnabled, cbactEndOfLineComplete, cbactRetainPrefixCase, cbactSearchAscending]
|
||||||
@ -292,7 +294,7 @@ object LazFindInFilesDialog: TLazFindInFilesDialog
|
|||||||
object SelectDirectoryDialog: TSelectDirectoryDialog
|
object SelectDirectoryDialog: TSelectDirectoryDialog
|
||||||
FilterIndex = 0
|
FilterIndex = 0
|
||||||
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]
|
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]
|
||||||
left = 260
|
left = 180
|
||||||
top = 215
|
top = 70
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -17,10 +17,14 @@ unit FindInFilesDlg;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, LCLIntf, Controls, StdCtrls, Forms, Buttons,
|
Classes, SysUtils,
|
||||||
ExtCtrls, FileProcs, LazarusIDEStrConsts, Dialogs, SynEditTypes, ButtonPanel,
|
FileProcs,
|
||||||
|
LCLProc, LCLIntf, Controls, StdCtrls, Forms, Buttons, ExtCtrls, Dialogs,
|
||||||
|
ButtonPanel,
|
||||||
|
SynEditTypes, SynEdit,
|
||||||
MacroIntf, IDEWindowIntf, SrcEditorIntf, IDEHelpIntf, IDEDialogs,
|
MacroIntf, IDEWindowIntf, SrcEditorIntf, IDEHelpIntf, IDEDialogs,
|
||||||
InputHistory, EditorOptions, SearchFrm, Project, SynEdit, SearchResultView;
|
LazarusIDEStrConsts, InputHistory, EditorOptions, Project, IDEProcs,
|
||||||
|
SearchFrm, SearchResultView;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TLazFindInFilesDialog }
|
{ TLazFindInFilesDialog }
|
||||||
@ -31,9 +35,9 @@ type
|
|||||||
ReplaceTextComboBox: TComboBox;
|
ReplaceTextComboBox: TComboBox;
|
||||||
IncludeSubDirsCheckBox: TCheckBox;
|
IncludeSubDirsCheckBox: TCheckBox;
|
||||||
FileMaskComboBox: TComboBox;
|
FileMaskComboBox: TComboBox;
|
||||||
DirectoryBrowse: TBitBtn;
|
DirectoriesBrowse: TBitBtn;
|
||||||
DirectoryComboBox: TComboBox;
|
DirectoriesComboBox: TComboBox;
|
||||||
DirectoryLabel: TLabel;
|
DirectoriesLabel: TLabel;
|
||||||
FileMaskLabel: TLabel;
|
FileMaskLabel: TLabel;
|
||||||
DirectoryOptionsGroupBox: TGroupBox;
|
DirectoryOptionsGroupBox: TGroupBox;
|
||||||
OptionsCheckGroupBox: TCheckGroup;
|
OptionsCheckGroupBox: TCheckGroup;
|
||||||
@ -41,7 +45,7 @@ type
|
|||||||
TextToFindComboBox: TComboBox;
|
TextToFindComboBox: TComboBox;
|
||||||
TextToFindLabel: TLabel;
|
TextToFindLabel: TLabel;
|
||||||
WhereRadioGroup: TRadioGroup;
|
WhereRadioGroup: TRadioGroup;
|
||||||
procedure DirectoryBrowseClick(Sender: TObject);
|
procedure DirectoriesBrowseClick(Sender: TObject);
|
||||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure HelpButtonClick(Sender: TObject);
|
procedure HelpButtonClick(Sender: TObject);
|
||||||
@ -65,12 +69,13 @@ 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;
|
||||||
|
function GetBaseDirectory: string;
|
||||||
procedure LoadHistory;
|
procedure LoadHistory;
|
||||||
procedure SaveHistory;
|
procedure SaveHistory;
|
||||||
procedure FindInFilesPerDialog(AProject: TProject);
|
procedure FindInFilesPerDialog(AProject: TProject);
|
||||||
procedure InitFromLazSearch(Sender: TObject);
|
procedure InitFromLazSearch(Sender: TObject);
|
||||||
procedure FindInFiles(AProject: TProject; const AFindText: string);
|
procedure FindInFiles(AProject: TProject; const AFindText: string);
|
||||||
function GetResolvedDirectory: string;
|
function GetResolvedDirectories: string;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function FindInFilesDialog: TLazFindInFilesDialog;
|
function FindInFilesDialog: TLazFindInFilesDialog;
|
||||||
@ -119,18 +124,28 @@ begin
|
|||||||
DirectoryOptionsGroupBox.Enabled := (WhereRadioGroup.ItemIndex = ItemIndDirectories)
|
DirectoryOptionsGroupBox.Enabled := (WhereRadioGroup.ItemIndex = ItemIndDirectories)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazFindInFilesDialog.DirectoryBrowseClick(Sender: TObject);
|
procedure TLazFindInFilesDialog.DirectoriesBrowseClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
Dir: String;
|
Dir: String;
|
||||||
|
OldDirs: String;
|
||||||
|
p: Integer;
|
||||||
begin
|
begin
|
||||||
InitIDEFileDialog(SelectDirectoryDialog);
|
InitIDEFileDialog(SelectDirectoryDialog);
|
||||||
Dir:=GetResolvedDirectory;
|
// use the first directory as initialdir for the dialog
|
||||||
if DirectoryExistsUTF8(Dir) then
|
OldDirs:=GetResolvedDirectories;
|
||||||
|
p:=1;
|
||||||
|
repeat
|
||||||
|
Dir:=GetNextDirectoryInSearchPath(OldDirs,p);
|
||||||
|
if Dir='' then break;
|
||||||
|
if DirectoryExistsUTF8(Dir) then break;
|
||||||
|
until false;
|
||||||
|
if Dir<>'' then
|
||||||
SelectDirectoryDialog.InitialDir := Dir
|
SelectDirectoryDialog.InitialDir := Dir
|
||||||
else
|
else
|
||||||
SelectDirectoryDialog.InitialDir := GetCurrentDirUTF8;
|
SelectDirectoryDialog.InitialDir := GetBaseDirectory;
|
||||||
|
|
||||||
if SelectDirectoryDialog.Execute then
|
if SelectDirectoryDialog.Execute then
|
||||||
DirectoryComboBox.Text := AppendPathDelim(TrimFilename(SelectDirectoryDialog.FileName));
|
DirectoriesComboBox.Text := AppendPathDelim(TrimFilename(SelectDirectoryDialog.FileName));
|
||||||
StoreIDEFileDialog(SelectDirectoryDialog);
|
StoreIDEFileDialog(SelectDirectoryDialog);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -160,7 +175,8 @@ begin
|
|||||||
WhereRadioGroup.Items[ItemIndActiveFile] := lisFindFilesearchInActiveFile;
|
WhereRadioGroup.Items[ItemIndActiveFile] := lisFindFilesearchInActiveFile;
|
||||||
|
|
||||||
DirectoryOptionsGroupBox.Caption := lisFindFileDirectoryOptions;
|
DirectoryOptionsGroupBox.Caption := lisFindFileDirectoryOptions;
|
||||||
DirectoryLabel.Caption := lisFindFileDirectory;
|
DirectoriesComboBox.Hint:=lisMultipleDirectoriesAreSeparatedWithSemicolons;
|
||||||
|
DirectoriesLabel.Caption := lisFindFileDirectory;
|
||||||
FileMaskLabel.Caption := lisFindFileFileMask;
|
FileMaskLabel.Caption := lisFindFileFileMask;
|
||||||
|
|
||||||
IncludeSubDirsCheckBox.Caption := lisFindFileIncludeSubDirectories;
|
IncludeSubDirsCheckBox.Caption := lisFindFileIncludeSubDirectories;
|
||||||
@ -185,14 +201,20 @@ end;
|
|||||||
procedure TLazFindInFilesDialog.OKButtonClick(Sender : TObject);
|
procedure TLazFindInFilesDialog.OKButtonClick(Sender : TObject);
|
||||||
var
|
var
|
||||||
Dir: String;
|
Dir: String;
|
||||||
|
p: Integer;
|
||||||
begin
|
begin
|
||||||
Dir:=GetResolvedDirectory;
|
if (WhereRadioGroup.ItemIndex=ItemIndDirectories) then
|
||||||
if (WhereRadioGroup.ItemIndex=ItemIndDirectories) and not DirectoryExistsUTF8(Dir) then
|
|
||||||
begin
|
begin
|
||||||
IDEMessageDialog(lisEnvOptDlgDirectoryNotFound,
|
Dir:=GetResolvedDirectories;
|
||||||
Format(dlgSeachDirectoryNotFound,[Dir]),
|
p:=1;
|
||||||
mtWarning, [mbOk]);
|
Dir:=GetNextDirectoryInSearchPath(Dir,p);
|
||||||
ModalResult:=mrNone;
|
if not DirectoryExistsUTF8(Dir) then
|
||||||
|
begin
|
||||||
|
IDEMessageDialog(lisEnvOptDlgDirectoryNotFound,
|
||||||
|
Format(dlgSeachDirectoryNotFound,[Dir]),
|
||||||
|
mtWarning, [mbOk]);
|
||||||
|
ModalResult:=mrNone;
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -272,6 +294,15 @@ begin
|
|||||||
ButtonPanel1.OKButton.Caption := lisBtnFind;
|
ButtonPanel1.OKButton.Caption := lisBtnFind;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLazFindInFilesDialog.GetBaseDirectory: string;
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
if Project1<>nil then
|
||||||
|
Result:=Project1.ProjectDirectory;
|
||||||
|
if Result='' then
|
||||||
|
Result:=GetCurrentDirUTF8;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TLazFindInFilesDialog.LoadHistory;
|
procedure TLazFindInFilesDialog.LoadHistory;
|
||||||
|
|
||||||
procedure AssignToComboBox(AComboBox: TComboBox; Strings: TStrings);
|
procedure AssignToComboBox(AComboBox: TComboBox; Strings: TStrings);
|
||||||
@ -319,11 +350,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
// show last used directories and directory of current file
|
// show last used directories and directory of current file
|
||||||
AssignToComboBox(DirectoryComboBox, InputHistories.FindInFilesPathHistory);
|
AssignToComboBox(DirectoriesComboBox, InputHistories.FindInFilesPathHistory);
|
||||||
if (SrcEdit<>nil) and (FilenameIsAbsolute(SrcEdit.FileName)) then
|
if (SrcEdit<>nil) and (FilenameIsAbsolute(SrcEdit.FileName)) then
|
||||||
AddFileToComboBox(DirectoryComboBox, ExtractFilePath(SrcEdit.FileName));
|
AddFileToComboBox(DirectoriesComboBox, ExtractFilePath(SrcEdit.FileName));
|
||||||
if DirectoryComboBox.Items.Count>0 then
|
if DirectoriesComboBox.Items.Count>0 then
|
||||||
DirectoryComboBox.Text:=DirectoryComboBox.Items[0];
|
DirectoriesComboBox.Text:=DirectoriesComboBox.Items[0];
|
||||||
// show last used file masks
|
// show last used file masks
|
||||||
AssignToComboBox(FileMaskComboBox, InputHistories.FindInFilesMaskHistory);
|
AssignToComboBox(FileMaskComboBox, InputHistories.FindInFilesMaskHistory);
|
||||||
Options := InputHistories.FindInFilesSearchOptions;
|
Options := InputHistories.FindInFilesSearchOptions;
|
||||||
@ -334,7 +365,7 @@ var
|
|||||||
Dir: String;
|
Dir: String;
|
||||||
begin
|
begin
|
||||||
InputHistories.AddToFindHistory(FindText);
|
InputHistories.AddToFindHistory(FindText);
|
||||||
Dir:=AppendPathDelim(TrimFilename(DirectoryComboBox.Text));
|
Dir:=AppendPathDelim(TrimFilename(DirectoriesComboBox.Text));
|
||||||
if Dir<>'' then
|
if Dir<>'' then
|
||||||
InputHistories.AddToFindInFilesPathHistory(Dir);
|
InputHistories.AddToFindInFilesPathHistory(Dir);
|
||||||
InputHistories.AddToFindInFilesMaskHistory(FileMaskComboBox.Text);
|
InputHistories.AddToFindInFilesMaskHistory(FileMaskComboBox.Text);
|
||||||
@ -369,9 +400,9 @@ procedure TLazFindInFilesDialog.InitFromLazSearch(Sender: TObject);
|
|||||||
var
|
var
|
||||||
Dir: String;
|
Dir: String;
|
||||||
begin
|
begin
|
||||||
Dir:=AppendPathDelim(TrimFilename(TLazSearch(Sender).SearchDirectory));
|
Dir:=AppendPathDelim(TrimFilename(TLazSearch(Sender).SearchDirectories));
|
||||||
if Dir<>'' then
|
if Dir<>'' then
|
||||||
DirectoryComboBox.Text:= Dir;
|
DirectoriesComboBox.Text:= Dir;
|
||||||
Options:= TLazSearch(Sender).SearchOptions;
|
Options:= TLazSearch(Sender).SearchOptions;
|
||||||
FileMaskComboBox.Text:= TLazSearch(Sender).SearchMask;
|
FileMaskComboBox.Text:= TLazSearch(Sender).SearchMask;
|
||||||
end;
|
end;
|
||||||
@ -396,11 +427,11 @@ begin
|
|||||||
|
|
||||||
SearchForm:= TSearchProgressForm.Create(SearchResultsView);
|
SearchForm:= TSearchProgressForm.Create(SearchResultsView);
|
||||||
with SearchForm do begin
|
with SearchForm do begin
|
||||||
SearchOptions := self.Options;
|
SearchOptions := self.Options;
|
||||||
SearchText := self.FindText;
|
SearchText := self.FindText;
|
||||||
ReplaceText := self.ReplaceText;
|
ReplaceText := self.ReplaceText;
|
||||||
SearchMask := self.FileMaskComboBox.Text;
|
SearchMask := self.FileMaskComboBox.Text;
|
||||||
SearchDirectory := self.GetResolvedDirectory;
|
SearchDirectories := self.GetResolvedDirectories;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -419,11 +450,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLazFindInFilesDialog.GetResolvedDirectory: string;
|
function TLazFindInFilesDialog.GetResolvedDirectories: string;
|
||||||
begin
|
begin
|
||||||
Result:=DirectoryComboBox.Text;
|
Result:=DirectoriesComboBox.Text;
|
||||||
IDEMacros.SubstituteMacros(Result);
|
IDEMacros.SubstituteMacros(Result);
|
||||||
Result:=TrimAndExpandDirectory(Result);
|
Result:=TrimSearchPath(Result,GetBaseDirectory,true,true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -123,7 +123,7 @@ function FindProgram(const Programname, BaseDirectory: string;
|
|||||||
|
|
||||||
// search paths
|
// search paths
|
||||||
function TrimSearchPath(const SearchPath, BaseDirectory: string;
|
function TrimSearchPath(const SearchPath, BaseDirectory: string;
|
||||||
DeleteDoubles: boolean = false): string;
|
DeleteDoubles: boolean = false; ExpandPaths: boolean = false): string;
|
||||||
function MergeSearchPaths(const OldSearchPath, AddSearchPath: string): string;
|
function MergeSearchPaths(const OldSearchPath, AddSearchPath: string): string;
|
||||||
procedure MergeSearchPaths(SearchPath: TStrings; const AddSearchPath: string);
|
procedure MergeSearchPaths(SearchPath: TStrings; const AddSearchPath: string);
|
||||||
function RemoveSearchPaths(const SearchPath, RemoveSearchPath: string): string;
|
function RemoveSearchPaths(const SearchPath, RemoveSearchPath: string): string;
|
||||||
@ -1363,7 +1363,7 @@ end;
|
|||||||
- removes doubles
|
- removes doubles
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
function TrimSearchPath(const SearchPath, BaseDirectory: string;
|
function TrimSearchPath(const SearchPath, BaseDirectory: string;
|
||||||
DeleteDoubles: boolean): string;
|
DeleteDoubles: boolean; ExpandPaths: boolean): string;
|
||||||
var
|
var
|
||||||
CurPath: String;
|
CurPath: String;
|
||||||
EndPos: Integer;
|
EndPos: Integer;
|
||||||
@ -1386,7 +1386,9 @@ begin
|
|||||||
CurPath:=copy(SearchPath,StartPos,EndPos-StartPos);
|
CurPath:=copy(SearchPath,StartPos,EndPos-StartPos);
|
||||||
if CurPath<>'' then begin
|
if CurPath<>'' then begin
|
||||||
// non empty path => expand, trim and normalize
|
// non empty path => expand, trim and normalize
|
||||||
if (BaseDir<>'') and (not FilenameIsAbsolute(CurPath)) then
|
if ExpandPaths then
|
||||||
|
CurPath:=TrimAndExpandDirectory(CurPath,BaseDir)
|
||||||
|
else if (BaseDir<>'') and (not FilenameIsAbsolute(CurPath)) then
|
||||||
CurPath:=BaseDir+CurPath;
|
CurPath:=BaseDir+CurPath;
|
||||||
CurPath:=ChompPathDelim(TrimFilename(CurPath));
|
CurPath:=ChompPathDelim(TrimFilename(CurPath));
|
||||||
if CurPath='' then CurPath:='.';
|
if CurPath='' then CurPath:='.';
|
||||||
|
@ -3748,6 +3748,8 @@ resourcestring
|
|||||||
lisFindFilesearchInDirectories = 'search in &directories';
|
lisFindFilesearchInDirectories = 'search in &directories';
|
||||||
lisFindFileDirectoryOptions = 'Directory options';
|
lisFindFileDirectoryOptions = 'Directory options';
|
||||||
lisFindFileDirectory = 'D&irectory';
|
lisFindFileDirectory = 'D&irectory';
|
||||||
|
lisMultipleDirectoriesAreSeparatedWithSemicolons = 'Multiple directories are'
|
||||||
|
+' separated with semicolons';
|
||||||
lisFindFileFileMask = 'Fi&le mask';
|
lisFindFileFileMask = 'Fi&le mask';
|
||||||
lisFindFileIncludeSubDirectories = 'Include &sub directories';
|
lisFindFileIncludeSubDirectories = 'Include &sub directories';
|
||||||
lisFindFileOnlyTextFiles = 'Only text files';
|
lisFindFileOnlyTextFiles = 'Only text files';
|
||||||
|
@ -39,7 +39,7 @@ uses
|
|||||||
// IDEIntf
|
// IDEIntf
|
||||||
IDEWindowIntf, LazIDEIntf, SrcEditorIntf, IDEDialogs, MainIntf,
|
IDEWindowIntf, LazIDEIntf, SrcEditorIntf, IDEDialogs, MainIntf,
|
||||||
// ide
|
// ide
|
||||||
LazarusIDEStrConsts, InputHistory, SearchResultView, Project;
|
LazarusIDEStrConsts, InputHistory, IDEProcs, SearchResultView, Project;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -77,14 +77,14 @@ type
|
|||||||
fSearchFileList: TStringList;
|
fSearchFileList: TStringList;
|
||||||
fSearchFiles: boolean;
|
fSearchFiles: boolean;
|
||||||
fSearchFor: String;
|
fSearchFor: String;
|
||||||
fTheDirectory: string;
|
fDirectories: string;
|
||||||
fSearchOpen: boolean;
|
fSearchOpen: boolean;
|
||||||
fSearchActive: boolean;
|
fSearchActive: boolean;
|
||||||
fSearchProject: boolean;
|
fSearchProject: boolean;
|
||||||
fAborting: boolean;
|
fAborting: boolean;
|
||||||
fLastUpdateProgress: DWORD;
|
fLastUpdateProgress: DWORD;
|
||||||
fWasActive: boolean;
|
fWasActive: boolean;
|
||||||
procedure DoFindInFiles(ADirectory: string);
|
procedure DoFindInFiles(ADirectories: string);
|
||||||
procedure DoFindInSearchList;
|
procedure DoFindInSearchList;
|
||||||
procedure SetResultsList(const AValue: TStrings);
|
procedure SetResultsList(const AValue: TStrings);
|
||||||
procedure UpdateMatches;
|
procedure UpdateMatches;
|
||||||
@ -102,7 +102,7 @@ type
|
|||||||
procedure DoSearchDir;
|
procedure DoSearchDir;
|
||||||
procedure DoSearchProject(AProject: TProject);
|
procedure DoSearchProject(AProject: TProject);
|
||||||
public
|
public
|
||||||
property SearchDirectory: string read fTheDirectory write fTheDirectory;
|
property SearchDirectories: string read fDirectories write fDirectories;
|
||||||
property SearchText: string read fSearchFor write fSearchFor;
|
property SearchText: string read fSearchFor write fSearchFor;
|
||||||
property ReplaceText: string read FReplaceText write FReplaceText;
|
property ReplaceText: string read FReplaceText write FReplaceText;
|
||||||
property SearchOptions: TLazFindInFileSearchOptions read GetOptions
|
property SearchOptions: TLazFindInFileSearchOptions read GetOptions
|
||||||
@ -761,7 +761,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
try
|
try
|
||||||
if fSearchFiles then
|
if fSearchFiles then
|
||||||
DoFindInFiles(fTheDirectory);
|
DoFindInFiles(fDirectories);
|
||||||
if fSearchProject or fSearchOpen or fSearchActive then
|
if fSearchProject or fSearchOpen or fSearchActive then
|
||||||
DoFindInSearchList;
|
DoFindInSearchList;
|
||||||
if Assigned(fResultsList) then begin
|
if Assigned(fResultsList) then begin
|
||||||
@ -849,19 +849,29 @@ end;
|
|||||||
|
|
||||||
{ TSearchProgressForm }
|
{ TSearchProgressForm }
|
||||||
|
|
||||||
procedure TSearchProgressForm.DoFindInFiles(ADirectory: string);
|
procedure TSearchProgressForm.DoFindInFiles(ADirectories: string);
|
||||||
var
|
var
|
||||||
Searcher: TLazFileSearcher;
|
Searcher: TLazFileSearcher;
|
||||||
|
SearchPath: String;
|
||||||
|
p: Integer;
|
||||||
|
Dir: String;
|
||||||
begin
|
begin
|
||||||
//if we have a list and a valid directory
|
// if we have a list and a valid directory
|
||||||
if (DirPathExists(ADirectory)) then
|
SearchPath:='';
|
||||||
begin
|
p:=1;
|
||||||
Searcher := TLazFileSearcher.Create(Self);
|
repeat
|
||||||
try
|
Dir:=GetNextDirectoryInSearchPath(ADirectories,p);
|
||||||
Searcher.Search(ADirectory, FMask, FRecursive);
|
if Dir='' then break;
|
||||||
finally
|
if DirPathExists(Dir) then
|
||||||
Searcher.Free;
|
SearchPath:=MergeSearchPaths(SearchPath,Dir);
|
||||||
end;
|
until false;
|
||||||
|
if SearchPath='' then
|
||||||
|
exit;
|
||||||
|
Searcher := TLazFileSearcher.Create(Self);
|
||||||
|
try
|
||||||
|
Searcher.Search(SearchPath, FMask, FRecursive);
|
||||||
|
finally
|
||||||
|
Searcher.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -953,7 +963,7 @@ begin
|
|||||||
Cnt:= 0;
|
Cnt:= 0;
|
||||||
LazarusIDE.DoShowSearchResultsView(False);
|
LazarusIDE.DoShowSearchResultsView(False);
|
||||||
ListPage:=SearchResultsView.AddSearch(SearchText,SearchText,
|
ListPage:=SearchResultsView.AddSearch(SearchText,SearchText,
|
||||||
ReplaceText,SearchDirectory,SearchMask,SearchOptions);
|
ReplaceText,SearchDirectories,SearchMask,SearchOptions);
|
||||||
try
|
try
|
||||||
(* BeginUpdate prevents ListPage from being closed,
|
(* BeginUpdate prevents ListPage from being closed,
|
||||||
other pages can still be closed or inserted, so PageIndex can change *)
|
other pages can still be closed or inserted, so PageIndex can change *)
|
||||||
|
@ -75,15 +75,15 @@ type
|
|||||||
FReplaceText: string;
|
FReplaceText: string;
|
||||||
fSearchString: string;
|
fSearchString: string;
|
||||||
fSearchOptions: TLazFindInFileSearchOptions;
|
fSearchOptions: TLazFindInFileSearchOptions;
|
||||||
fSearchDirectory: string;
|
fSearchDirectories: string;
|
||||||
fSearchMask: string;
|
fSearchMask: string;
|
||||||
public
|
public
|
||||||
property SearchString: string read fSearchString write fSearchString;
|
property SearchString: string read fSearchString write fSearchString;
|
||||||
property ReplaceText: string read FReplaceText write FReplaceText;
|
property ReplaceText: string read FReplaceText write FReplaceText;
|
||||||
property SearchOptions: TLazFindInFileSearchOptions read fSearchOptions
|
property SearchOptions: TLazFindInFileSearchOptions read fSearchOptions
|
||||||
write fSearchOptions;
|
write fSearchOptions;
|
||||||
property SearchDirectory: string read fSearchDirectory
|
property SearchDirectories: string read fSearchDirectories
|
||||||
write fSearchDirectory;
|
write fSearchDirectories;
|
||||||
property SearchMask: string read fSearchMask write fSearchMask;
|
property SearchMask: string read fSearchMask write fSearchMask;
|
||||||
end;//TLazSearch
|
end;//TLazSearch
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ type
|
|||||||
function AddSearch(const ResultsName: string;
|
function AddSearch(const ResultsName: string;
|
||||||
const SearchText: string;
|
const SearchText: string;
|
||||||
const ReplaceText: string;
|
const ReplaceText: string;
|
||||||
const ADirectory: string;
|
const ADirectories: string;
|
||||||
const AMask: string;
|
const AMask: string;
|
||||||
const TheOptions: TLazFindInFileSearchOptions): TTabSheet;
|
const TheOptions: TLazFindInFileSearchOptions): TTabSheet;
|
||||||
function GetSourcePositon: TPoint;
|
function GetSourcePositon: TPoint;
|
||||||
@ -709,7 +709,7 @@ end;
|
|||||||
function TSearchResultsView.AddSearch(const ResultsName: string;
|
function TSearchResultsView.AddSearch(const ResultsName: string;
|
||||||
const SearchText: string;
|
const SearchText: string;
|
||||||
const ReplaceText: string;
|
const ReplaceText: string;
|
||||||
const ADirectory: string;
|
const ADirectories: string;
|
||||||
const AMask: string;
|
const AMask: string;
|
||||||
const TheOptions: TLazFindInFileSearchOptions): TTabSheet;
|
const TheOptions: TLazFindInFileSearchOptions): TTabSheet;
|
||||||
var
|
var
|
||||||
@ -751,7 +751,7 @@ begin
|
|||||||
if SearchObj<>nil then begin
|
if SearchObj<>nil then begin
|
||||||
SearchObj.SearchString:= SearchText;
|
SearchObj.SearchString:= SearchText;
|
||||||
SearchObj.ReplaceText := ReplaceText;
|
SearchObj.ReplaceText := ReplaceText;
|
||||||
SearchObj.SearchDirectory:= ADirectory;
|
SearchObj.SearchDirectories:= ADirectories;
|
||||||
SearchObj.SearchMask:= AMask;
|
SearchObj.SearchMask:= AMask;
|
||||||
SearchObj.SearchOptions:= TheOptions;
|
SearchObj.SearchOptions:= TheOptions;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user