mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 18:20:30 +02:00
SynEdit: Clean up AssignColors
This commit is contained in:
parent
6690e16115
commit
f576fc86c0
@ -106,10 +106,12 @@ type
|
||||
procedure DoChanged; virtual;
|
||||
procedure Init; virtual;
|
||||
procedure DoClear; virtual;
|
||||
procedure AssignColorsFrom(ASource: TLazCustomEditTextAttribute); virtual;
|
||||
procedure AssignFrom(ASource: TLazCustomEditTextAttribute); virtual;
|
||||
public
|
||||
constructor Create;
|
||||
procedure Assign(ASource: TPersistent); override;
|
||||
procedure AssignColors(ASource: TLazCustomEditTextAttribute);
|
||||
procedure Clear;
|
||||
procedure BeginUpdate;
|
||||
procedure EndUpdate;
|
||||
@ -186,16 +188,17 @@ type
|
||||
function GetStyleStored: Boolean;
|
||||
function GetStylePriorityStored(AnIndex: TFontStyle): Boolean;
|
||||
|
||||
procedure SetCaption(ACaption: String);
|
||||
procedure DoChanged; override;
|
||||
procedure Init; override;
|
||||
procedure DoClearThis; inline;
|
||||
procedure DoClear; override;
|
||||
procedure AssignColorsFrom(ASource: TLazCustomEditTextAttribute); override;
|
||||
procedure AssignFrom(ASource: TLazCustomEditTextAttribute); override;
|
||||
public
|
||||
constructor Create;
|
||||
constructor Create(ACaption: string; AStoredName: String = '');
|
||||
constructor Create(ACaption: PString; AStoredName: String = ''); // e.g. pointer to resourcestring. (Must be global var/const)
|
||||
procedure SetCaption(ACaption: String);
|
||||
|
||||
procedure InternalSaveDefaultValues; virtual;
|
||||
procedure SetAllPriorities(APriority: integer); override;
|
||||
@ -244,7 +247,7 @@ type
|
||||
|
||||
procedure DoClearThis; reintroduce; inline;
|
||||
procedure DoClear; override;
|
||||
procedure AssignFrom(ASource: TLazCustomEditTextAttribute); override;
|
||||
procedure AssignColorsFrom(ASource: TLazCustomEditTextAttribute); override;
|
||||
public
|
||||
function IsEnabled: boolean; override;
|
||||
procedure InternalSaveDefaultValues; override;
|
||||
@ -409,13 +412,16 @@ begin
|
||||
FEndX.Offset := 0;
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.AssignFrom(ASource: TLazCustomEditTextAttribute);
|
||||
procedure TLazCustomEditTextAttribute.AssignColorsFrom(ASource: TLazCustomEditTextAttribute);
|
||||
begin
|
||||
FColors := ASource.FColors;
|
||||
FFrameEdges := ASource.FFrameEdges;
|
||||
FFrameStyle := ASource.FFrameStyle;
|
||||
FStyle := ASource.FStyle;
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.AssignFrom(ASource: TLazCustomEditTextAttribute);
|
||||
begin
|
||||
FStartX := ASource.FStartX;
|
||||
FEndX := ASource.FEndX;
|
||||
end;
|
||||
@ -431,6 +437,7 @@ var
|
||||
begin
|
||||
if ASource is TLazCustomEditTextAttribute then begin
|
||||
BeginUpdate;
|
||||
AssignColorsFrom(Src);
|
||||
AssignFrom(Src);
|
||||
Changed;
|
||||
EndUpdate;
|
||||
@ -439,6 +446,14 @@ begin
|
||||
inherited Assign(ASource);
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.AssignColors(ASource: TLazCustomEditTextAttribute);
|
||||
begin
|
||||
BeginUpdate;
|
||||
AssignColorsFrom(ASource);
|
||||
Changed;
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.Clear;
|
||||
begin
|
||||
BeginUpdate;
|
||||
@ -600,6 +615,19 @@ begin
|
||||
DoClearThis;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttribute.AssignColorsFrom(ASource: TLazCustomEditTextAttribute);
|
||||
var
|
||||
Source: TLazEditTextAttribute absolute ASource;
|
||||
begin
|
||||
inherited AssignColorsFrom(ASource);
|
||||
if ASource is TLazEditTextAttribute then begin
|
||||
FPriority := Source.FPriority;
|
||||
FStylePriority := Source.FStylePriority;
|
||||
end
|
||||
else
|
||||
DoClearThis;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttribute.AssignFrom(ASource: TLazCustomEditTextAttribute);
|
||||
var
|
||||
Source: TLazEditTextAttribute absolute ASource;
|
||||
@ -609,11 +637,7 @@ begin
|
||||
FStoredName := Source.FStoredName;
|
||||
FFixedCaption := Source.FFixedCaption;
|
||||
FCaption := Source.FCaption;
|
||||
FPriority := Source.FPriority;
|
||||
FStylePriority := Source.FStylePriority;
|
||||
end
|
||||
else
|
||||
DoClearThis;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TLazEditTextAttribute.Create;
|
||||
@ -713,11 +737,11 @@ begin
|
||||
DoClearThis;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttributeModifier.AssignFrom(ASource: TLazCustomEditTextAttribute);
|
||||
procedure TLazEditTextAttributeModifier.AssignColorsFrom(ASource: TLazCustomEditTextAttribute);
|
||||
var
|
||||
Source: TLazEditTextAttributeModifier absolute ASource;
|
||||
begin
|
||||
inherited AssignFrom(ASource);
|
||||
inherited AssignColorsFrom(ASource);
|
||||
if ASource is TLazEditTextAttributeModifier then begin
|
||||
FAlpha := Source.FAlpha;
|
||||
FStyleMask := Source.FStyleMask;
|
||||
|
@ -80,12 +80,9 @@ type
|
||||
private
|
||||
function GetConstName: string;
|
||||
function GetStyleFromInt: integer;
|
||||
procedure SetConstName(AValue: string);
|
||||
procedure SetStyleFromInt(const Value: integer);
|
||||
function GetStyleMaskFromInt : integer;
|
||||
procedure SetStyleMaskFromInt(const Value : integer);
|
||||
protected
|
||||
property ConstName: string read GetConstName write SetConstName; // internal accessor
|
||||
public
|
||||
function LoadFromBorlandRegistry(rootKey: HKEY; attrKey, attrName: string;
|
||||
oldStyle: boolean): boolean;
|
||||
@ -486,7 +483,7 @@ var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 0 to Count - 1 do begin
|
||||
Attribs[i].ConstName := Format(FBaseName, [i]);
|
||||
Attribs[i].SetCaption(Format(FBaseName, [i]));
|
||||
Attribs[i].StoredName := Format(FBaseStoredName, [i]);
|
||||
end;
|
||||
end;
|
||||
@ -878,11 +875,6 @@ begin
|
||||
if fsStrikeout in Style then Result:= Result + 8;
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributesHelper.SetConstName(AValue: string);
|
||||
begin
|
||||
SetCaption(AValue);
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributesHelper.SetStyleFromInt(const Value: integer);
|
||||
begin
|
||||
if Value and $1 = 0 then Style:= [] else Style:= [fsBold];
|
||||
|
@ -343,13 +343,13 @@ type
|
||||
procedure ApplyTo(aDest: TObject);
|
||||
protected
|
||||
procedure Init; override;
|
||||
procedure AssignColorsFrom(ASource: TLazCustomEditTextAttribute); override;
|
||||
public
|
||||
constructor Create(ASchemeLang: TColorSchemeLanguage; attribName: PString;
|
||||
const aStoredName: String = '');
|
||||
function IsEnabled: boolean; override;
|
||||
procedure ApplyTo(aDest: TSynHighlighterAttributes; aDefault: TColorSchemeAttribute = nil);
|
||||
procedure Assign(Src: TPersistent); override;
|
||||
procedure AssignColors(Src: TPersistent);
|
||||
function Equals(Other: TColorSchemeAttribute): Boolean; reintroduce;
|
||||
function GetStoredValuesForAttrib: TColorSchemeAttribute; // The IDE default colors from the resources
|
||||
function GetSchemeGlobal: TColorSchemeAttribute;
|
||||
@ -7120,6 +7120,19 @@ begin
|
||||
FMarkupFoldLineAlpha := 0;
|
||||
end;
|
||||
|
||||
procedure TColorSchemeAttribute.AssignColorsFrom(ASource: TLazCustomEditTextAttribute);
|
||||
var
|
||||
SrcAttr: TColorSchemeAttribute absolute ASource;
|
||||
begin
|
||||
inherited AssignColorsFrom(ASource);
|
||||
if ASource is TColorSchemeAttribute then begin
|
||||
FUseSchemeGlobals := SrcAttr.FUseSchemeGlobals;
|
||||
FMarkupFoldLineColor := SrcAttr.FMarkupFoldLineColor;
|
||||
FMarkupFoldLineStyle := SrcAttr.FMarkupFoldLineStyle;
|
||||
FMarkupFoldLineAlpha := SrcAttr.FMarkupFoldLineAlpha;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TColorSchemeAttribute.GetIsUsingSchemeGlobals: Boolean;
|
||||
begin
|
||||
Result := FUseSchemeGlobals and (GetSchemeGlobal <> nil);
|
||||
@ -7252,28 +7265,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TColorSchemeAttribute.AssignColors(Src: TPersistent);
|
||||
var
|
||||
SrcAttr: TColorSchemeAttribute;
|
||||
sn, n: String;
|
||||
begin
|
||||
BeginUpdate;
|
||||
sn := StoredName;
|
||||
n := ConstName;
|
||||
inherited Assign(Src);
|
||||
StoredName := sn;
|
||||
ConstName := n;
|
||||
|
||||
if Src is TColorSchemeAttribute then begin
|
||||
SrcAttr := TColorSchemeAttribute(Src);
|
||||
FUseSchemeGlobals := SrcAttr.FUseSchemeGlobals;
|
||||
FMarkupFoldLineColor := SrcAttr.FMarkupFoldLineColor;
|
||||
FMarkupFoldLineStyle := SrcAttr.FMarkupFoldLineStyle;
|
||||
FMarkupFoldLineAlpha := SrcAttr.FMarkupFoldLineAlpha;
|
||||
end;
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
function TColorSchemeAttribute.Equals(Other: TColorSchemeAttribute): Boolean;
|
||||
begin
|
||||
Result := (FGroup = Other.FGroup) and
|
||||
|
@ -384,7 +384,7 @@ type
|
||||
procedure DoWordsChanged(Sender: TObject);
|
||||
procedure SetCustomWordTokenKind(AValue: TtkTokenKindEx);
|
||||
protected
|
||||
procedure AssignFrom(Src: TLazCustomEditTextAttribute); override;
|
||||
procedure AssignColorsFrom(ASource: TLazCustomEditTextAttribute); override;
|
||||
procedure DoClear; override;
|
||||
procedure Init; override;
|
||||
public
|
||||
@ -2168,12 +2168,13 @@ begin
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterLazCustomPasAttribute.AssignFrom(Src: TLazCustomEditTextAttribute);
|
||||
procedure TSynHighlighterLazCustomPasAttribute.AssignColorsFrom(
|
||||
ASource: TLazCustomEditTextAttribute);
|
||||
begin
|
||||
inherited AssignFrom(Src);
|
||||
if Src is TSynHighlighterLazCustomPasAttribute then begin
|
||||
FCustomWords.Assign(TSynHighlighterLazCustomPasAttribute(Src).FCustomWords);
|
||||
FCustomWordTokenKind := TSynHighlighterLazCustomPasAttribute(Src).FCustomWordTokenKind;
|
||||
inherited AssignColorsFrom(ASource);
|
||||
if ASource is TSynHighlighterLazCustomPasAttribute then begin
|
||||
FCustomWords.Assign(TSynHighlighterLazCustomPasAttribute(ASource).FCustomWords);
|
||||
FCustomWordTokenKind := TSynHighlighterLazCustomPasAttribute(ASource).FCustomWordTokenKind;
|
||||
end
|
||||
else begin
|
||||
FCustomWords.Clear;
|
||||
|
Loading…
Reference in New Issue
Block a user