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

unit ecCodeTemplListDlg;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ecsnCodeTempl, ecSyntAnal;

type
  TCodeTemplatesDlg = class(TForm)
    SyntCodeTemplFrame1: TSyntCodeTemplFrame;
    Button1: TButton;
    Button2: TButton;
  private
    FTempl: TCodeTemplates;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

function EditTemplates(Templ: TCodeTemplates; Lexer: TsyntAnalyzer = nil): Boolean;

implementation

{$R *.dfm}

function EditTemplates(Templ: TCodeTemplates; Lexer: TsyntAnalyzer = nil): Boolean;
begin
  with TCodeTemplatesDlg.Create(nil) do
   try
     FTempl.Assign(Templ);
     SyntCodeTemplFrame1.Templates:=FTempl;
     SyntCodeTemplFrame1.SyntaxMemo2.SyntaxAnalyzer := Lexer;
     Result := ShowModal = mrOk;
     if Result then Templ.Assign(FTempl);
   finally
     Free;
   end;
end;

{ TCodeTemplatesDlg }

constructor TCodeTemplatesDlg.Create(AOwner: TComponent);
begin
  inherited;
  FTempl := TCodeTemplates.Create(Self);
  SyntCodeTemplFrame1.Templates := FTempl;
end;

destructor TCodeTemplatesDlg.Destroy;
begin
  FTempl.Free;
  inherited;
end;

end.

