fix, changed ancestor, previous one didn't have a Shortcut.

removed default attrib, property is always written to setting file
This commit is contained in:
Basile Burg 2014-12-09 11:33:48 +01:00
parent 8fc973dd99
commit d0ca1fbffa
1 changed files with 9 additions and 6 deletions

View File

@ -5,7 +5,7 @@ unit ce_staticmacro;
interface interface
uses uses
Classes, Sysutils, SynEdit, SynEditAutoComplete, Classes, Sysutils, SynEdit, SynEditAutoComplete, SynCompletion,
ce_interfaces, ce_writableComponent, ce_synmemo; ce_interfaces, ce_writableComponent, ce_synmemo;
type type
@ -24,7 +24,7 @@ type
*) *)
TCEStaticEditorMacro = class(TWritableComponent, ICEMultiDocObserver) TCEStaticEditorMacro = class(TWritableComponent, ICEMultiDocObserver)
private private
fCompletor: TSynEditAutoComplete; fCompletor: TSynAutoComplete;
fMacros: TStringList; fMacros: TStringList;
fDoc: TCESynMemo; fDoc: TCESynMemo;
fAutomatic: boolean; fAutomatic: boolean;
@ -40,7 +40,7 @@ type
published published
// list of string with the format $<..>alnum=<..> // list of string with the format $<..>alnum=<..>
property macros: TStringList read fMacros write setMacros; property macros: TStringList read fMacros write setMacros;
property automatic: boolean read fAutomatic write fAutomatic default true; property automatic: boolean read fAutomatic write fAutomatic;
public public
constructor create(aOwner: TComponent); override; constructor create(aOwner: TComponent); override;
destructor destroy; override; destructor destroy; override;
@ -77,9 +77,10 @@ var
begin begin
inherited; inherited;
fAutomatic := true; fAutomatic := true;
fCompletor := TSynEditAutoComplete.Create(self); fCompletor := TSynAutoComplete.Create(self);
fMacros := TStringList.Create; fMacros := TStringList.Create;
fMacros.Delimiter := '='; fMacros.Delimiter := '=';
assert(fCompletor.ShortCut <> 0);
// //
fname := getDocPath + macFname; fname := getDocPath + macFname;
if fileExists(fname) then loadFromFile(fname); if fileExists(fname) then loadFromFile(fname);
@ -113,11 +114,13 @@ end;
procedure TCEStaticEditorMacro.docNew(aDoc: TCESynMemo); procedure TCEStaticEditorMacro.docNew(aDoc: TCESynMemo);
begin begin
fDoc := aDoc; fDoc := aDoc;
fCompletor.Editor := fDoc;
end; end;
procedure TCEStaticEditorMacro.docFocused(aDoc: TCESynMemo); procedure TCEStaticEditorMacro.docFocused(aDoc: TCESynMemo);
begin begin
fDoc := aDoc; fDoc := aDoc;
fCompletor.Editor := fDoc;
end; end;
procedure TCEStaticEditorMacro.docChanged(aDoc: TCESynMemo); procedure TCEStaticEditorMacro.docChanged(aDoc: TCESynMemo);
@ -183,13 +186,13 @@ end;
procedure TCEStaticEditorMacro.Execute; procedure TCEStaticEditorMacro.Execute;
begin begin
if fDoc <> nil then if fDoc <> nil then
fCompletor.ExecuteCompletion(fDoc.Identifier, fDoc); fCompletor.Execute(fDoc.Identifier, fDoc);
end; end;
procedure TCEStaticEditorMacro.Execute(aEditor: TCustomSynEdit; const aToken: string); procedure TCEStaticEditorMacro.Execute(aEditor: TCustomSynEdit; const aToken: string);
begin begin
if aEditor <> nil then if aEditor <> nil then
fCompletor.ExecuteCompletion(aToken, aEditor); fCompletor.Execute(aToken, aEditor);
end; end;
{$ENDREGION} {$ENDREGION}