mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 13:19:20 +02:00
SynEdit: Token Attributes (TSynSelectedColor), move StartX and EndX to base class
This commit is contained in:
parent
9b0070e05e
commit
5abe12a280
@ -25,6 +25,14 @@ uses
|
|||||||
Classes, SysUtils, Graphics;
|
Classes, SysUtils, Graphics;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
TLazEditDisplayTokenBound = record
|
||||||
|
Physical: Integer; // 1 based - May be in middle of char
|
||||||
|
Logical: Integer; // 1 based
|
||||||
|
Offset: Integer; // default 0. MultiWidth (e.g. Tab), if token starts in the middle of char
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//TLazTextAttributeFeature = (
|
//TLazTextAttributeFeature = (
|
||||||
// lafForeColor, lafBackColor,
|
// lafForeColor, lafBackColor,
|
||||||
// lafFrameColor,
|
// lafFrameColor,
|
||||||
@ -60,6 +68,9 @@ type
|
|||||||
protected type
|
protected type
|
||||||
TLazTextAttributeColor = (lacForeColor, lacBackColor, lacFrameColor);
|
TLazTextAttributeColor = (lacForeColor, lacBackColor, lacFrameColor);
|
||||||
private
|
private
|
||||||
|
// 0 or -1 start/end before/after line // 1 first char
|
||||||
|
FStartX, FEndX: TLazEditDisplayTokenBound;
|
||||||
|
|
||||||
FColors: array[TLazTextAttributeColor] of TColor;
|
FColors: array[TLazTextAttributeColor] of TColor;
|
||||||
FFrameEdges: TLazTextAttrFrameEdges;
|
FFrameEdges: TLazTextAttrFrameEdges;
|
||||||
FFrameStyle: TLazTextAttrLineStyle;
|
FFrameStyle: TLazTextAttrLineStyle;
|
||||||
@ -103,6 +114,11 @@ type
|
|||||||
procedure EndUpdate;
|
procedure EndUpdate;
|
||||||
function IsEnabled: boolean; virtual;
|
function IsEnabled: boolean; virtual;
|
||||||
procedure SetAllPriorities(APriority: integer); virtual;
|
procedure SetAllPriorities(APriority: integer); virtual;
|
||||||
|
// boundaries of the frame
|
||||||
|
procedure SetFrameBoundsPhys(AStart, AEnd: Integer);
|
||||||
|
procedure SetFrameBoundsLog(AStart, AEnd: Integer; AStartOffs: Integer = 0; AEndOffs: Integer = 0);
|
||||||
|
property StartX: TLazEditDisplayTokenBound read FStartX write FStartX;
|
||||||
|
property EndX: TLazEditDisplayTokenBound read FEndX write FEndX;
|
||||||
public
|
public
|
||||||
property Foreground: TColor index lacForeColor read GetColor write SetColor;
|
property Foreground: TColor index lacForeColor read GetColor write SetColor;
|
||||||
property Background: TColor index lacBackColor read GetColor write SetColor;
|
property Background: TColor index lacBackColor read GetColor write SetColor;
|
||||||
@ -383,6 +399,13 @@ begin
|
|||||||
FFrameEdges := sfeAround;
|
FFrameEdges := sfeAround;
|
||||||
FFrameStyle := slsSolid;
|
FFrameStyle := slsSolid;
|
||||||
FStyle := [];
|
FStyle := [];
|
||||||
|
|
||||||
|
FStartX.Physical := -1;
|
||||||
|
FEndX.Physical := -1;
|
||||||
|
FStartX.Logical := -1;
|
||||||
|
FEndX.Logical := -1;
|
||||||
|
FStartX.Offset := 0;
|
||||||
|
FEndX.Offset := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazCustomEditTextAttribute.AssignFrom(ASource: TLazCustomEditTextAttribute);
|
procedure TLazCustomEditTextAttribute.AssignFrom(ASource: TLazCustomEditTextAttribute);
|
||||||
@ -391,6 +414,9 @@ begin
|
|||||||
FFrameEdges := ASource.FFrameEdges;
|
FFrameEdges := ASource.FFrameEdges;
|
||||||
FFrameStyle := ASource.FFrameStyle;
|
FFrameStyle := ASource.FFrameStyle;
|
||||||
FStyle := ASource.FStyle;
|
FStyle := ASource.FStyle;
|
||||||
|
|
||||||
|
FStartX := ASource.FStartX;
|
||||||
|
FEndX := ASource.FEndX;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TLazCustomEditTextAttribute.Create;
|
constructor TLazCustomEditTextAttribute.Create;
|
||||||
@ -453,6 +479,27 @@ begin
|
|||||||
//raise exception.Create('abstract');
|
//raise exception.Create('abstract');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLazCustomEditTextAttribute.SetFrameBoundsPhys(AStart, AEnd: Integer);
|
||||||
|
begin
|
||||||
|
FStartX.Physical := AStart;
|
||||||
|
FEndX.Physical := AEnd;
|
||||||
|
FStartX.Logical := -1;
|
||||||
|
FEndX.Logical := -1;
|
||||||
|
FStartX.Offset := 0;
|
||||||
|
FEndX.Offset := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLazCustomEditTextAttribute.SetFrameBoundsLog(AStart, AEnd: Integer;
|
||||||
|
AStartOffs: Integer; AEndOffs: Integer);
|
||||||
|
begin
|
||||||
|
FStartX.Physical := -1;
|
||||||
|
FEndX.Physical := -1;
|
||||||
|
FStartX.Logical := AStart;
|
||||||
|
FEndX.Logical := AEnd;
|
||||||
|
FStartX.Offset := AStartOffs;
|
||||||
|
FEndX.Offset := AEndOffs;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TLazEditTextAttribute }
|
{ TLazEditTextAttribute }
|
||||||
|
|
||||||
function TLazEditTextAttribute.GetPriority(AnIndex: TLazTextAttributeColor): integer;
|
function TLazEditTextAttribute.GetPriority(AnIndex: TLazTextAttributeColor): integer;
|
||||||
|
@ -715,7 +715,7 @@ begin
|
|||||||
inherited Create;
|
inherited Create;
|
||||||
FFoldView := AFoldView;
|
FFoldView := AFoldView;
|
||||||
FTokenAttr := TSynHighlighterAttributesModifier.Create(nil);
|
FTokenAttr := TSynHighlighterAttributesModifier.Create(nil);
|
||||||
FMarkupLine := TSynSelectedColorMergeResult.Create(nil);
|
FMarkupLine := TSynSelectedColorMergeResult.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TLazSynDisplayFold.Destroy;
|
destructor TLazSynDisplayFold.Destroy;
|
||||||
|
@ -471,28 +471,13 @@ type
|
|||||||
|
|
||||||
TSynObjectListItemClass = class of TSynObjectListItem;
|
TSynObjectListItemClass = class of TSynObjectListItem;
|
||||||
|
|
||||||
TLazSynDisplayTokenBound = record
|
TLazSynDisplayTokenBound = TLazEditDisplayTokenBound;
|
||||||
Physical: Integer; // 1 based - May be in middle of char
|
|
||||||
Logical: Integer; // 1 based
|
|
||||||
Offset: Integer; // default 0. MultiWidth (e.g. Tab), if token starts in the middle of char
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TSynSelectedColor }
|
{ TSynSelectedColor }
|
||||||
|
|
||||||
TSynSelectedColor = class(TSynHighlighterAttributesModifier)
|
TSynSelectedColor = class(TSynHighlighterAttributesModifier)
|
||||||
private
|
|
||||||
// 0 or -1 start/end before/after line // 1 first char
|
|
||||||
FStartX, FEndX: TLazSynDisplayTokenBound;
|
|
||||||
protected
|
protected
|
||||||
procedure DoClear; override;
|
|
||||||
procedure AssignFrom(Src: TLazCustomEditTextAttribute); override;
|
|
||||||
procedure Init; override;
|
procedure Init; override;
|
||||||
public
|
|
||||||
// boundaries of the frame
|
|
||||||
procedure SetFrameBoundsPhys(AStart, AEnd: Integer);
|
|
||||||
procedure SetFrameBoundsLog(AStart, AEnd: Integer; AStartOffs: Integer = 0; AEndOffs: Integer = 0);
|
|
||||||
property StartX: TLazSynDisplayTokenBound read FStartX write FStartX;
|
|
||||||
property EndX: TLazSynDisplayTokenBound read FEndX write FEndX;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TSynSelectedColorAlphaEntry = record
|
TSynSelectedColorAlphaEntry = record
|
||||||
@ -1068,8 +1053,8 @@ begin
|
|||||||
|
|
||||||
if (FCurrentStartX.Logical >= 0) or (FCurrentStartX.Physical >= 0) then
|
if (FCurrentStartX.Logical >= 0) or (FCurrentStartX.Physical >= 0) then
|
||||||
case Side of
|
case Side of
|
||||||
bsLeft: if not IsMatching(FCurrentStartX, FStartX) then exit(clNone);
|
bsLeft: if not IsMatching(FCurrentStartX, StartX) then exit(clNone);
|
||||||
bsRight: if not IsMatching(FCurrentEndX, FEndX) then exit(clNone);
|
bsRight: if not IsMatching(FCurrentEndX, EndX) then exit(clNone);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (Side in SynFrameEdgeToSides[FrameEdges])
|
if (Side in SynFrameEdgeToSides[FrameEdges])
|
||||||
@ -1095,8 +1080,8 @@ begin
|
|||||||
|
|
||||||
if (FCurrentStartX.Logical >= 0) or (FCurrentStartX.Physical >= 0) then
|
if (FCurrentStartX.Logical >= 0) or (FCurrentStartX.Physical >= 0) then
|
||||||
case Side of
|
case Side of
|
||||||
bsLeft: if not IsMatching(FCurrentStartX, FStartX) then exit(0);
|
bsLeft: if not IsMatching(FCurrentStartX, StartX) then exit(0);
|
||||||
bsRight: if not IsMatching(FCurrentEndX, FEndX) then exit(0);
|
bsRight: if not IsMatching(FCurrentEndX, EndX) then exit(0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (Side in SynFrameEdgeToSides[FrameEdges])
|
if (Side in SynFrameEdgeToSides[FrameEdges])
|
||||||
@ -1118,7 +1103,7 @@ procedure TSynSelectedColorMergeResult.SetCurrentEndX(AValue: TLazSynDisplayToke
|
|||||||
begin
|
begin
|
||||||
//if FCurrentEndX = AValue then Exit;
|
//if FCurrentEndX = AValue then Exit;
|
||||||
FCurrentEndX := AValue;
|
FCurrentEndX := AValue;
|
||||||
if not IsMatching(FCurrentEndX, FEndX) then begin
|
if not IsMatching(FCurrentEndX, EndX) then begin
|
||||||
FFrameSideColors[bsRight] := clNone;
|
FFrameSideColors[bsRight] := clNone;
|
||||||
FMergeInfos[sscFrameRight].BaseColor := clNone;
|
FMergeInfos[sscFrameRight].BaseColor := clNone;
|
||||||
FMergeInfos[sscFrameRight].AlphaCount := 0;
|
FMergeInfos[sscFrameRight].AlphaCount := 0;
|
||||||
@ -1129,7 +1114,7 @@ procedure TSynSelectedColorMergeResult.SetCurrentStartX(AValue: TLazSynDisplayTo
|
|||||||
begin
|
begin
|
||||||
//if FCurrentStartX = AValue then Exit;
|
//if FCurrentStartX = AValue then Exit;
|
||||||
FCurrentStartX := AValue;
|
FCurrentStartX := AValue;
|
||||||
if not IsMatching(FCurrentStartX, FStartX) then begin
|
if not IsMatching(FCurrentStartX, StartX) then begin
|
||||||
FFrameSideColors[bsLeft] := clNone;
|
FFrameSideColors[bsLeft] := clNone;
|
||||||
FMergeInfos[sscFrameLeft].BaseColor := clNone;
|
FMergeInfos[sscFrameLeft].BaseColor := clNone;
|
||||||
FMergeInfos[sscFrameLeft].AlphaCount := 0;
|
FMergeInfos[sscFrameLeft].AlphaCount := 0;
|
||||||
@ -1384,7 +1369,7 @@ end;
|
|||||||
|
|
||||||
procedure TSynSelectedColorMergeResult.Merge(Other: TSynHighlighterAttributesModifier);
|
procedure TSynSelectedColorMergeResult.Merge(Other: TSynHighlighterAttributesModifier);
|
||||||
begin
|
begin
|
||||||
Merge(Other, FStartX, FEndX); // always merge frame
|
Merge(Other, StartX, EndX); // always merge frame
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynSelectedColorMergeResult.Merge(Other: TSynHighlighterAttributesModifier; LeftCol,
|
procedure TSynSelectedColorMergeResult.Merge(Other: TSynHighlighterAttributesModifier; LeftCol,
|
||||||
@ -1460,9 +1445,9 @@ procedure TSynSelectedColorMergeResult.MergeFrames(Other: TSynHighlighterAttribu
|
|||||||
// FFrameSidePriority[ASide] := ASrc.FramePriority;
|
// FFrameSidePriority[ASide] := ASrc.FramePriority;
|
||||||
// FFrameSideOrigin[ASide] := ASrc.FrameEdges;
|
// FFrameSideOrigin[ASide] := ASrc.FrameEdges;
|
||||||
// if ASide = bsLeft then
|
// if ASide = bsLeft then
|
||||||
// FStartX := LeftCol; // LeftCol has Phys and log ; // ASrc.FStartX;
|
// StartX := LeftCol; // LeftCol has Phys and log ; // ASrc.StartX;
|
||||||
// if ASide = bsRight then
|
// if ASide = bsRight then
|
||||||
// FEndX := RightCol; // ASrc.FEndX;
|
// EndX := RightCol; // ASrc.EndX;
|
||||||
//end;
|
//end;
|
||||||
|
|
||||||
procedure SetSide(AInfoSide: TSynSelectedColorEnum; ASide: TLazSynBorderSide;
|
procedure SetSide(AInfoSide: TSynSelectedColorEnum; ASide: TLazSynBorderSide;
|
||||||
@ -1527,17 +1512,6 @@ end;
|
|||||||
|
|
||||||
{ TSynSelectedColor }
|
{ TSynSelectedColor }
|
||||||
|
|
||||||
procedure TSynSelectedColor.AssignFrom(Src: TLazCustomEditTextAttribute);
|
|
||||||
begin
|
|
||||||
inherited AssignFrom(Src);
|
|
||||||
if not (Src is TSynSelectedColor) then exit;
|
|
||||||
|
|
||||||
FStartX := TSynSelectedColor(Src).FStartX;
|
|
||||||
FEndX := TSynSelectedColor(Src).FEndX;
|
|
||||||
|
|
||||||
Changed; {TODO: only if really changed}
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSynSelectedColor.Init;
|
procedure TSynSelectedColor.Init;
|
||||||
begin
|
begin
|
||||||
inherited Init;
|
inherited Init;
|
||||||
@ -1549,38 +1523,6 @@ begin
|
|||||||
InternalSaveDefaultValues;
|
InternalSaveDefaultValues;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynSelectedColor.SetFrameBoundsPhys(AStart, AEnd: Integer);
|
|
||||||
begin
|
|
||||||
FStartX.Physical := AStart;
|
|
||||||
FEndX.Physical := AEnd;
|
|
||||||
FStartX.Logical := -1;
|
|
||||||
FEndX.Logical := -1;
|
|
||||||
FStartX.Offset := 0;
|
|
||||||
FEndX.Offset := 0;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSynSelectedColor.SetFrameBoundsLog(AStart, AEnd: Integer; AStartOffs: Integer;
|
|
||||||
AEndOffs: Integer);
|
|
||||||
begin
|
|
||||||
FStartX.Physical := -1;
|
|
||||||
FEndX.Physical := -1;
|
|
||||||
FStartX.Logical := AStart;
|
|
||||||
FEndX.Logical := AEnd;
|
|
||||||
FStartX.Offset := AStartOffs;
|
|
||||||
FEndX.Offset := AEndOffs;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSynSelectedColor.DoClear;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
FStartX.Physical := -1;
|
|
||||||
FEndX.Physical := -1;
|
|
||||||
FStartX.Logical := -1;
|
|
||||||
FEndX.Logical := -1;
|
|
||||||
FStartX.Offset := 0;
|
|
||||||
FEndX.Offset := 0;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TLazSynSurface }
|
{ TLazSynSurface }
|
||||||
|
|
||||||
function TLazSynSurface.GetHandle: HWND;
|
function TLazSynSurface.GetHandle: HWND;
|
||||||
|
Loading…
Reference in New Issue
Block a user