mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 13:39:24 +02:00
EditorOptions: fixed default colors for none-pascal (html, xml), none-default (twilight, ocean). Any color ticked(checkbox) to default, was set to the default of SynEdit (black on white) instead of the default of the scheme. issue #7353
git-svn-id: trunk@21319 -
This commit is contained in:
parent
86638f7ba8
commit
31dde5e299
@ -64,6 +64,7 @@ type
|
|||||||
(lshNone, lshText, lshFreePascal, lshDelphi, lshLFM, lshXML, lshHTML,
|
(lshNone, lshText, lshFreePascal, lshDelphi, lshLFM, lshXML, lshHTML,
|
||||||
lshCPP, lshPerl, lshJava, lshBash, lshPython, lshPHP, lshSQL, lshJScript);
|
lshCPP, lshPerl, lshJava, lshBash, lshPython, lshPHP, lshSQL, lshJScript);
|
||||||
|
|
||||||
|
// TODO: add defaults for other highlighters too (like html, xml...)
|
||||||
TPascalHilightAttribute = (
|
TPascalHilightAttribute = (
|
||||||
phaAssembler, phaComment, phaDirective, phaReservedWord, phaNumber,
|
phaAssembler, phaComment, phaDirective, phaReservedWord, phaNumber,
|
||||||
phaString, phaSymbol
|
phaString, phaSymbol
|
||||||
@ -221,6 +222,43 @@ type
|
|||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
|
(* How it works:
|
||||||
|
- All color settings (highlighter, markup, others are stored on the Highlighters.
|
||||||
|
For this each Highlighter is extended by:
|
||||||
|
AddSpecialHilightAttribsToHighlighter
|
||||||
|
|
||||||
|
- GetDefaultsForPascalAttribute
|
||||||
|
replaces all clDefault with the values from the 'Default' colors
|
||||||
|
which can be clNone (The SynEdit default is Black on White; see SetMarkupColors)
|
||||||
|
|
||||||
|
- ReadDefaultsForHighlighterSettings
|
||||||
|
- for a 'pascal' highlighter
|
||||||
|
will set all values as provided by: GetDefaultsForPascalAttribute
|
||||||
|
- for any other highlighte
|
||||||
|
^ Will read the user's configuration (ReadHighlighterSettings) for 'pascal',
|
||||||
|
which starts with GetDefaultsForPascalAttribute
|
||||||
|
^ All defaults for AdditionalAttributes and selected language attributes
|
||||||
|
(MappedAttributes) will be set to the user's pascal config
|
||||||
|
^ The remaining language attributes are left to the Values defined in the
|
||||||
|
Highlighters Create
|
||||||
|
//Todo: Add them to TPascalHilightAttribute, so they can have defaults
|
||||||
|
per colorscheme too
|
||||||
|
|
||||||
|
- ReadHighlighterSettings
|
||||||
|
loads the differences between the users setting and the defaults
|
||||||
|
|
||||||
|
* clDefault vs clNone
|
||||||
|
- clDefault is replaced with the values from the 'Default' colors (GetDefaultsForPascalAttribute)
|
||||||
|
this can be clNone
|
||||||
|
- clDefault should not make it outside GetDefaultsForPascalAttribute
|
||||||
|
- editor_color_option_frame expects clNone (but will take and convert clDefault)
|
||||||
|
- clNone is handled inside SynEdit / clDefault is not expected in SynEdit
|
||||||
|
^ clnone in Additional Attributes means the pascal/ language Attribute is used
|
||||||
|
^ clnone in pascal/ language Attributes means the SynEdit.Font.Color is used
|
||||||
|
for forground / SynEdit.Color is used for BackGround
|
||||||
|
|
||||||
|
* Additional Attributes should use clNone. They always fallback to a pascal/language attribute
|
||||||
|
*)
|
||||||
DEFAULT_COLOR_SCHEME: TPascalColorScheme = (
|
DEFAULT_COLOR_SCHEME: TPascalColorScheme = (
|
||||||
Name: 'Default';
|
Name: 'Default';
|
||||||
Default: (BG: clNone; FG: clNone; FC: clNone; Styles: []; StylesMask: []);
|
Default: (BG: clNone; FG: clNone; FC: clNone; Styles: []; StylesMask: []);
|
||||||
@ -882,7 +920,7 @@ type
|
|||||||
procedure SetMarkupColor(Syn: TSrcIDEHighlighter;
|
procedure SetMarkupColor(Syn: TSrcIDEHighlighter;
|
||||||
AddHilightAttr: TAdditionalHilightAttribute;
|
AddHilightAttr: TAdditionalHilightAttribute;
|
||||||
aMarkup: TSynSelectedColor);
|
aMarkup: TSynSelectedColor);
|
||||||
procedure SetMarkupColors(Syn: TSrcIDEHighlighter; aSynEd: TSynEdit);
|
procedure SetMarkupColors(Syn: TSrcIDEHighlighter; aSynEd: TSynEdit; SynColorScheme: String = '');
|
||||||
published
|
published
|
||||||
// general options
|
// general options
|
||||||
property SynEditOptions: TSynEditorOptions
|
property SynEditOptions: TSynEditorOptions
|
||||||
@ -3165,8 +3203,7 @@ begin
|
|||||||
continue;
|
continue;
|
||||||
// check, if there is a known mapping for this attribute
|
// check, if there is a known mapping for this attribute
|
||||||
if HilightInfo.MappedAttributes <> Nil then
|
if HilightInfo.MappedAttributes <> Nil then
|
||||||
MappedAttriName :=
|
MappedAttriName := HilightInfo.MappedAttributes.Values[AttriName]
|
||||||
HilightInfo.MappedAttributes.Values[AttriName]
|
|
||||||
else
|
else
|
||||||
MappedAttriName := '';
|
MappedAttriName := '';
|
||||||
if MappedAttriName = '' then
|
if MappedAttriName = '' then
|
||||||
@ -3570,9 +3607,12 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEditorOptions.SetMarkupColors(Syn: TSrcIDEHighlighter; aSynEd: TSynEdit);
|
procedure TEditorOptions.SetMarkupColors(Syn: TSrcIDEHighlighter; aSynEd: TSynEdit;
|
||||||
(* ASynEd.Highlighter has a copy of all the ahaAttributes
|
SynColorScheme: String = '');
|
||||||
|
(* - ASynEd.Highlighter has a copy of all the ahaAttributes
|
||||||
SetMarkupColors copies them from the highlighter to the synedit
|
SetMarkupColors copies them from the highlighter to the synedit
|
||||||
|
- For this reason (if called from SourceNotebook)
|
||||||
|
Syn and aSynEd.Highlighter should be equal
|
||||||
*)
|
*)
|
||||||
procedure SetMarkupColorByClass(AddHilightAttr: TAdditionalHilightAttribute;
|
procedure SetMarkupColorByClass(AddHilightAttr: TAdditionalHilightAttribute;
|
||||||
aClass: TSynEditMarkupClass);
|
aClass: TSynEditMarkupClass);
|
||||||
@ -3592,7 +3632,23 @@ procedure TEditorOptions.SetMarkupColors(Syn: TSrcIDEHighlighter; aSynEd: TSynEd
|
|||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
Attri: TSynHighlighterAttributes;
|
Attri: TSynHighlighterAttributes;
|
||||||
|
Scheme: TPascalColorScheme;
|
||||||
begin
|
begin
|
||||||
|
// Find current color scheme for default colors
|
||||||
|
if (SynColorScheme = '') and (aSynEd.Highlighter <> nil) then
|
||||||
|
SynColorScheme := ReadColorScheme(aSynEd.Highlighter.LanguageName);
|
||||||
|
if (SynColorScheme <> '') then
|
||||||
|
try
|
||||||
|
Scheme := GetColorScheme(SynColorScheme);
|
||||||
|
if (Scheme.Default.BG = clNone) or (Scheme.Default.BG = clDefault)
|
||||||
|
then aSynEd.Color := clWhite
|
||||||
|
else aSynEd.Color := Scheme.Default.BG;
|
||||||
|
if (Scheme.Default.FG = clNone) or (Scheme.Default.FG = clDefault)
|
||||||
|
then aSynEd.Font.Color := clBlack
|
||||||
|
else aSynEd.Font.Color := Scheme.Default.FG;
|
||||||
|
except
|
||||||
|
end;
|
||||||
|
|
||||||
Attri := GetSynAttributeByAha(aSynEd.Highlighter, ahaGutter);
|
Attri := GetSynAttributeByAha(aSynEd.Highlighter, ahaGutter);
|
||||||
if Attri <> nil then
|
if Attri <> nil then
|
||||||
aSynEd.Gutter.Color := Attri.Background;
|
aSynEd.Gutter.Color := Attri.Background;
|
||||||
@ -3734,6 +3790,9 @@ begin
|
|||||||
ASynEdit.ExtraCharSpacing := fExtraCharSpacing;
|
ASynEdit.ExtraCharSpacing := fExtraCharSpacing;
|
||||||
ASynEdit.ExtraLineSpacing := fExtraLineSpacing;
|
ASynEdit.ExtraLineSpacing := fExtraLineSpacing;
|
||||||
ASynEdit.MaxUndo := fUndoLimit;
|
ASynEdit.MaxUndo := fUndoLimit;
|
||||||
|
// The Highlighter on the SynEdit will have been initialized with the configured
|
||||||
|
// values already (including all the additional-attributes.
|
||||||
|
// Just copy the colors from the SynEdit's highlighter to the SynEdit's Markup and co
|
||||||
SetMarkupColors(ASynEdit.Highlighter, ASynEdit);
|
SetMarkupColors(ASynEdit.Highlighter, ASynEdit);
|
||||||
|
|
||||||
MarkCaret := TSynEditMarkupHighlightAllCaret(ASynEdit.MarkupByClass[TSynEditMarkupHighlightAllCaret]);
|
MarkCaret := TSynEditMarkupHighlightAllCaret(ASynEdit.MarkupByClass[TSynEditMarkupHighlightAllCaret]);
|
||||||
|
@ -982,7 +982,8 @@ begin
|
|||||||
for a := Low(PreviewEdits) to High(PreviewEdits) do
|
for a := Low(PreviewEdits) to High(PreviewEdits) do
|
||||||
if PreviewEdits[a] <> nil then
|
if PreviewEdits[a] <> nil then
|
||||||
begin
|
begin
|
||||||
EditorOpts.SetMarkupColors(PreviewEdits[a].Highlighter, PreviewEdits[a]);
|
EditorOpts.SetMarkupColors(PreviewEdits[a].Highlighter, PreviewEdits[a],
|
||||||
|
GetCurColorScheme(PreviewSyn.LanguageName));
|
||||||
PreviewEdits[a].Invalidate;
|
PreviewEdits[a].Invalidate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user