-
Notifications
You must be signed in to change notification settings - Fork 86
/
dlgSearchText.pas
216 lines (179 loc) · 6.31 KB
/
dlgSearchText.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
{-------------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: dlgSearchText.pas, released 2000-06-23.
The Original Code is part of the SearchReplaceDemo project, written by
Michael Hieke for the SynEdit component suite.
All Rights Reserved.
Contributors to the SynEdit project are listed in the Contributors.txt file.
Alternatively, the contents of this file may be used under the terms of the
GNU General Public License Version 2 or later (the "GPL"), in which case
the provisions of the GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms
of the GPL and not to allow others to use your version of this file
under the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the GPL.
If you do not delete the provisions above, a recipient may use your version
of this file under either the MPL or the GPL.
$Id: dlgSearchText.pas,v 1.3 2002/08/01 05:44:05 etrusco Exp $
You may retrieve the latest version of this file at the SynEdit home page,
located at http://SynEdit.SourceForge.net
Known Issues:
-------------------------------------------------------------------------------}
unit dlgSearchText;
{$I SynEdit.inc}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TTextSearchDialog = class(TForm)
Label1: TLabel;
cbSearchText: TComboBox;
rgSearchDirection: TRadioGroup;
gbSearchOptions: TGroupBox;
cbSearchCaseSensitive: TCheckBox;
cbSearchWholeWords: TCheckBox;
cbSearchFromCursor: TCheckBox;
cbSearchSelectedOnly: TCheckBox;
btnOK: TButton;
btnCancel: TButton;
cbRegularExpression: TCheckBox;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
function GetSearchBackwards: boolean;
function GetSearchCaseSensitive: boolean;
function GetSearchFromCursor: boolean;
function GetSearchInSelection: boolean;
function GetSearchText: string;
function GetSearchTextHistory: string;
function GetSearchWholeWords: boolean;
procedure SetSearchBackwards(Value: boolean);
procedure SetSearchCaseSensitive(Value: boolean);
procedure SetSearchFromCursor(Value: boolean);
procedure SetSearchInSelection(Value: boolean);
procedure SetSearchText(Value: string);
procedure SetSearchTextHistory(Value: string);
procedure SetSearchWholeWords(Value: boolean);
procedure SetSearchRegularExpression(const Value: boolean);
function GetSearchRegularExpression: boolean;
public
property SearchBackwards: boolean read GetSearchBackwards
write SetSearchBackwards;
property SearchCaseSensitive: boolean read GetSearchCaseSensitive
write SetSearchCaseSensitive;
property SearchFromCursor: boolean read GetSearchFromCursor
write SetSearchFromCursor;
property SearchInSelectionOnly: boolean read GetSearchInSelection
write SetSearchInSelection;
property SearchText: string read GetSearchText write SetSearchText;
property SearchTextHistory: string read GetSearchTextHistory
write SetSearchTextHistory;
property SearchWholeWords: boolean read GetSearchWholeWords
write SetSearchWholeWords;
property SearchRegularExpression: boolean read GetSearchRegularExpression
write SetSearchRegularExpression;
end;
implementation
{$R *.DFM}
{ TTextSearchDialog }
function TTextSearchDialog.GetSearchBackwards: boolean;
begin
Result := rgSearchDirection.ItemIndex = 1;
end;
function TTextSearchDialog.GetSearchCaseSensitive: boolean;
begin
Result := cbSearchCaseSensitive.Checked;
end;
function TTextSearchDialog.GetSearchFromCursor: boolean;
begin
Result := cbSearchFromCursor.Checked;
end;
function TTextSearchDialog.GetSearchInSelection: boolean;
begin
Result := cbSearchSelectedOnly.Checked;
end;
function TTextSearchDialog.GetSearchRegularExpression: boolean;
begin
Result := cbRegularExpression.Checked;
end;
function TTextSearchDialog.GetSearchText: string;
begin
Result := cbSearchText.Text;
end;
function TTextSearchDialog.GetSearchTextHistory: string;
var
i: integer;
begin
Result := '';
for i := 0 to cbSearchText.Items.Count - 1 do begin
if i >= 10 then
break;
if i > 0 then
Result := Result + #13#10;
Result := Result + cbSearchText.Items[i];
end;
end;
function TTextSearchDialog.GetSearchWholeWords: boolean;
begin
Result := cbSearchWholeWords.Checked;
end;
procedure TTextSearchDialog.SetSearchBackwards(Value: boolean);
begin
rgSearchDirection.ItemIndex := Ord(Value);
end;
procedure TTextSearchDialog.SetSearchCaseSensitive(Value: boolean);
begin
cbSearchCaseSensitive.Checked := Value;
end;
procedure TTextSearchDialog.SetSearchFromCursor(Value: boolean);
begin
cbSearchFromCursor.Checked := Value;
end;
procedure TTextSearchDialog.SetSearchInSelection(Value: boolean);
begin
cbSearchSelectedOnly.Checked := Value;
end;
procedure TTextSearchDialog.SetSearchText(Value: string);
begin
cbSearchText.Text := Value;
end;
procedure TTextSearchDialog.SetSearchTextHistory(Value: string);
begin
cbSearchText.Items.Text := Value;
end;
procedure TTextSearchDialog.SetSearchWholeWords(Value: boolean);
begin
cbSearchWholeWords.Checked := Value;
end;
procedure TTextSearchDialog.SetSearchRegularExpression(
const Value: boolean);
begin
cbRegularExpression.Checked := Value;
end;
{ event handlers }
procedure TTextSearchDialog.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
var
s: string;
i: integer;
begin
if ModalResult = mrOK then begin
s := cbSearchText.Text;
if s <> '' then begin
i := cbSearchText.Items.IndexOf(s);
if i > -1 then begin
cbSearchText.Items.Delete(i);
cbSearchText.Items.Insert(0, s);
cbSearchText.Text := s;
end else
cbSearchText.Items.Insert(0, s);
end;
end;
end;
end.