{ *************************************************************************** }
{                                                                             }
{ EControl Syntax Editor SDK                                                  }
{                                                                             }
{ Copyright (c) 2004 - 2008 EControl Ltd., Zaharov Michael                    }
{     www.econtrol.ru                                                         }
{     support@econtrol.ru                                                     }
{                                                                             }
{ *************************************************************************** }
{$I ecSyntEdit.INC}

unit ecAutoReplDlg;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, ecSyntAnal, ecSyntMemo, StdCtrls, ExtCtrls, ecAutoReplace,
  ComCtrls;

type
  TAutoReplDlg = class(TForm)
    Panel1: TPanel;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    SyntaxMemo1: TSyntaxMemo;
    SyntAnalyzer1: TSyntAnalyzer;
    Button1: TButton;
    Button2: TButton;
    CheckBox4: TCheckBox;
  private
  protected
    procedure ReadState(Reader: TReader); override;
    { Private declarations }
  public
    { Public declarations }
  end;

function CustomizeAutoReplace(ARepl: TSyntAutoReplace): Boolean;

implementation

{$R *.dfm}

function CustomizeAutoReplace(ARepl: TSyntAutoReplace): Boolean;
begin
  with TAutoReplDlg.Create(nil) do
   try
     CheckBox1.Checked := ARepl.Enabled;
     CheckBox2.Checked := ARepl.IgnoreCase;
     CheckBox3.Checked := ARepl.MaintainCase;
     CheckBox4.Checked := ARepl.CaseConsistancy;
     if ARepl.Separator <= ' ' then
       SyntAnalyzer1.TokenRules[0].Expression := ''
     else
       SyntAnalyzer1.TokenRules[0].Expression := Format('\x%2x',[Ord(ARepl.Separator)]);
     SyntaxMemo1.Lines.Text := ARepl.Items.Text;
     Result := ShowModal = mrOk;
     if Result then
      begin
        ARepl.Enabled := CheckBox1.Checked;
        ARepl.IgnoreCase := CheckBox2.Checked;
        ARepl.MaintainCase := CheckBox3.Checked;
        ARepl.CaseConsistancy := CheckBox4.Checked;
        ARepl.Items.Text := SyntaxMemo1.Lines.Text;
      end;
   finally
     Free;
   end;
end;

procedure TAutoReplDlg.ReadState(Reader: TReader);
begin
  inherited;
  BorderStyle := bsSizeable;
end;

end.

