forked from do-/steludio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchReplace.pas
87 lines (75 loc) · 2.65 KB
/
SearchReplace.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
unit SearchReplace;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, SynEdit;
type
TSearchReplaceForm = class(TForm)
CheckBoxMatchCase: TCheckBox;
EditSearch: TEdit;
Label1: TLabel;
CheckBoxWholeWord: TCheckBox;
CheckBoxBackwards: TCheckBox;
CheckBoxSelectedOnly: TCheckBox;
Bevel1: TBevel;
EditReplace: TEdit;
CheckBoxReplace: TCheckBox;
CheckBoxReplaceAll: TCheckBox;
CheckBoxPrompt: TCheckBox;
BitBtnOK: TBitBtn;
BitBtnCancel: TBitBtn;
RadioButtonEntireScope: TRadioButton;
RadioButtonFromCursor: TRadioButton;
Bevel2: TBevel;
procedure BitBtnOKClick(Sender: TObject);
procedure BitBtnCancelClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure CheckBoxReplaceClick(Sender: TObject);
private
procedure CheckReplaceEnabled;
public
function Options: TSynSearchOptions;
end;
implementation
{$R *.dfm}
function TSearchReplaceForm.Options: TSynSearchOptions;
begin
Result := [];
if CheckBoxMatchCase.Checked then Result := Result + [ssoMatchCase];
if CheckBoxWholeWord.Checked then Result := Result + [ssoWholeWord];
if CheckBoxBackwards.Checked then Result := Result + [ssoBackwards];
if CheckBoxSelectedOnly.Checked then Result := Result + [ssoSelectedOnly];
if CheckBoxReplace.Checked then Result := Result + [ssoReplace];
if CheckBoxReplace.Checked and RadioButtonEntireScope.Checked then Result := Result + [ssoEntireScope];
if CheckBoxReplace.Checked and CheckBoxReplaceAll.Checked then Result := Result + [ssoReplaceAll];
if CheckBoxReplace.Checked and CheckBoxPrompt.Checked then Result := Result + [ssoPrompt];
end;
procedure TSearchReplaceForm.CheckReplaceEnabled;
begin
EditReplace.Enabled := CheckBoxReplace.Checked;
CheckBoxReplaceAll.Enabled := CheckBoxReplace.Checked;
RadioButtonEntireScope.Enabled := CheckBoxReplace.Checked;
RadioButtonFromCursor.Enabled := CheckBoxReplace.Checked;
CheckBoxPrompt.Enabled := false; //CheckBoxReplace.Checked;
end;
procedure TSearchReplaceForm.BitBtnOKClick(Sender: TObject);
begin
ModalResult := mrOK;
end;
procedure TSearchReplaceForm.BitBtnCancelClick(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure TSearchReplaceForm.FormShow(Sender: TObject);
begin
CheckReplaceEnabled;
EditSearch.SelectAll;
if CheckBoxReplace.Checked
then ActiveControl := EditReplace
else ActiveControl := EditSearch;
end;
procedure TSearchReplaceForm.CheckBoxReplaceClick(Sender: TObject);
begin
CheckReplaceEnabled;
end;
end.