mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 10:47:58 +02:00
SynEdit: TextAttributes refactor/cleanup: move some properties to highlighter / move "feature" property to IDE
git-svn-id: trunk@41180 -
This commit is contained in:
parent
3cef71b547
commit
655de9221e
@ -66,13 +66,6 @@ type
|
||||
property NeedsReScanRealStartIndex: Integer read GetNeedsReScanRealStartIndex;
|
||||
end;
|
||||
|
||||
TSynHighlighterAttrFeature =
|
||||
( hafBackColor, hafForeColor, hafFrameColor,
|
||||
hafStyle, hafStyleMask,
|
||||
hafFrameStyle, hafFrameEdges
|
||||
);
|
||||
TSynHighlighterAttrFeatures = set of TSynHighlighterAttrFeature;
|
||||
|
||||
{ TLazSynCustomTextAttributes }
|
||||
|
||||
TLazSynCustomTextAttributes = class(TPersistent)
|
||||
@ -127,7 +120,6 @@ type
|
||||
FFrameStyleDefault: TSynLineStyle;
|
||||
FStyleDefault: TFontStyles;
|
||||
FStyleMaskDefault: TFontStyles;
|
||||
FFeatures: TSynHighlighterAttrFeatures;
|
||||
FStoredName: string;
|
||||
FName: string;
|
||||
FOnChange: TNotifyEvent;
|
||||
@ -149,7 +141,7 @@ type
|
||||
public
|
||||
constructor Create;
|
||||
constructor Create(attribName: string; aStoredName: String = '');
|
||||
procedure InternalSaveDefaultValues;
|
||||
procedure InternalSaveDefaultValues; virtual;
|
||||
function LoadFromBorlandRegistry(rootKey: HKEY; attrKey, attrName: string;
|
||||
oldStyle: boolean): boolean; virtual;
|
||||
function LoadFromRegistry(Reg: TRegistry): boolean;
|
||||
@ -162,7 +154,6 @@ type
|
||||
property Name: string read fName;
|
||||
property StoredName: string read FStoredName write FStoredName;
|
||||
property OnChange: TNotifyEvent read fOnChange write fOnChange;
|
||||
property Features: TSynHighlighterAttrFeatures read FFeatures write FFeatures;
|
||||
published
|
||||
property Background stored GetBackgroundColorStored;
|
||||
property Foreground stored GetForegroundColorStored;
|
||||
@ -170,17 +161,33 @@ type
|
||||
property FrameStyle stored GetFrameStyleStored;
|
||||
property FrameEdges stored GetFrameEdgesStored;
|
||||
property Style stored GetFontStyleStored;
|
||||
// TODO: StyleMask move to TSynHighlighterAttributesModifier
|
||||
property StyleMask stored GetFontStyleMaskStored;
|
||||
// FStyle = [], FStyleMask = [] ==> no modification
|
||||
// FStyle = [fsBold], FStyleMask = [] ==> invert fsBold
|
||||
// FStyle = [], FStyleMask = [fsBold] ==> clear fsBold
|
||||
// FStyle = [fsBold], FStyleMask = [fsBold] ==> set fsBold
|
||||
end;
|
||||
|
||||
{ TSynHighlighterAttributesModifier }
|
||||
|
||||
TSynHighlighterAttributesModifier = class(TSynHighlighterAttributes)
|
||||
{strict} private
|
||||
private
|
||||
FBackPriority: integer;
|
||||
FForePriority: integer;
|
||||
FFramePriority: integer;
|
||||
FStylePriority: Array [TFontStyle] of integer;
|
||||
|
||||
FBackPriorityDefault: integer;
|
||||
FForePriorityDefault: integer;
|
||||
FFramePriorityDefault: integer;
|
||||
FStylePriorityDefault: Array [TFontStyle] of integer;
|
||||
|
||||
function GetBackPriorityStored: Boolean;
|
||||
function GetForePriorityStored: Boolean;
|
||||
function GetFramePriorityStored: Boolean;
|
||||
function GetStylePriorityStored(Index: TFontStyle): Boolean;
|
||||
|
||||
function GetStylePriority(Index: TFontStyle): integer;
|
||||
procedure SetBackPriority(AValue: integer);
|
||||
procedure SetForePriority(AValue: integer);
|
||||
@ -191,15 +198,16 @@ type
|
||||
procedure DoClear; override;
|
||||
procedure InitPriorities;
|
||||
public
|
||||
procedure InternalSaveDefaultValues; override;
|
||||
procedure SetAllPriorities(APriority: integer);
|
||||
property StylePriority[Index: TFontStyle]: integer read GetStylePriority write SetStylePriority;
|
||||
published
|
||||
property BackPriority: integer read FBackPriority write SetBackPriority;
|
||||
property ForePriority: integer read FForePriority write SetForePriority;
|
||||
property FramePriority: integer read FFramePriority write SetFramePriority;
|
||||
property BoldPriority: integer index fsBold read GetStylePriority write SetStylePriority default 0;
|
||||
property ItalicPriority: integer index fsItalic read GetStylePriority write SetStylePriority default 0;
|
||||
property UnderlinePriority: integer index fsUnderline read GetStylePriority write SetStylePriority default 0;
|
||||
property BackPriority: integer read FBackPriority write SetBackPriority stored GetBackPriorityStored;
|
||||
property ForePriority: integer read FForePriority write SetForePriority stored GetForePriorityStored;
|
||||
property FramePriority: integer read FFramePriority write SetFramePriority stored GetFramePriorityStored;
|
||||
property BoldPriority: integer index fsBold read GetStylePriority write SetStylePriority stored GetStylePriorityStored;
|
||||
property ItalicPriority: integer index fsItalic read GetStylePriority write SetStylePriority stored GetStylePriorityStored;
|
||||
property UnderlinePriority: integer index fsUnderline read GetStylePriority write SetStylePriority stored GetStylePriorityStored;
|
||||
end;
|
||||
|
||||
TSynHighlighterCapability = (
|
||||
@ -443,6 +451,26 @@ begin
|
||||
Result := FStylePriority[Index];
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributesModifier.GetBackPriorityStored: Boolean;
|
||||
begin
|
||||
Result := FBackPriority <> FBackPriorityDefault;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributesModifier.GetForePriorityStored: Boolean;
|
||||
begin
|
||||
Result := FForePriority <> FForePriorityDefault;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributesModifier.GetFramePriorityStored: Boolean;
|
||||
begin
|
||||
Result := FFramePriority <> FFramePriorityDefault;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributesModifier.GetStylePriorityStored(Index: TFontStyle): Boolean;
|
||||
begin
|
||||
Result := FStylePriority[Index] <> FStylePriorityDefault[Index];
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributesModifier.SetBackPriority(AValue: integer);
|
||||
begin
|
||||
if FBackPriority = AValue then Exit;
|
||||
@ -510,6 +538,18 @@ begin
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributesModifier.InternalSaveDefaultValues;
|
||||
var
|
||||
i: TFontStyle;
|
||||
begin
|
||||
inherited InternalSaveDefaultValues;
|
||||
FBackPriorityDefault := FBackPriority;
|
||||
FForePriorityDefault := FForePriority;
|
||||
FFramePriorityDefault := FFramePriority;
|
||||
for i := Low(TFontStyle) to High(TFontStyle) do
|
||||
FStylePriorityDefault[i] := FStylePriority[i];
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributesModifier.SetAllPriorities(APriority: integer);
|
||||
var
|
||||
i: TFontStyle;
|
||||
@ -1098,7 +1138,6 @@ begin
|
||||
if not (Src is TSynHighlighterAttributes) then exit;
|
||||
FName := TSynHighlighterAttributes(Src).FName;
|
||||
FStoredName:= TSynHighlighterAttributes(Src).FStoredName;
|
||||
FFeatures := TSynHighlighterAttributes(Src).FFeatures;
|
||||
Changed; {TODO: only if really changed}
|
||||
end;
|
||||
|
||||
@ -1117,7 +1156,6 @@ begin
|
||||
FFrameColorDefault := clNone;
|
||||
FFrameStyleDefault := slsSolid;
|
||||
FFrameEdgesDefault := sfeAround;
|
||||
FFeatures := [hafBackColor, hafForeColor, hafFrameColor, hafStyle, hafFrameStyle, hafFrameEdges];
|
||||
end;
|
||||
|
||||
constructor TSynHighlighterAttributes.Create;
|
||||
|
@ -228,24 +228,6 @@ type
|
||||
function GetModifiedStyle(aStyle: TFontStyles): TFontStyles; // deprecated;
|
||||
procedure ModifyColors(var AForeground, ABackground, AFrameColor: TColor;
|
||||
var AStyle: TFontStyles; var AFrameStyle: TSynLineStyle); deprecated;
|
||||
published
|
||||
property Background default clHighLight;
|
||||
property Foreground default clHighLightText;
|
||||
property FrameColor default clNone;
|
||||
property FrameStyle default slsSolid;
|
||||
property FrameEdges default sfeAround;
|
||||
// FStyle = [], FStyleMask = [] ==> no modification
|
||||
// FStyle = [fsBold], FStyleMask = [] ==> invert fsBold
|
||||
// FStyle = [], FStyleMask = [fsBold] ==> clear fsBold
|
||||
// FStyle = [fsBold], FStyleMask = [fsBold] ==> set fsBold
|
||||
property Style default [];
|
||||
property StyleMask default [];
|
||||
property BackPriority default 0;
|
||||
property ForePriority default 0;
|
||||
property FramePriority default 0;
|
||||
property BoldPriority default 0;
|
||||
property ItalicPriority default 0;
|
||||
property UnderlinePriority default 0;
|
||||
end;
|
||||
|
||||
{ TSynSelectedColorMergeResult }
|
||||
@ -922,6 +904,10 @@ begin
|
||||
inherited Init;
|
||||
Background := clHighLight;
|
||||
Foreground := clHighLightText;
|
||||
FrameColor := clNone;
|
||||
FrameStyle := slsSolid;
|
||||
FrameEdges := sfeAround;
|
||||
InternalSaveDefaultValues;
|
||||
end;
|
||||
|
||||
procedure TSynSelectedColor.SetFrameBoundsPhys(AStart, AEnd: Integer);
|
||||
|
@ -2263,7 +2263,6 @@ begin
|
||||
fCommentAttri.Style:= [fsItalic];
|
||||
AddAttribute(fCommentAttri);
|
||||
FIDEDirectiveAttri := TSynHighlighterAttributesModifier.Create(SYNS_AttrIDEDirective, SYNS_XML_AttrIDEDirective);
|
||||
FIDEDirectiveAttri.Features := FIDEDirectiveAttri.Features + [hafStyleMask];
|
||||
AddAttribute(FIDEDirectiveAttri);
|
||||
// FCurIDEDirectiveAttri, FCurCaseLabelAttri
|
||||
// They are not available through the "Attribute" property (not added via AddAttribute
|
||||
@ -2283,7 +2282,6 @@ begin
|
||||
fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol, SYNS_XML_AttrSymbol);
|
||||
AddAttribute(fSymbolAttri);
|
||||
FCaseLabelAttri := TSynHighlighterAttributesModifier.Create(SYNS_AttrCaseLabel, SYNS_XML_AttrCaseLabel);
|
||||
FCaseLabelAttri.Features := FCaseLabelAttri.Features + [hafStyleMask];
|
||||
AddAttribute(FCaseLabelAttri);
|
||||
FCurCaseLabelAttri := TSynSelectedColorMergeResult.Create(SYNS_AttrCaseLabel, SYNS_XML_AttrCaseLabel);
|
||||
fDirectiveAttri := TSynHighlighterAttributes.Create(SYNS_AttrDirective, SYNS_XML_AttrDirective);
|
||||
|
@ -103,6 +103,13 @@ type
|
||||
|
||||
TAhaGroupName = (agnDefault, agnLanguage, agnText, agnLine, agnGutter, agnTemplateMode, agnSyncronMode);
|
||||
|
||||
TColorSchemeAttributeFeature =
|
||||
( hafBackColor, hafForeColor, hafFrameColor,
|
||||
hafStyle, hafStyleMask,
|
||||
hafFrameStyle, hafFrameEdges
|
||||
);
|
||||
TColorSchemeAttributeFeatures = set of TColorSchemeAttributeFeature;
|
||||
|
||||
const
|
||||
SynEditPreviewIncludeOptions = [eoNoCaret, eoNoSelection];
|
||||
SynEditPreviewExcludeOptions = [eoDragDropEditing, eoDropFiles,
|
||||
@ -164,7 +171,7 @@ const
|
||||
{ ahaSpecialVisibleChars } agnText,
|
||||
{ ahaTopInfoHint } agnLine
|
||||
);
|
||||
ahaSupportedFeatures: array[TAdditionalHilightAttribute] of TSynHighlighterAttrFeatures =
|
||||
ahaSupportedFeatures: array[TAdditionalHilightAttribute] of TColorSchemeAttributeFeatures =
|
||||
(
|
||||
{ ahaNone } [hafBackColor, hafForeColor, hafFrameColor, hafFrameStyle, hafFrameEdges, hafStyle, hafStyleMask],
|
||||
{ ahaTextBlock } [hafBackColor, hafForeColor, hafFrameColor, hafFrameStyle, hafFrameEdges, hafStyle, hafStyleMask],
|
||||
@ -220,11 +227,14 @@ type
|
||||
|
||||
TColorSchemeAttribute = class(TSynHighlighterAttributesModifier)
|
||||
private
|
||||
FFeatures: TColorSchemeAttributeFeatures;
|
||||
FGroup: TAhaGroupName;
|
||||
FOwner: TColorSchemeLanguage;
|
||||
FUseSchemeGlobals: Boolean;
|
||||
function GetIsUsingSchemeGlobals: Boolean;
|
||||
function OldAdditionalAttributeName(NewAha: String): string;
|
||||
protected
|
||||
procedure Init; override;
|
||||
public
|
||||
constructor Create(ASchemeLang: TColorSchemeLanguage; attribName: string; aStoredName: String = '');
|
||||
procedure ApplyTo(aDest: TSynHighlighterAttributes; aDefault: TColorSchemeAttribute = nil);
|
||||
@ -239,6 +249,7 @@ type
|
||||
Defaults: TColorSchemeAttribute);
|
||||
property Group: TAhaGroupName read FGroup write FGroup;
|
||||
property IsUsingSchemeGlobals: Boolean read GetIsUsingSchemeGlobals;
|
||||
property Features: TColorSchemeAttributeFeatures read FFeatures write FFeatures;
|
||||
published
|
||||
property UseSchemeGlobals: Boolean read FUseSchemeGlobals write FUseSchemeGlobals;
|
||||
end;
|
||||
@ -5541,6 +5552,12 @@ begin
|
||||
else Result := ahaXmlNames[TAdditionalHilightAttribute(AttriIdx)];
|
||||
end;
|
||||
|
||||
procedure TColorSchemeAttribute.Init;
|
||||
begin
|
||||
inherited Init;
|
||||
FFeatures := [hafBackColor, hafForeColor, hafFrameColor, hafStyle, hafFrameStyle, hafFrameEdges];
|
||||
end;
|
||||
|
||||
function TColorSchemeAttribute.GetIsUsingSchemeGlobals: Boolean;
|
||||
begin
|
||||
Result := FUseSchemeGlobals and (GetSchemeGlobal <> nil);
|
||||
@ -5588,8 +5605,6 @@ begin
|
||||
aDest.StyleMask := [low(TFontStyle)..high(TFontStyle)];
|
||||
|
||||
if not (aDest is TSynSelectedColor) then begin
|
||||
aDest.Features := Src.Features;
|
||||
|
||||
if aDefault <> nil then begin
|
||||
if aDefault.IsUsingSchemeGlobals then
|
||||
aDefault := aDefault.GetSchemeGlobal;
|
||||
@ -5618,10 +5633,17 @@ end;
|
||||
procedure TColorSchemeAttribute.Assign(Src: TPersistent);
|
||||
begin
|
||||
inherited Assign(Src);
|
||||
|
||||
FFeatures := [hafBackColor, hafForeColor, hafFrameColor, hafStyle, hafFrameStyle, hafFrameEdges];
|
||||
if Src is TSynHighlighterAttributesModifier then
|
||||
FFeatures := FFeatures + [hafStyleMask];
|
||||
|
||||
if Src is TColorSchemeAttribute then begin
|
||||
FGroup := TColorSchemeAttribute(Src).FGroup;
|
||||
FUseSchemeGlobals := TColorSchemeAttribute(Src).FUseSchemeGlobals;
|
||||
FFeatures := TColorSchemeAttribute(Src).FFeatures;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
function TColorSchemeAttribute.Equals(Other: TColorSchemeAttribute): Boolean;
|
||||
|
Loading…
Reference in New Issue
Block a user