mirror of https://gitlab.com/basile.b/dexed.git
fix #293 - Changes to hardcoded highlighter presets are not visible until the old setting file is deleted
This commit is contained in:
parent
ddf268e685
commit
ab68e7287e
|
@ -36,6 +36,7 @@ type
|
||||||
fSelAttribs: TSynSelectedColor;
|
fSelAttribs: TSynSelectedColor;
|
||||||
fd2syn: TPersistent;
|
fd2syn: TPersistent;
|
||||||
fName: string;
|
fName: string;
|
||||||
|
fIsHardcoded: boolean;
|
||||||
procedure setBracketMatchColor(value: TSynSelectedColor);
|
procedure setBracketMatchColor(value: TSynSelectedColor);
|
||||||
procedure setCurrLineAttribs(value: TSynSelectedColor);
|
procedure setCurrLineAttribs(value: TSynSelectedColor);
|
||||||
procedure setFoldedColor(value: TSynSelectedColor);
|
procedure setFoldedColor(value: TSynSelectedColor);
|
||||||
|
@ -54,6 +55,7 @@ type
|
||||||
property identifierMatch: TSynSelectedColor read fIdentifierMarkup write setIdentifierMarkup stored true;
|
property identifierMatch: TSynSelectedColor read fIdentifierMarkup write setIdentifierMarkup stored true;
|
||||||
property mouseLink: TSynSelectedColor read fMouseLinkAttribs write setMouseLinkColor stored true;
|
property mouseLink: TSynSelectedColor read fMouseLinkAttribs write setMouseLinkColor stored true;
|
||||||
property selection: TSynSelectedColor read fSelAttribs write setSelCol stored true;
|
property selection: TSynSelectedColor read fSelAttribs write setSelCol stored true;
|
||||||
|
property isHardCoded: boolean read fIsHardcoded stored false;
|
||||||
public
|
public
|
||||||
constructor Create(ACollection: TCollection); override;
|
constructor Create(ACollection: TCollection); override;
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
|
@ -73,6 +75,7 @@ type
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function addPreset: TCED2SynPreset;
|
function addPreset: TCED2SynPreset;
|
||||||
|
function insertPreset(index: integer): TCED2SynPreset;
|
||||||
function count: integer;
|
function count: integer;
|
||||||
property preset[index: integer]: TCED2SynPreset read getPreset ; default;
|
property preset[index: integer]: TCED2SynPreset read getPreset ; default;
|
||||||
end;
|
end;
|
||||||
|
@ -254,6 +257,11 @@ begin
|
||||||
exit(TCED2SynPreset(fCollection.Add));
|
exit(TCED2SynPreset(fCollection.Add));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCED2SynPresets.insertPreset(index: integer): TCED2SynPreset;
|
||||||
|
begin
|
||||||
|
exit(TCED2SynPreset(fCollection.Insert(index)));
|
||||||
|
end;
|
||||||
|
|
||||||
function TCED2SynPresets.count: integer;
|
function TCED2SynPresets.count: integer;
|
||||||
begin
|
begin
|
||||||
exit(fCollection.Count);
|
exit(fCollection.Count);
|
||||||
|
@ -323,17 +331,28 @@ constructor TCED2SynPresetsLoaderForm.Create(AOwner: TComponent);
|
||||||
var
|
var
|
||||||
fname: string;
|
fname: string;
|
||||||
pnl: TPanel;
|
pnl: TPanel;
|
||||||
|
i: integer;
|
||||||
|
const
|
||||||
|
h: array[0..5] of string = ('bright', 'dark', 'Mustard', 'Mars bright',
|
||||||
|
'Mars dark', 'Soft dust');
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
fBackup:= TCED2SynPreset.Create(nil);
|
fBackup:= TCED2SynPreset.Create(nil);
|
||||||
fPresets:= TCED2SynPresets.Create(self);
|
fPresets:= TCED2SynPresets.Create(self);
|
||||||
fname := getCoeditDocPath + optfname;
|
fname := getCoeditDocPath + optfname;
|
||||||
if fname.fileExists then
|
if fname.fileExists then
|
||||||
fPresets.loadFromFile(fname)
|
fPresets.loadFromFile(fname);
|
||||||
else
|
|
||||||
|
//TODO-cmaintenance: remove this the second version following 3.6.7
|
||||||
|
for i:= 5 downto 0 do
|
||||||
begin
|
begin
|
||||||
with fPresets.addPreset do
|
if (i < fPresets.count) and (fPresets[i].name = h[i]) then
|
||||||
|
fPresets.fCollection.Delete(i);
|
||||||
|
end;
|
||||||
|
|
||||||
|
with fPresets.insertPreset(0) do
|
||||||
begin
|
begin
|
||||||
|
fIsHardcoded := true;
|
||||||
fName :='bright';
|
fName :='bright';
|
||||||
fBackground := clWhite;
|
fBackground := clWhite;
|
||||||
getHl.whites.define(clNone);
|
getHl.whites.define(clNone);
|
||||||
|
@ -377,8 +396,9 @@ begin
|
||||||
getHl.types.Style:=[fsBold];
|
getHl.types.Style:=[fsBold];
|
||||||
getHl.phobosStyleType := True;
|
getHl.phobosStyleType := True;
|
||||||
end;
|
end;
|
||||||
with fPresets.addPreset do
|
with fPresets.insertPreset(1) do
|
||||||
begin
|
begin
|
||||||
|
fIsHardcoded := true;
|
||||||
fName :='dark';
|
fName :='dark';
|
||||||
getHl.whites.FrameEdges := sfeNone;
|
getHl.whites.FrameEdges := sfeNone;
|
||||||
getHl.numbers.Foreground := 16761218;
|
getHl.numbers.Foreground := 16761218;
|
||||||
|
@ -421,8 +441,9 @@ begin
|
||||||
selection.BackPriority:= 2;
|
selection.BackPriority:= 2;
|
||||||
getHl.phobosStyleType := True;
|
getHl.phobosStyleType := True;
|
||||||
end;
|
end;
|
||||||
with fPresets.addPreset do
|
with fPresets.insertPreset(2) do
|
||||||
begin
|
begin
|
||||||
|
fIsHardcoded := true;
|
||||||
fName :='Mustard';
|
fName :='Mustard';
|
||||||
getHl.whites.FrameEdges := sfeNone;
|
getHl.whites.FrameEdges := sfeNone;
|
||||||
getHl.numbers.FrameEdges := sfeNone;
|
getHl.numbers.FrameEdges := sfeNone;
|
||||||
|
@ -462,8 +483,9 @@ begin
|
||||||
selection.BackPriority := 1;
|
selection.BackPriority := 1;
|
||||||
getHl.phobosStyleType := True;
|
getHl.phobosStyleType := True;
|
||||||
end;
|
end;
|
||||||
with fPresets.addPreset do
|
with fPresets.insertPreset(3) do
|
||||||
begin
|
begin
|
||||||
|
fIsHardcoded := true;
|
||||||
name := 'Mars bright';
|
name := 'Mars bright';
|
||||||
getHl.identifiers.Foreground := clBlack;
|
getHl.identifiers.Foreground := clBlack;
|
||||||
getHl.identifiers.FrameEdges := sfeNone;
|
getHl.identifiers.FrameEdges := sfeNone;
|
||||||
|
@ -498,8 +520,9 @@ begin
|
||||||
selection.BackPriority := 10;
|
selection.BackPriority := 10;
|
||||||
getHl.phobosStyleType := True;
|
getHl.phobosStyleType := True;
|
||||||
end;
|
end;
|
||||||
with fPresets.addPreset do
|
with fPresets.insertPreset(4) do
|
||||||
begin
|
begin
|
||||||
|
fIsHardcoded := true;
|
||||||
name := 'Mars dark';
|
name := 'Mars dark';
|
||||||
getHl.numbers.Foreground := 7763655;
|
getHl.numbers.Foreground := 7763655;
|
||||||
getHl.symbols.Foreground := 5460961;
|
getHl.symbols.Foreground := 5460961;
|
||||||
|
@ -534,8 +557,9 @@ begin
|
||||||
selection.Foreground := clNone;
|
selection.Foreground := clNone;
|
||||||
getHl.phobosStyleType := True;
|
getHl.phobosStyleType := True;
|
||||||
end;
|
end;
|
||||||
with fPresets.addPreset do
|
with fPresets.insertPreset(5) do
|
||||||
begin
|
begin
|
||||||
|
fIsHardcoded := true;
|
||||||
name := 'Soft dust';
|
name := 'Soft dust';
|
||||||
getHl.phobosStyleType := True;
|
getHl.phobosStyleType := True;
|
||||||
getHl.foldKinds := [fkBrackets, fkRegion];
|
getHl.foldKinds := [fkBrackets, fkRegion];
|
||||||
|
@ -575,7 +599,6 @@ begin
|
||||||
selection.Background := $9DAABC;
|
selection.Background := $9DAABC;
|
||||||
selection.Foreground := clNone;
|
selection.Foreground := clNone;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
|
||||||
fEditor := TSynEdit.Create(self);
|
fEditor := TSynEdit.Create(self);
|
||||||
fEditor.Parent:= self;
|
fEditor.Parent:= self;
|
||||||
|
@ -657,7 +680,12 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCED2SynPresetsLoaderForm.Destroy;
|
destructor TCED2SynPresetsLoaderForm.Destroy;
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
begin
|
begin
|
||||||
|
for i:= fPresets.count-1 downto 0 do
|
||||||
|
if fPresets.preset[i].isHardCoded then
|
||||||
|
fPresets.fCollection.Delete(i);
|
||||||
fPresets.saveToFile(getCoeditDocPath + optfname);
|
fPresets.saveToFile(getCoeditDocPath + optfname);
|
||||||
fBackup.Free;
|
fBackup.Free;
|
||||||
EntitiesConnector.removeObserver(self);
|
EntitiesConnector.removeObserver(self);
|
||||||
|
@ -722,8 +750,17 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCED2SynPresetsLoaderForm.btnDelClick(sender: TObject);
|
procedure TCED2SynPresetsLoaderForm.btnDelClick(sender: TObject);
|
||||||
|
var
|
||||||
|
o: integer;
|
||||||
begin
|
begin
|
||||||
|
if (fPresets.preset[fList.ItemIndex].isHardCoded) then
|
||||||
|
exit;
|
||||||
|
o := fList.ItemIndex;
|
||||||
|
fPropEd.TIObject := nil;
|
||||||
fPresets.fCollection.Delete(fList.ItemIndex);
|
fPresets.fCollection.Delete(fList.ItemIndex);
|
||||||
|
if o >= fPresets.count then
|
||||||
|
o -= 1 ;
|
||||||
|
fList.ItemIndex:=o;
|
||||||
updateList;
|
updateList;
|
||||||
lstBoxSelChange(nil);
|
lstBoxSelChange(nil);
|
||||||
end;
|
end;
|
||||||
|
|
Loading…
Reference in New Issue