fix #293 - Changes to hardcoded highlighter presets are not visible until the old setting file is deleted

This commit is contained in:
Basile Burg 2018-04-13 23:47:26 +02:00
parent ddf268e685
commit ab68e7287e
1 changed files with 282 additions and 245 deletions

View File

@ -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,258 +331,273 @@ 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
begin fPresets.fCollection.Delete(i);
fName :='bright'; end;
fBackground := clWhite;
getHl.whites.define(clNone); with fPresets.insertPreset(0) do
getHl.numbers.define($000079F2); begin
getHl.symbols.define(clMaroon); fIsHardcoded := true;
getHl.identifiers.define(clBlack); fName :='bright';
getHl.comments.define(clGreen,[fsItalic]); fBackground := clWhite;
getHl.strings.define(clBlue); getHl.whites.define(clNone);
getHl.keywords.define(clNavy,[fsBold]); getHl.numbers.define($000079F2);
getHl.ddoc.define(clTeal); getHl.symbols.define(clMaroon);
getHl.inlineAsm.define(clGray,[fsBold]); getHl.identifiers.define(clBlack);
getHl.special.define(clNavy,[fsBold]); getHl.comments.define(clGreen,[fsItalic]);
getHl.errors.define(clBlack,[],clNone,clRed,slsWaved,sfeBottom,[]); getHl.strings.define(clBlue);
getHl.attributes.define(clNavy,[fsBold]); getHl.keywords.define(clNavy,[fsBold]);
// getHl.ddoc.define(clTeal);
folding.Background := clNone; getHl.inlineAsm.define(clGray,[fsBold]);
folding.Foreground := clDkGray; getHl.special.define(clNavy,[fsBold]);
folding.FrameColor := clDkGray; getHl.errors.define(clBlack,[],clNone,clRed,slsWaved,sfeBottom,[]);
// getHl.attributes.define(clNavy,[fsBold]);
mouseLink.Style := [fsUnderline, fsBold]; //
mouseLink.StyleMask := []; folding.Background := clNone;
mouseLink.Foreground := clNone; folding.Foreground := clDkGray;
mouseLink.Background := clNone; folding.FrameColor := clDkGray;
// //
bracketMatch.Foreground := clRed; mouseLink.Style := [fsUnderline, fsBold];
bracketMatch.Background := clNone; mouseLink.StyleMask := [];
// mouseLink.Foreground := clNone;
identifierMatch.Foreground:= clNone; mouseLink.Background := clNone;
identifierMatch.Background:= clSilver; //
identifierMatch.BackAlpha:=70; bracketMatch.Foreground := clRed;
identifierMatch.BackPriority:= 10; bracketMatch.Background := clNone;
// //
selection.Background:= 15984598; identifierMatch.Foreground:= clNone;
selection.Foreground:= clNone; identifierMatch.Background:= clSilver;
// identifierMatch.BackAlpha:=70;
currentLine.Background:= 15789545; identifierMatch.BackPriority:= 10;
currentLine.Foreground:= clNone; //
// selection.Background:= 15984598;
getHl.types.Background:=clNone; selection.Foreground:= clNone;
getHl.types.Foreground:=clBlack; //
getHl.types.Style:=[fsBold]; currentLine.Background:= 15789545;
getHl.phobosStyleType := True; currentLine.Foreground:= clNone;
end; //
with fPresets.addPreset do getHl.types.Background:=clNone;
begin getHl.types.Foreground:=clBlack;
fName :='dark'; getHl.types.Style:=[fsBold];
getHl.whites.FrameEdges := sfeNone; getHl.phobosStyleType := True;
getHl.numbers.Foreground := 16761218; end;
getHl.numbers.FrameEdges := sfeNone; with fPresets.insertPreset(1) do
getHl.numbers.Style := []; begin
getHl.symbols.Foreground := clYellow; fIsHardcoded := true;
getHl.symbols.FrameEdges := sfeNone; fName :='dark';
getHl.identifiers.Foreground := 14807024; getHl.whites.FrameEdges := sfeNone;
getHl.identifiers.FrameEdges := sfeNone; getHl.numbers.Foreground := 16761218;
getHl.comments.Foreground := 13092807; getHl.numbers.FrameEdges := sfeNone;
getHl.comments.FrameEdges := sfeNone; getHl.numbers.Style := [];
getHl.strings.Foreground := 5157104; getHl.symbols.Foreground := clYellow;
getHl.strings.FrameEdges := sfeNone; getHl.symbols.FrameEdges := sfeNone;
getHl.keywords.Foreground := 9684887; getHl.identifiers.Foreground := 14807024;
getHl.keywords.FrameEdges := sfeNone; getHl.identifiers.FrameEdges := sfeNone;
getHl.ddoc.Foreground := 14671730; getHl.comments.Foreground := 13092807;
getHl.ddoc.FrameEdges := sfeNone; getHl.comments.FrameEdges := sfeNone;
getHl.inlineAsm.Foreground := 15500491; getHl.strings.Foreground := 5157104;
getHl.inlineAsm.FrameEdges := sfeNone; getHl.strings.FrameEdges := sfeNone;
getHl.special.Foreground := 9684887; getHl.keywords.Foreground := 9684887;
getHl.special.FrameEdges := sfeNone; getHl.keywords.FrameEdges := sfeNone;
getHl.errors.Foreground := 14807024; getHl.ddoc.Foreground := 14671730;
getHl.attributes.Foreground := 9684887; getHl.ddoc.FrameEdges := sfeNone;
getHl.attributes.FrameEdges := sfeNone; getHl.inlineAsm.Foreground := 15500491;
getHl.types.Background:=clNone; getHl.inlineAsm.FrameEdges := sfeNone;
getHl.types.Foreground:=14807024; getHl.special.Foreground := 9684887;
getHl.types.Style:=[fsBold]; getHl.special.FrameEdges := sfeNone;
background := 4210752; getHl.errors.Foreground := 14807024;
bracketMatch.Background := clNone; getHl.attributes.Foreground := 9684887;
bracketMatch.Foreground := clFuchsia; getHl.attributes.FrameEdges := sfeNone;
currentLine.Background := 6184542; getHl.types.Background:=clNone;
currentLine.Foreground := clNone; getHl.types.Foreground:=14807024;
folding.Background := 7303023; getHl.types.Style:=[fsBold];
folding.Foreground := clYellow; background := 4210752;
identifierMatch.Background := 7697781; bracketMatch.Background := clNone;
identifierMatch.BackPriority:= 2; bracketMatch.Foreground := clFuchsia;
identifierMatch.Foreground := clNone; currentLine.Background := 6184542;
selection.Background := 10132122; currentLine.Foreground := clNone;
selection.Foreground := clNone; folding.Background := 7303023;
selection.BackPriority:= 2; folding.Foreground := clYellow;
getHl.phobosStyleType := True; identifierMatch.Background := 7697781;
end; identifierMatch.BackPriority:= 2;
with fPresets.addPreset do identifierMatch.Foreground := clNone;
begin selection.Background := 10132122;
fName :='Mustard'; selection.Foreground := clNone;
getHl.whites.FrameEdges := sfeNone; selection.BackPriority:= 2;
getHl.numbers.FrameEdges := sfeNone; getHl.phobosStyleType := True;
getHl.symbols.Foreground := 3487083; end;
getHl.symbols.FrameEdges := sfeNone; with fPresets.insertPreset(2) do
getHl.identifiers.Foreground := 1975089; begin
getHl.identifiers.FrameEdges := sfeNone; fIsHardcoded := true;
getHl.comments.Foreground := 5206404; fName :='Mustard';
getHl.comments.FrameEdges := sfeNone; getHl.whites.FrameEdges := sfeNone;
getHl.strings.Foreground := 6056852; getHl.numbers.FrameEdges := sfeNone;
getHl.strings.FrameEdges := sfeNone; getHl.symbols.Foreground := 3487083;
getHl.keywords.Foreground := 3226202; getHl.symbols.FrameEdges := sfeNone;
getHl.keywords.FrameEdges := sfeNone; getHl.identifiers.Foreground := 1975089;
getHl.ddoc.Foreground := 6259092; getHl.identifiers.FrameEdges := sfeNone;
getHl.ddoc.FrameEdges := sfeNone; getHl.comments.Foreground := 5206404;
getHl.inlineAsm.Foreground := 3379344; getHl.comments.FrameEdges := sfeNone;
getHl.inlineAsm.FrameEdges := sfeNone; getHl.strings.Foreground := 6056852;
getHl.special.Foreground := 3226202; getHl.strings.FrameEdges := sfeNone;
getHl.special.FrameEdges := sfeNone; getHl.keywords.Foreground := 3226202;
getHl.errors.Foreground := 1975089; getHl.keywords.FrameEdges := sfeNone;
getHl.attributes.Foreground := 3226202; getHl.ddoc.Foreground := 6259092;
getHl.attributes.FrameEdges := sfeNone; getHl.ddoc.FrameEdges := sfeNone;
getHl.types.Background:=clNone; getHl.inlineAsm.Foreground := 3379344;
getHl.types.Foreground:=1975089; getHl.inlineAsm.FrameEdges := sfeNone;
getHl.types.Style:=[fsBold]; getHl.special.Foreground := 3226202;
background := 9818842; getHl.special.FrameEdges := sfeNone;
currentLine.Background := 9030871; getHl.errors.Foreground := 1975089;
currentLine.Foreground := clNone; getHl.attributes.Foreground := 3226202;
folding.Background := clNone; getHl.attributes.FrameEdges := sfeNone;
folding.Foreground := clYellow; getHl.types.Background:=clNone;
folding.FrameColor := clYellow; getHl.types.Foreground:=1975089;
identifierMatch.Background := 10278890; getHl.types.Style:=[fsBold];
identifierMatch.BackPriority:= 2; background := 9818842;
identifierMatch.Foreground := clNone; currentLine.Background := 9030871;
selection.Background := 8448232; currentLine.Foreground := clNone;
selection.Foreground := clNone; folding.Background := clNone;
selection.BackPriority := 1; folding.Foreground := clYellow;
getHl.phobosStyleType := True; folding.FrameColor := clYellow;
end; identifierMatch.Background := 10278890;
with fPresets.addPreset do identifierMatch.BackPriority:= 2;
begin identifierMatch.Foreground := clNone;
name := 'Mars bright'; selection.Background := 8448232;
getHl.identifiers.Foreground := clBlack; selection.Foreground := clNone;
getHl.identifiers.FrameEdges := sfeNone; selection.BackPriority := 1;
getHl.numbers.Foreground := 7763655; getHl.phobosStyleType := True;
getHl.comments.Foreground := clMedGray; end;
getHl.strings.Foreground := 3750276; with fPresets.insertPreset(3) do
getHl.keywords.Foreground := 2631874; begin
getHl.ddoc.Foreground := 7105644; fIsHardcoded := true;
getHl.special.Foreground := 2631874; name := 'Mars bright';
getHl.attributes.Foreground := 2631874; getHl.identifiers.Foreground := clBlack;
getHl.types.Background:=clNone; getHl.identifiers.FrameEdges := sfeNone;
getHl.types.Foreground:=clBlack; getHl.numbers.Foreground := 7763655;
getHl.types.Style:=[fsBold]; getHl.comments.Foreground := clMedGray;
background := 16579836; getHl.strings.Foreground := 3750276;
bracketMatch.Background := 12698077; getHl.keywords.Foreground := 2631874;
bracketMatch.Foreground := clNone; getHl.ddoc.Foreground := 7105644;
currentLine.Background := 15263976; getHl.special.Foreground := 2631874;
currentLine.Foreground := clNone; getHl.attributes.Foreground := 2631874;
folding.Background := clNone; getHl.types.Background:=clNone;
folding.Foreground := clNone; getHl.types.Foreground:=clBlack;
folding.FrameColor := clBlack; getHl.types.Style:=[fsBold];
identifierMatch.Background := clNone; background := 16579836;
identifierMatch.Foreground := clNone; bracketMatch.Background := 12698077;
identifierMatch.FrameColor := clGray; bracketMatch.Foreground := clNone;
identifierMatch.BackPriority := 10; currentLine.Background := 15263976;
mouseLink.Background := clNone; currentLine.Foreground := clNone;
mouseLink.Foreground := clNone; folding.Background := clNone;
mouseLink.FrameColor := 3166415; folding.Foreground := clNone;
mouseLink.FrameEdges := sfeBottom; folding.FrameColor := clBlack;
selection.Background := $C3E1E1; identifierMatch.Background := clNone;
selection.Foreground := clNone; identifierMatch.Foreground := clNone;
selection.BackPriority := 10; identifierMatch.FrameColor := clGray;
getHl.phobosStyleType := True; identifierMatch.BackPriority := 10;
end; mouseLink.Background := clNone;
with fPresets.addPreset do mouseLink.Foreground := clNone;
begin mouseLink.FrameColor := 3166415;
name := 'Mars dark'; mouseLink.FrameEdges := sfeBottom;
getHl.numbers.Foreground := 7763655; selection.Background := $C3E1E1;
getHl.symbols.Foreground := 5460961; selection.Foreground := clNone;
getHl.identifiers.Foreground := clCream; selection.BackPriority := 10;
getHl.comments.Foreground := 5095359; getHl.phobosStyleType := True;
getHl.strings.Foreground := 10790107; end;
getHl.keywords.Foreground := 4539883; with fPresets.insertPreset(4) do
getHl.ddoc.Foreground := 10540501; begin
getHl.inlineAsm.Foreground := 12303291; fIsHardcoded := true;
getHl.special.Foreground := 2631874; name := 'Mars dark';
getHl.errors.Foreground := clCream; getHl.numbers.Foreground := 7763655;
getHl.attributes.Foreground := 2631874; getHl.symbols.Foreground := 5460961;
getHl.types.Background:=clNone; getHl.identifiers.Foreground := clCream;
getHl.types.Foreground:=clCream; getHl.comments.Foreground := 5095359;
getHl.types.Style:=[fsBold]; getHl.strings.Foreground := 10790107;
background := 5263440; getHl.keywords.Foreground := 4539883;
bracketMatch.Background := 9276865; getHl.ddoc.Foreground := 10540501;
bracketMatch.Foreground := clNone; getHl.inlineAsm.Foreground := 12303291;
currentLine.Background := 4013373; getHl.special.Foreground := 2631874;
currentLine.Foreground := clNone; getHl.errors.Foreground := clCream;
folding.Background := clNone; getHl.attributes.Foreground := 2631874;
folding.Foreground := clNone; getHl.types.Background:=clNone;
folding.FrameColor := clBlack; getHl.types.Foreground:=clCream;
identifierMatch.Background := 6381928; getHl.types.Style:=[fsBold];
identifierMatch.Foreground := clNone; background := 5263440;
identifierMatch.BackPriority := 10; bracketMatch.Background := 9276865;
mouseLink.Background := clNone; bracketMatch.Foreground := clNone;
mouseLink.Foreground := clNone; currentLine.Background := 4013373;
mouseLink.FrameColor := clRed; currentLine.Foreground := clNone;
mouseLink.FrameEdges := sfeBottom; folding.Background := clNone;
selection.Background := 12837345; folding.Foreground := clNone;
selection.Foreground := clNone; folding.FrameColor := clBlack;
getHl.phobosStyleType := True; identifierMatch.Background := 6381928;
end; identifierMatch.Foreground := clNone;
with fPresets.addPreset do identifierMatch.BackPriority := 10;
begin mouseLink.Background := clNone;
name := 'Soft dust'; mouseLink.Foreground := clNone;
getHl.phobosStyleType := True; mouseLink.FrameColor := clRed;
getHl.foldKinds := [fkBrackets, fkRegion]; mouseLink.FrameEdges := sfeBottom;
getHl.whites.FrameEdges := sfeNone; selection.Background := 12837345;
getHl.numbers.Foreground := 8618785; selection.Foreground := clNone;
getHl.numbers.FrameEdges := sfeNone; getHl.phobosStyleType := True;
getHl.symbols.Foreground := 5120546; end;
getHl.symbols.FrameEdges := sfeNone; with fPresets.insertPreset(5) do
getHl.identifiers.FrameEdges := sfeNone; begin
getHl.comments.FrameEdges := sfeNone; fIsHardcoded := true;
getHl.comments.Style := []; name := 'Soft dust';
getHl.strings.Foreground := 7171346; getHl.phobosStyleType := True;
getHl.strings.FrameEdges := sfeNone; getHl.foldKinds := [fkBrackets, fkRegion];
getHl.keywords.Foreground := 6498601; getHl.whites.FrameEdges := sfeNone;
getHl.keywords.FrameEdges := sfeNone; getHl.numbers.Foreground := 8618785;
getHl.ddoc.Foreground := clGreen; getHl.numbers.FrameEdges := sfeNone;
getHl.ddoc.FrameEdges := sfeNone; getHl.symbols.Foreground := 5120546;
getHl.ddoc.Style := [fsBold]; getHl.symbols.FrameEdges := sfeNone;
getHl.inlineAsm.FrameEdges := sfeNone; getHl.identifiers.FrameEdges := sfeNone;
getHl.special.FrameEdges := sfeNone; getHl.comments.FrameEdges := sfeNone;
getHl.attributes.FrameEdges := sfeNone; getHl.comments.Style := [];
background := 15395049; getHl.strings.Foreground := 7171346;
bracketMatch.Background := clNone; getHl.strings.FrameEdges := sfeNone;
bracketMatch.Foreground := clRed; getHl.keywords.Foreground := 6498601;
currentLine.Background := 14801617; getHl.keywords.FrameEdges := sfeNone;
currentLine.Foreground := clNone; getHl.ddoc.Foreground := clGreen;
folding.Background := clNone; getHl.ddoc.FrameEdges := sfeNone;
folding.Foreground := clGray; getHl.ddoc.Style := [fsBold];
folding.FrameColor := clGray; getHl.inlineAsm.FrameEdges := sfeNone;
identifierMatch.Background := clSilver; getHl.special.FrameEdges := sfeNone;
identifierMatch.Foreground := clNone; getHl.attributes.FrameEdges := sfeNone;
identifierMatch.BackPriority := 10; background := 15395049;
identifierMatch.BackAlpha := 70; bracketMatch.Background := clNone;
mouseLink.Background := clNone; bracketMatch.Foreground := clRed;
mouseLink.Foreground := clNone; currentLine.Background := 14801617;
mouseLink.Style := [fsBold, fsUnderline]; currentLine.Foreground := clNone;
selection.Background := $9DAABC; folding.Background := clNone;
selection.Foreground := clNone; folding.Foreground := clGray;
end; folding.FrameColor := clGray;
identifierMatch.Background := clSilver;
identifierMatch.Foreground := clNone;
identifierMatch.BackPriority := 10;
identifierMatch.BackAlpha := 70;
mouseLink.Background := clNone;
mouseLink.Foreground := clNone;
mouseLink.Style := [fsBold, fsUnderline];
selection.Background := $9DAABC;
selection.Foreground := clNone;
end; end;
fEditor := TSynEdit.Create(self); fEditor := TSynEdit.Create(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;