mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 12:39:29 +02:00
added FindInFiles Options from Bob
git-svn-id: trunk@3441 -
This commit is contained in:
parent
a86ce8f3ba
commit
03abba6294
@ -24,7 +24,14 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLLinux, Controls, StdCtrls, Forms, Buttons, ExtCtrls,
|
||||
LResources, LazarusIDEStrConsts, DirSel, Dialogs;
|
||||
LResources, LazarusIDEStrConsts, DirSel, Dialogs, SynEditTypes;
|
||||
|
||||
type
|
||||
TLazFindInFileSearchOption = (fifMatchCase, fifWholeWord, fifRegExpr,
|
||||
fifSearchProject, fifSearchOpen, fifSearchFiles,
|
||||
fifIncludeSubDirs);
|
||||
|
||||
TLazFindInFileSearchOptions = set of TLazFindInFileSearchOption;
|
||||
|
||||
type
|
||||
TLazFindInFilesDialog = class(TForm)
|
||||
@ -49,12 +56,20 @@ type
|
||||
procedure CancelButtonClick(Sender: TObject);
|
||||
procedure DirectoryBrowseClick(Sender: TObject);
|
||||
procedure WhereRadioGroupClick(Sender: TObject);
|
||||
procedure SetOptions(NewOptions: TLazFindInFileSearchOptions);
|
||||
function GetOptions: TLazFindInFileSearchOptions;
|
||||
function GetSynOptions: TSynSearchOptions;
|
||||
procedure SetSynOptions(NewOptions: TSynSearchOptions);
|
||||
private
|
||||
function GetFindText: string;
|
||||
procedure SetFindText(const NewFindText: string);
|
||||
public
|
||||
constructor Create(AOwner:TComponent); override;
|
||||
property Options:TLazFindInFileSearchOptions read GetOptions
|
||||
write SetOptions;
|
||||
property FindText: string read GetFindText write SetFindText;
|
||||
property SynSearchOptions: TSynSearchOptions read GetSynOptions
|
||||
write SetSynOptions;
|
||||
end;
|
||||
|
||||
|
||||
@ -356,6 +371,48 @@ begin
|
||||
DirectoryComboBox.Text:= TheDirectory;
|
||||
end;//DirectoryBrowseClick
|
||||
|
||||
procedure TLazFindInFilesDialog.SetOptions(
|
||||
NewOptions: TLazFindInFileSearchOptions);
|
||||
begin
|
||||
CaseSensitiveCheckBox.Checked:=fifMatchCase in NewOptions;
|
||||
WholeWordsOnlyCheckBox.Checked:=fifWholeWord in NewOptions;
|
||||
RegularExpressionsCheckBox.Checked:=fifRegExpr in NewOptions;
|
||||
IncludeSubDirsCheckBox.Checked:= fifIncludeSubDirs in NewOptions;
|
||||
if fifSearchProject in NewOptions then WhereRadioGroup.ItemIndex:= 0;
|
||||
if fifSearchOpen in NewOptions then WhereRadioGroup.ItemIndex:= 1;
|
||||
if fifSearchFiles in NewOptions then WhereRadioGroup.ItemIndex:= 2;
|
||||
end;//SetOptions
|
||||
|
||||
function TLazFindInFilesDialog.GetOptions: TLazFindInFileSearchOptions;
|
||||
begin
|
||||
Result:=[];
|
||||
if CaseSensitiveCheckBox.Checked then Include(Result,fifMatchCase);
|
||||
if WholeWordsOnlyCheckBox.Checked then Include(Result,fifWholeWord);
|
||||
if RegularExpressionsCheckBox.Checked then Include(Result,fifRegExpr);
|
||||
if IncludeSubDirsCheckBox.Checked then Include(Result,fifIncludeSubDirs);
|
||||
|
||||
case WhereRadioGroup.ItemIndex of
|
||||
0: Include(Result,fifSearchProject);
|
||||
1: Include(Result,fifSearchOpen);
|
||||
2: Include(Result,fifSearchFiles);
|
||||
end;//case
|
||||
end;//GetOptions
|
||||
|
||||
function TLazFindInFilesDialog.GetSynOptions: TSynSearchOptions;
|
||||
begin
|
||||
Result:=[];
|
||||
if CaseSensitiveCheckBox.Checked then Include(Result,ssoMatchCase);
|
||||
if WholeWordsOnlyCheckBox.Checked then Include(Result,ssoWholeWord);
|
||||
if RegularExpressionsCheckBox.Checked then Include(Result,ssoRegExpr);
|
||||
end;//GetSynOptions
|
||||
|
||||
procedure TLazFindInFilesDialog.SetSynOptions(NewOptions: TSynSearchOptions);
|
||||
begin
|
||||
CaseSensitiveCheckBox.Checked:=ssoMatchCase in NewOptions;
|
||||
WholeWordsOnlyCheckBox.Checked:=ssoWholeWord in NewOptions;
|
||||
RegularExpressionsCheckBox.Checked:=ssoRegExpr in NewOptions;
|
||||
end;//SetSynOptions
|
||||
|
||||
initialization
|
||||
FindInFilesDialog:=nil;
|
||||
|
||||
|
@ -2083,12 +2083,10 @@ begin
|
||||
// check if special file, skip directories this time
|
||||
if (FileInfo.Name='.') or (FileInfo.Name='..')
|
||||
or ((faDirectory and FileInfo.Attr)>0) then continue;
|
||||
//Make sure this is a text file as we will be search
|
||||
if (FileIsText(TempDir + FileInfo.Name))and
|
||||
(FileIsReadable(TempDir + FileInfo.Name)) then
|
||||
begin
|
||||
FileList.Add(TempDir + FileInfo.Name);
|
||||
end;//if
|
||||
//Make sure this is a text file as it will be searched
|
||||
if FileIsReadable(TempDir + FileInfo.Name)
|
||||
and FileIsText(TempDir + FileInfo.Name)
|
||||
then FileList.Add(TempDir + FileInfo.Name);
|
||||
until SysUtils.FindNext(FileInfo)<>0;
|
||||
end;//if
|
||||
SysUtils.FindClose(FileInfo);
|
||||
@ -2098,20 +2096,17 @@ begin
|
||||
end;//try-finally
|
||||
//If selected then Look for and search subdirectories
|
||||
if (recursive) then begin
|
||||
if (SysUtils.FindFirst(TempDir
|
||||
+FindMask,faAnyFile,FileInfo)=0) then
|
||||
if (SysUtils.FindFirst(TempDir+FindMask,faAnyFile,FileInfo)=0) then
|
||||
begin
|
||||
if ((faDirectory and FileInfo.Attr)>0) then
|
||||
begin
|
||||
repeat
|
||||
// check if special file
|
||||
if (FileInfo.Name='.') or (FileInfo.Name='..') then continue;
|
||||
FindMatchingTextFiles
|
||||
(FileList,TempDir + FileInfo.Name,mask,recursive);
|
||||
until SysUtils.FindNext(FileInfo)<>0;
|
||||
end;//if
|
||||
SysUtils.FindClose(FileInfo);
|
||||
end;
|
||||
repeat
|
||||
// check if directory and not special file
|
||||
if ((faDirectory and FileInfo.Attr)>0)
|
||||
and (FileInfo.Name<>'.') and (FileInfo.Name<>'..')
|
||||
then FindMatchingTextFiles(FileList,
|
||||
TempDir + FileInfo.Name,mask,recursive);
|
||||
until SysUtils.FindNext(FileInfo)<>0;
|
||||
end;//if
|
||||
SysUtils.FindClose(FileInfo);
|
||||
end;//if
|
||||
end;//if
|
||||
end;//FindMatchingFiles
|
||||
|
@ -3390,24 +3390,9 @@ Begin
|
||||
with FindReplaceDlg do
|
||||
begin
|
||||
FindText:=LocalFindText;
|
||||
Options:= Options-[ssoReplace,ssoReplaceAll,ssoBackwards];
|
||||
//Whole Words ?
|
||||
if FindInFilesDialog.WholeWordsOnlyCheckBox.Checked then
|
||||
Options:= Options+[ssoWholeWord]
|
||||
else
|
||||
Options:= Options-[ssoWholeWord];
|
||||
//Case Sensitive?
|
||||
if FindInFilesDialog.CaseSensitiveCheckBox.Checked then
|
||||
Options:= Options+[ssoMatchCase]
|
||||
else
|
||||
Options:= Options-[ssoMatchCase];
|
||||
//Regular Expression?
|
||||
if FindInFilesDialog.RegularExpressionsCheckBox.Checked then
|
||||
Options:= Options+[ssoRegExpr]
|
||||
else
|
||||
Options:= Options-[ssoRegExpr];
|
||||
Options:= FindInFilesDialog.SynSearchOptions;
|
||||
//Multiline RegExpr?
|
||||
Options:= Options-[ssoRegExprMultiLine];
|
||||
Options:= Options-[ssoRegExprMultiLine];
|
||||
end;//with
|
||||
end//if
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user