mirror of https://gitlab.com/basile.b/dexed.git
static macros, defaults can be cleared and wont be reset automatically
in the options, a btn allows to reset them explicitly
This commit is contained in:
parent
e442c1fea2
commit
256017709a
|
@ -32,6 +32,7 @@ type
|
|||
// aliased to get a custom prop inspector
|
||||
TCEPathname = type string;
|
||||
TCEFilename = type string;
|
||||
TCEEditEvent = type boolean;
|
||||
|
||||
(**
|
||||
* Workaround for a TAsyncProcess Linux issue: OnTerminate event not called.
|
||||
|
|
|
@ -30,6 +30,14 @@ type
|
|||
constructor Create(Hook: TPropertyEditorHook; APropCount: Integer); override;
|
||||
end;
|
||||
|
||||
TCEActionInEditor = class(TPropertyEditor)
|
||||
constructor Create(Hook:TPropertyEditorHook; APropCount:Integer); override;
|
||||
function GetAttributes: TPropertyAttributes; override;
|
||||
function IsReadOnly: boolean; override;
|
||||
function GetVisualValue: ansistring; override;
|
||||
procedure Edit; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
function TCECustomPathEditor.GetAttributes: TPropertyAttributes;
|
||||
|
@ -68,8 +76,35 @@ begin
|
|||
fType := ptFile;
|
||||
end;
|
||||
|
||||
constructor TCEActionInEditor.Create(Hook:TPropertyEditorHook; APropCount:Integer);
|
||||
begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TCEActionInEditor.GetAttributes: TPropertyAttributes;
|
||||
begin
|
||||
exit([paReadOnly, paDialog]);
|
||||
end;
|
||||
|
||||
function TCEActionInEditor.IsReadOnly: boolean;
|
||||
begin
|
||||
exit(true);
|
||||
end;
|
||||
|
||||
function TCEActionInEditor.GetVisualValue: ansistring;
|
||||
begin
|
||||
exit('(click)');
|
||||
end;
|
||||
|
||||
procedure TCEActionInEditor.Edit;
|
||||
begin
|
||||
SetOrdValue(not GetOrdValue);
|
||||
Modified;
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterPropertyEditor(TypeInfo(TCEPathname), nil, '', TCEPathnameEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TCEFilename), nil, '', TCEfilenameEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TCEEditEvent), nil, '', TCEActionInEditor);
|
||||
end.
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ interface
|
|||
|
||||
uses
|
||||
Classes, Sysutils, SynEdit, SynCompletion,
|
||||
ce_interfaces, ce_writableComponent, ce_synmemo;
|
||||
ce_common, ce_interfaces, ce_writableComponent, ce_synmemo;
|
||||
|
||||
type
|
||||
|
||||
|
@ -19,11 +19,14 @@ type
|
|||
fAutoInsert: boolean;
|
||||
fShortCut: TShortCut;
|
||||
fMacros: TStringList;
|
||||
fSetDef: TCEEditEvent;
|
||||
procedure setMacros(aValue: TStringList);
|
||||
procedure setDefEvent(value: TCEEditEvent);
|
||||
published
|
||||
property autoInsert: boolean read fAutoInsert write fAutoInsert;
|
||||
property macros: TStringList read fMacros write setMacros;
|
||||
property shortcut: TShortCut read fShortCut write fShortCut;
|
||||
property resetDefault: TCEEditEvent read fSetDef write setDefEvent stored false;
|
||||
public
|
||||
constructor create(aOwner: TComponent); override;
|
||||
destructor destroy; override;
|
||||
|
@ -89,7 +92,7 @@ var
|
|||
implementation
|
||||
|
||||
uses
|
||||
ce_observer, ce_common;
|
||||
ce_observer;
|
||||
|
||||
const
|
||||
OptFname = 'staticmacros.txt';
|
||||
|
@ -181,8 +184,13 @@ procedure TStaticMacrosOptions.setMacros(aValue: TStringList);
|
|||
begin
|
||||
fMacros.Assign(aValue);
|
||||
end;
|
||||
{$ENDREGION}
|
||||
|
||||
procedure TStaticMacrosOptions.setDefEvent(value : TCEEditEvent);
|
||||
begin
|
||||
TCEStaticEditorMacro(owner).addDefaults;
|
||||
fMacros.Assign(TCEStaticEditorMacro(owner).fMacros);
|
||||
end;
|
||||
{$ENDREGION}
|
||||
|
||||
{$REGION Standard Comp/Obj -----------------------------------------------------}
|
||||
constructor TCEStaticEditorMacro.create(aOwner: TComponent);
|
||||
|
@ -195,7 +203,6 @@ begin
|
|||
fCompletor.ShortCut := 8224; // SHIFT + SPACE
|
||||
fMacros := TStringList.Create;
|
||||
fMacros.Delimiter := '=';
|
||||
addDefaults;
|
||||
//
|
||||
fOptions := TStaticMacrosOptions.create(self);
|
||||
fOptionBackup := TStaticMacrosOptions.create(self);
|
||||
|
@ -209,7 +216,11 @@ begin
|
|||
else
|
||||
fOptions.Assign(self);
|
||||
end
|
||||
else fOptions.Assign(self);
|
||||
else
|
||||
begin
|
||||
addDefaults;
|
||||
fOptions.Assign(self);
|
||||
end;
|
||||
//
|
||||
sanitize;
|
||||
updateCompletor;
|
||||
|
@ -229,7 +240,6 @@ end;
|
|||
procedure TCEStaticEditorMacro.setMacros(aValue: TStringList);
|
||||
begin
|
||||
fMacros.Assign(aValue);
|
||||
addDefaults;
|
||||
sanitize;
|
||||
updateCompletor;
|
||||
end;
|
||||
|
|
Loading…
Reference in New Issue