1
{-------------------------------------------------------------------------------
2
The contents of this file are subject to the Mozilla Public License
3
Version 1.1 (the "License"); you may not use this file except in compliance
4
with the License. You may obtain a copy of the License at
5
http://www.mozilla.org/MPL/
7
Software distributed under the License is distributed on an "AS IS" basis,
8
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9
the specific language governing rights and limitations under the License.
11
The Original Code is: dlgSearchText.pas, released 2000-06-23.
13
The Original Code is part of the SearchReplaceDemo project, written by
14
Michael Hieke for the SynEdit component suite.
17
Contributors to the SynEdit project are listed in the Contributors.txt file.
19
Alternatively, the contents of this file may be used under the terms of the
20
GNU General Public License Version 2 or later (the "GPL"), in which case
21
the provisions of the GPL are applicable instead of those above.
22
If you wish to allow use of your version of this file only under the terms
23
of the GPL and not to allow others to use your version of this file
24
under the MPL, indicate your decision by deleting the provisions above and
25
replace them with the notice and other provisions required by the GPL.
26
If you do not delete the provisions above, a recipient may use your version
27
of this file under either the MPL or the GPL.
29
$Id: dlgSearchText.pas,v 1.3 2002/08/01 05:44:05 etrusco Exp $
31
You may retrieve the latest version of this file at the SynEdit home page,
32
located at http://SynEdit.SourceForge.net
35
-------------------------------------------------------------------------------}
44
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
48
TTextSearchDialog = class(TForm)
50
cbSearchText: TComboBox;
51
rgSearchDirection: TRadioGroup;
52
gbSearchOptions: TGroupBox;
53
cbSearchCaseSensitive: TCheckBox;
54
cbSearchWholeWords: TCheckBox;
55
cbSearchFromCursor: TCheckBox;
56
cbSearchSelectedOnly: TCheckBox;
59
cbRegularExpression: TCheckBox;
60
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
62
function GetSearchBackwards: boolean;
63
function GetSearchCaseSensitive: boolean;
64
function GetSearchFromCursor: boolean;
65
function GetSearchInSelection: boolean;
66
function GetSearchText: string;
67
function GetSearchTextHistory: string;
68
function GetSearchWholeWords: boolean;
69
procedure SetSearchBackwards(Value: boolean);
70
procedure SetSearchCaseSensitive(Value: boolean);
71
procedure SetSearchFromCursor(Value: boolean);
72
procedure SetSearchInSelection(Value: boolean);
73
procedure SetSearchText(Value: string);
74
procedure SetSearchTextHistory(Value: string);
75
procedure SetSearchWholeWords(Value: boolean);
76
procedure SetSearchRegularExpression(const Value: boolean);
77
function GetSearchRegularExpression: boolean;
79
property SearchBackwards: boolean read GetSearchBackwards
80
write SetSearchBackwards;
81
property SearchCaseSensitive: boolean read GetSearchCaseSensitive
82
write SetSearchCaseSensitive;
83
property SearchFromCursor: boolean read GetSearchFromCursor
84
write SetSearchFromCursor;
85
property SearchInSelectionOnly: boolean read GetSearchInSelection
86
write SetSearchInSelection;
87
property SearchText: string read GetSearchText write SetSearchText;
88
property SearchTextHistory: string read GetSearchTextHistory
89
write SetSearchTextHistory;
90
property SearchWholeWords: boolean read GetSearchWholeWords
91
write SetSearchWholeWords;
92
property SearchRegularExpression: boolean read GetSearchRegularExpression
93
write SetSearchRegularExpression;
100
{ TTextSearchDialog }
102
function TTextSearchDialog.GetSearchBackwards: boolean;
104
Result := rgSearchDirection.ItemIndex = 1;
107
function TTextSearchDialog.GetSearchCaseSensitive: boolean;
109
Result := cbSearchCaseSensitive.Checked;
112
function TTextSearchDialog.GetSearchFromCursor: boolean;
114
Result := cbSearchFromCursor.Checked;
117
function TTextSearchDialog.GetSearchInSelection: boolean;
119
Result := cbSearchSelectedOnly.Checked;
122
function TTextSearchDialog.GetSearchRegularExpression: boolean;
124
Result := cbRegularExpression.Checked;
127
function TTextSearchDialog.GetSearchText: string;
129
Result := cbSearchText.Text;
132
function TTextSearchDialog.GetSearchTextHistory: string;
137
for i := 0 to cbSearchText.Items.Count - 1 do begin
141
Result := Result + #13#10;
142
Result := Result + cbSearchText.Items[i];
146
function TTextSearchDialog.GetSearchWholeWords: boolean;
148
Result := cbSearchWholeWords.Checked;
151
procedure TTextSearchDialog.SetSearchBackwards(Value: boolean);
153
rgSearchDirection.ItemIndex := Ord(Value);
156
procedure TTextSearchDialog.SetSearchCaseSensitive(Value: boolean);
158
cbSearchCaseSensitive.Checked := Value;
161
procedure TTextSearchDialog.SetSearchFromCursor(Value: boolean);
163
cbSearchFromCursor.Checked := Value;
166
procedure TTextSearchDialog.SetSearchInSelection(Value: boolean);
168
cbSearchSelectedOnly.Checked := Value;
171
procedure TTextSearchDialog.SetSearchText(Value: string);
173
cbSearchText.Text := Value;
176
procedure TTextSearchDialog.SetSearchTextHistory(Value: string);
178
cbSearchText.Items.Text := Value;
181
procedure TTextSearchDialog.SetSearchWholeWords(Value: boolean);
183
cbSearchWholeWords.Checked := Value;
186
procedure TTextSearchDialog.SetSearchRegularExpression(
187
const Value: boolean);
189
cbRegularExpression.Checked := Value;
194
procedure TTextSearchDialog.FormCloseQuery(Sender: TObject;
195
var CanClose: Boolean);
200
if ModalResult = mrOK then begin
201
s := cbSearchText.Text;
202
if s <> '' then begin
203
i := cbSearchText.Items.IndexOf(s);
205
cbSearchText.Items.Delete(i);
206
cbSearchText.Items.Insert(0, s);
207
cbSearchText.Text := s;
209
cbSearchText.Items.Insert(0, s);
b'\\ No newline at end of file'