123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- unit FindInFiles;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, Mask, JvExMask, JvToolEdit, ExtCtrls, JvExStdCtrls,
- JvRadioButton;
- type
- TfrmFindInFiles = class(TForm)
- cboSearchInFilesText: TComboBox;
- Label1: TLabel;
- gbSearchOptions: TGroupBox;
- chkSearchCaseSensitive: TCheckBox;
- chkSearchWholeWords: TCheckBox;
- chkRegularExpression: TCheckBox;
- fraDirectory: TGroupBox;
- jvdirDirectory: TJvDirectoryEdit;
- Label2: TLabel;
- optOutput: TRadioGroup;
- btnOK: TButton;
- btnCancel: TButton;
- chkIncludeSubdir: TCheckBox;
- fraWhere: TGroupBox;
- jvoptFilesInDir: TJvRadioButton;
- jvoptActiveProject: TJvRadioButton;
- jvoptOpenFiles: TJvRadioButton;
- procedure btnOKClick(Sender: TObject);
- procedure optWhereClick(Sender: TObject);
- procedure btnCancelClick(Sender: TObject);
- procedure FormShow(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- SearchText: String;
- SearchDirectory: String;
- function IsCaseSensitive: Boolean;
- function IsWholeWordOnly: Boolean;
- function IsResgularExpression: Boolean;
- function IsSubDir: Boolean;
- function GetSearchMode: Integer;
- procedure SetSearchMode(Index: Integer);
- function GetOutput: Integer;
- end;
- var
- frmFindInFiles: TfrmFindInFiles;
- implementation
- uses Main;
- {$R *.dfm}
- procedure TfrmFindInFiles.btnOKClick(Sender: TObject);
- begin
- if cboSearchInFilesText.Text <> '' then
- begin
- SearchText := cboSearchInFilesText.Text;
- SearchDirectory := jvdirDirectory.Text;
- Self.Close;
- end
- else
- begin
- Application.MessageBox('The search string cannot be blank.', 'LuaEdit', MB_OK+MB_ICONERROR);
- end;
- end;
- procedure TfrmFindInFiles.btnCancelClick(Sender: TObject);
- begin
- SearchText := '';
- SearchDirectory := '';
- Self.Close;
- end;
- procedure TfrmFindInFiles.optWhereClick(Sender: TObject);
- begin
- fraDirectory.Enabled := (GetSearchMode = 2);
- jvdirDirectory.Enabled := (GetSearchMode = 2);
- chkIncludeSubdir.Enabled := (GetSearchMode = 2);
- end;
- function TfrmFindInFiles.IsCaseSensitive: Boolean;
- begin
- Result := chkSearchCaseSensitive.Checked;
- end;
- function TfrmFindInFiles.IsWholeWordOnly: Boolean;
- begin
- Result := chkSearchWholeWords.Checked;
- end;
- function TfrmFindInFiles.IsResgularExpression: Boolean;
- begin
- Result := chkRegularExpression.Checked;
- end;
- function TfrmFindInFiles.IsSubDir: Boolean;
- begin
- Result := chkIncludeSubdir.Checked;
- end;
- function TfrmFindInFiles.GetSearchMode: Integer;
- begin
- // Retreive mode through radio buttons
- if jvoptActiveProject.Checked then
- Result := 0
- else if jvoptOpenFiles.Checked then
- Result := 1
- else
- Result := 2;
- end;
- procedure TfrmFindInFiles.SetSearchMode(Index: Integer);
- begin
- // Set mode through radio buttons
- case Index of
- 0:
- begin
- if jvoptActiveProject.Enabled then
- jvoptActiveProject.Checked := True
- else
- SetSearchMode(2);
- end;
- 1:
- begin
- if jvoptOpenFiles.Enabled then
- jvoptOpenFiles.Checked := True
- else
- SetSearchMode(2);
- end;
- 2: jvoptFilesInDir.Checked := True;
- end;
- end;
- function TfrmFindInFiles.GetOutput: Integer;
- begin
- Result := optOutput.ItemIndex;
- end;
- procedure TfrmFindInFiles.FormShow(Sender: TObject);
- begin
- optWhereClick(nil);
- end;
- end.
|