pascalscript/Samples/Debug/dlgSearchText.pas
carlokok afe3fdfd77 re-checkin
git-svn-id: http://code.remobjects.com/svn/pascalscript@1 5c9d2617-0215-0410-a2ee-e80e04d1c6d8
2006-05-30 14:23:25 +00:00

216 lines
6.5 KiB
ObjectPascal

{-------------------------------------------------------------------------------
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.