mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 19:20:41 +02:00
SynEdit, highlight: fix inverting styles
git-svn-id: trunk@27710 -
This commit is contained in:
parent
276625f65d
commit
ae56cb323a
@ -3572,7 +3572,10 @@ var
|
|||||||
FPaintLineColor.FrameStyle := attr.FrameStyle;
|
FPaintLineColor.FrameStyle := attr.FrameStyle;
|
||||||
FPaintLineColor.FrameEdges := attr.FrameEdges;
|
FPaintLineColor.FrameEdges := attr.FrameEdges;
|
||||||
FPaintLineColor.Style := attr.Style;
|
FPaintLineColor.Style := attr.Style;
|
||||||
FPaintLineColor.StyleMask := attr.StyleMask;
|
// TSynSelectedColor.Style and StyleMask describe how to modify a style,
|
||||||
|
// but FPaintLineColor contains an actual style
|
||||||
|
FPaintLineColor.MergeFinalStyle := True;
|
||||||
|
FPaintLineColor.StyleMask := [];
|
||||||
if FPaintLineColor.Background = clNone then
|
if FPaintLineColor.Background = clNone then
|
||||||
FPaintLineColor.Background := colEditorBG;
|
FPaintLineColor.Background := colEditorBG;
|
||||||
if FPaintLineColor.Foreground = clNone then
|
if FPaintLineColor.Foreground = clNone then
|
||||||
|
@ -232,6 +232,10 @@ type
|
|||||||
procedure SetStyleMask(const AValue : TFontStyles);
|
procedure SetStyleMask(const AValue : TFontStyles);
|
||||||
procedure DoChange;
|
procedure DoChange;
|
||||||
public
|
public
|
||||||
|
// TSynSelectedColor.Style and StyleMask describe how to modify a style,
|
||||||
|
// but PaintLines creates an instance that contains an actual style (without mask)
|
||||||
|
// Todo: always start with actual style
|
||||||
|
MergeFinalStyle: Boolean;
|
||||||
procedure Merge(Other: TSynSelectedColor; LeftCol, RightCol: Integer);
|
procedure Merge(Other: TSynSelectedColor; LeftCol, RightCol: Integer);
|
||||||
procedure MergeFrames(Other: TSynSelectedColor; LeftCol, RightCol: Integer);
|
procedure MergeFrames(Other: TSynSelectedColor; LeftCol, RightCol: Integer);
|
||||||
property FrameSideColors[Side: TSynFrameSide]: TColor read GetFrameSideColors;
|
property FrameSideColors[Side: TSynFrameSide]: TColor read GetFrameSideColors;
|
||||||
@ -255,6 +259,10 @@ type
|
|||||||
property FrameColor: TColor read FFrameColor write SetFrameColor default clNone;
|
property FrameColor: TColor read FFrameColor write SetFrameColor default clNone;
|
||||||
property FrameStyle: TSynLineStyle read FFrameStyle write SetFrameStyle default slsSolid;
|
property FrameStyle: TSynLineStyle read FFrameStyle write SetFrameStyle default slsSolid;
|
||||||
property FrameEdges: TSynFrameEdges read FFrameEdges write SetFrameEdges default sfeAround;
|
property FrameEdges: TSynFrameEdges read FFrameEdges write SetFrameEdges default sfeAround;
|
||||||
|
// FStyle = [], FStyleMask = [] ==> no modification
|
||||||
|
// FStyle = [fsBold], FStyleMask = [] ==> invert fsBold
|
||||||
|
// FStyle = [], FStyleMask = [fsBold] ==> clear fsBold
|
||||||
|
// FStyle = [fsBold], FStyleMask = [fsBold] ==> set fsBold
|
||||||
property Style: TFontStyles read FStyle write SetStyle default [];
|
property Style: TFontStyles read FStyle write SetStyle default [];
|
||||||
property StyleMask: TFontStyles read fStyleMask write SetStyleMask default [];
|
property StyleMask: TFontStyles read fStyleMask write SetStyleMask default [];
|
||||||
end;
|
end;
|
||||||
@ -477,6 +485,7 @@ end;
|
|||||||
constructor TSynSelectedColor.Create;
|
constructor TSynSelectedColor.Create;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
|
MergeFinalStyle := False;
|
||||||
Clear;
|
Clear;
|
||||||
FBG := clHighLight;
|
FBG := clHighLight;
|
||||||
FFG := clHighLightText;
|
FFG := clHighLightText;
|
||||||
@ -599,14 +608,35 @@ end;
|
|||||||
|
|
||||||
procedure TSynSelectedColor.Merge(Other: TSynSelectedColor; LeftCol, RightCol: Integer);
|
procedure TSynSelectedColor.Merge(Other: TSynSelectedColor; LeftCol, RightCol: Integer);
|
||||||
var
|
var
|
||||||
sMask: TFontStyles;
|
sSet, sClr, sInv, sInvInv, sKeep: TFontStyles;
|
||||||
begin
|
begin
|
||||||
if Other.Background <> clNone then Background := Other.Background;
|
if Other.Background <> clNone then Background := Other.Background;
|
||||||
if Other.Foreground <> clNone then Foreground := Other.Foreground;
|
if Other.Foreground <> clNone then Foreground := Other.Foreground;
|
||||||
if Other.FrameColor <> clNone then MergeFrames(Other, LeftCol, RightCol);
|
if Other.FrameColor <> clNone then MergeFrames(Other, LeftCol, RightCol);
|
||||||
sMask := Other.StyleMask + (fsNot(Other.StyleMask) * Other.Style); // Styles to be taken from Other
|
sSet := Other.Style * Other.StyleMask;
|
||||||
Style:= (Style * fsNot(sMask)) + (Other.Style * sMask);
|
sClr := fsNot(Other.Style) * Other.StyleMask;
|
||||||
StyleMask:= (StyleMask * fsNot(sMask)) + (Other.StyleMask * sMask);
|
sInv := Other.Style * fsNot(Other.StyleMask);
|
||||||
|
|
||||||
|
if MergeFinalStyle then begin
|
||||||
|
Style := fsXor(Style, sInv) + sSet - sClr;
|
||||||
|
end else begin
|
||||||
|
sKeep := fsNot(Other.Style) * fsNot(Other.StyleMask);
|
||||||
|
sInvInv := sInv * (Style * fsNot(StyleMask)); // invert * invert = not modified
|
||||||
|
sInv := sInv - sInvInv;
|
||||||
|
sSet := sSet + sInv * (fsnot(Style) * StyleMask); // currently not set
|
||||||
|
sClr := sClr + sInv * (Style * StyleMask); // currently set
|
||||||
|
sInv := sInv - StyleMask; // now SInv only inverts currently "not modifying"
|
||||||
|
|
||||||
|
Style := (Style * sKeep) + sSet - sClr - sInvInv + sInv;
|
||||||
|
StyleMask := (StyleMask * sKeep) + sSet + sClr - sInvInv - sInv;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
//sMask := Other.StyleMask // Styles to be taken from Other
|
||||||
|
// + (fsNot(Other.StyleMask) * Other.Style); // Styles to be inverted
|
||||||
|
//Style := (Style * fsNot(sMask)) // Styles that are neither taken, nor inverted
|
||||||
|
// + (Other.Style * sMask); // Styles that are either inverted or set
|
||||||
|
//StyleMask := (StyleMask * fsNot(sMask)) + (Other.StyleMask * sMask);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynSelectedColor.MergeFrames(Other: TSynSelectedColor; LeftCol, RightCol: Integer);
|
procedure TSynSelectedColor.MergeFrames(Other: TSynSelectedColor; LeftCol, RightCol: Integer);
|
||||||
|
Loading…
Reference in New Issue
Block a user