mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 14:59:30 +02:00
SynEdit: rewrite part of the Highlighter-attribute
This commit is contained in:
parent
c6957da9f2
commit
1bb56e053b
@ -44,8 +44,15 @@ Additional licenses may be granted in each individual file. See the headers in e
|
||||
<Filename Value="lazedithighlighterutils.pas"/>
|
||||
<UnitName Value="lazedithighlighterutils"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="lazedittextattributes.pas"/>
|
||||
<UnitName Value="lazedittextattributes"/>
|
||||
</Item>
|
||||
</Files>
|
||||
<RequiredPkgs>
|
||||
<Item>
|
||||
<PackageName Value="LCLBase"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<PackageName Value="LazUtils"/>
|
||||
</Item>
|
||||
|
@ -9,7 +9,7 @@ interface
|
||||
|
||||
uses
|
||||
TextMateGrammar, xHyperLinksDecorator, xregexpr, xregexpr_unicodedata, LazEditMiscProcs,
|
||||
LazEditHighlighterUtils;
|
||||
LazEditHighlighterUtils, LazEditTextAttributes;
|
||||
|
||||
implementation
|
||||
|
||||
|
697
components/lazedit/lazedittextattributes.pas
Normal file
697
components/lazedit/lazedittextattributes.pas
Normal file
@ -0,0 +1,697 @@
|
||||
{
|
||||
*****************************************************************************
|
||||
This file is part of the LazEdit package from the Lazarus IDE.
|
||||
|
||||
This content of this file is licensensed: Modified LGPL-2
|
||||
Or at the users choice: Modified LGPL-3
|
||||
See the file COPYING.modifiedLGPL.txt, included in the Lazarus distribution,
|
||||
for details about the license.
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of the
|
||||
Mozilla Public License Version 1.1 http://www.mozilla.org/MPL/
|
||||
|
||||
A copy used under either License can have the other Licenses removed from this
|
||||
header. A note should be added that the original file is available with the
|
||||
above choice of License.
|
||||
*****************************************************************************
|
||||
}
|
||||
unit LazEditTextAttributes;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Graphics;
|
||||
|
||||
type
|
||||
//TLazTextAttributeFeature = (
|
||||
// lafForeColor, lafBackColor,
|
||||
// lafFrameColor,
|
||||
// lafAlpha, lafPrior,
|
||||
// lafStyle, lafStyleMask
|
||||
//);
|
||||
|
||||
TLazTextAttrLineStyle = (
|
||||
slsSolid, // PS_SOLID pen
|
||||
slsDashed, // PS_DASH pen
|
||||
slsDotted, // PS_DOT
|
||||
slsWaved // solid wave
|
||||
);
|
||||
|
||||
TLazTextAttrFrameEdges = (
|
||||
sfeNone,
|
||||
sfeAround, // frame around
|
||||
sfeBottom, // bottom part of the frame
|
||||
sfeLeft // left part of the frame
|
||||
);
|
||||
|
||||
TLazTextAttrBorderSide = (
|
||||
bsLeft,
|
||||
bsTop,
|
||||
bsRight,
|
||||
bsBottom
|
||||
);
|
||||
TLazTextAttrBorderSides = set of TLazTextAttrBorderSide;
|
||||
|
||||
{ TLazCustomEditTextAttribute }
|
||||
|
||||
TLazCustomEditTextAttribute = class(TPersistent)
|
||||
protected type
|
||||
TLazTextAttributeColor = (lacForeColor, lacBackColor, lacFrameColor);
|
||||
private
|
||||
FColors: array[TLazTextAttributeColor] of TColor;
|
||||
FFrameEdges: TLazTextAttrFrameEdges;
|
||||
FFrameStyle: TLazTextAttrLineStyle;
|
||||
FStyle: TFontStyles;
|
||||
|
||||
FUpdateCount: integer;
|
||||
FHasUpdates: Boolean;
|
||||
|
||||
protected
|
||||
function GetColor(AnIndex: TLazTextAttributeColor): TColor; inline;
|
||||
function GetAlpha({%H-}AnIndex: TLazTextAttributeColor): byte; virtual;
|
||||
function GetPriority({%H-}AnIndex: TLazTextAttributeColor): integer; virtual;
|
||||
function GetFrameStyle: TLazTextAttrLineStyle; inline;
|
||||
function GetFrameEdges: TLazTextAttrFrameEdges; inline;
|
||||
function GetFrameSideColors({%H-}Side: TLazTextAttrBorderSide): TColor; virtual;
|
||||
function GetFrameSidePriority({%H-}Side: TLazTextAttrBorderSide): integer; virtual;
|
||||
function GetFrameSideStyles({%H-}Side: TLazTextAttrBorderSide): TLazTextAttrLineStyle; virtual;
|
||||
function GetStyle: TFontStyles; inline;
|
||||
function GetStyleMask: TFontStyles; virtual;
|
||||
function GetStylePriority({%H-}AnIndex: TFontStyle): integer; virtual;
|
||||
procedure SetColor(AnIndex: TLazTextAttributeColor; AValue: TColor);
|
||||
procedure SetAlpha({%H-}AnIndex: TLazTextAttributeColor; {%H-}AValue: byte); virtual;
|
||||
procedure SetPriority({%H-}AnIndex: TLazTextAttributeColor; {%H-}AValue: integer); virtual;
|
||||
procedure SetFrameStyle(AValue: TLazTextAttrLineStyle);
|
||||
procedure SetFrameEdges(AValue: TLazTextAttrFrameEdges);
|
||||
procedure SetStyle(AValue: TFontStyles);
|
||||
procedure SetStyleMask({%H-}AValue: TFontStyles); virtual;
|
||||
procedure SetStylePriority({%H-}AnIndex: TFontStyle; {%H-}AValue: integer); virtual;
|
||||
|
||||
protected
|
||||
procedure Changed;
|
||||
procedure DoChanged; virtual;
|
||||
procedure Init; virtual;
|
||||
procedure DoClear; virtual;
|
||||
procedure AssignFrom(ASource: TLazCustomEditTextAttribute); virtual;
|
||||
public
|
||||
constructor Create;
|
||||
procedure Assign(ASource: TPersistent); override;
|
||||
procedure Clear;
|
||||
procedure BeginUpdate;
|
||||
procedure EndUpdate;
|
||||
function IsEnabled: boolean; virtual;
|
||||
procedure SetAllPriorities(APriority: integer); virtual;
|
||||
public
|
||||
property Foreground: TColor index lacForeColor read GetColor write SetColor;
|
||||
property Background: TColor index lacBackColor read GetColor write SetColor;
|
||||
property FrameColor: TColor index lacFrameColor read GetColor write SetColor;
|
||||
|
||||
property BackAlpha: byte index lacBackColor read GetAlpha write SetAlpha;
|
||||
property ForeAlpha: byte index lacForeColor read GetAlpha write SetAlpha;
|
||||
property FrameAlpha: byte index lacFrameColor read GetAlpha write SetAlpha;
|
||||
|
||||
property ForePriority: integer index lacForeColor read GetPriority write SetPriority;
|
||||
property BackPriority: integer index lacBackColor read GetPriority write SetPriority;
|
||||
property FramePriority: integer index lacFrameColor read GetPriority write SetPriority;
|
||||
|
||||
property FrameStyle: TLazTextAttrLineStyle read GetFrameStyle write SetFrameStyle;
|
||||
property FrameEdges: TLazTextAttrFrameEdges read GetFrameEdges write SetFrameEdges;
|
||||
|
||||
property FrameSidePriority[Side: TLazTextAttrBorderSide]: integer read GetFrameSidePriority;
|
||||
property FrameSideColors[Side: TLazTextAttrBorderSide]: TColor read GetFrameSideColors;
|
||||
property FrameSideStyles[Side: TLazTextAttrBorderSide]: TLazTextAttrLineStyle read GetFrameSideStyles;
|
||||
|
||||
property Style: TFontStyles read GetStyle write SetStyle;
|
||||
property StyleMask: TFontStyles read GetStyleMask write SetStyleMask;
|
||||
// FStyle = [], FStyleMask = [] ==> no modification
|
||||
// FStyle = [fsBold], FStyleMask = [] ==> invert fsBold
|
||||
// FStyle = [], FStyleMask = [fsBold] ==> clear fsBold
|
||||
// FStyle = [fsBold], FStyleMask = [fsBold] ==> set fsBold
|
||||
|
||||
property StylePriority[AnIndex: TFontStyle]: integer read GetStylePriority write SetStylePriority;
|
||||
property BoldPriority: integer index fsBold read GetStylePriority write SetStylePriority;
|
||||
property ItalicPriority: integer index fsItalic read GetStylePriority write SetStylePriority;
|
||||
property UnderlinePriority: integer index fsUnderline read GetStylePriority write SetStylePriority;
|
||||
property StrikeOutPriority: integer index fsStrikeOut read GetStylePriority write SetStylePriority;
|
||||
end;
|
||||
|
||||
{ TLazEditTextAttribute }
|
||||
|
||||
TLazEditTextAttribute = class(TLazCustomEditTextAttribute)
|
||||
private
|
||||
FOnChange: TNotifyEvent;
|
||||
FStoredName, FFixedCaption: string;
|
||||
FCaption: PString;
|
||||
|
||||
FPriority: array[TLazTextAttributeColor] of Integer;
|
||||
FStylePriority: array[TFontStyle] of Integer;
|
||||
|
||||
FDefaultColors: array[TLazTextAttributeColor] of TColor;
|
||||
FDefaultPriority: array[TLazTextAttributeColor] of Integer;
|
||||
FDefaultFrameEdges: TLazTextAttrFrameEdges;
|
||||
FDefaultFrameStyle: TLazTextAttrLineStyle;
|
||||
FDefaultStyle: TFontStyles;
|
||||
FDefaultStylePriority: array[TFontStyle] of Integer;
|
||||
|
||||
protected
|
||||
function GetPriority(AnIndex: TLazTextAttributeColor): integer; override;
|
||||
function GetFrameSidePriority(Side: TLazTextAttrBorderSide): integer; override;
|
||||
function GetStylePriority(AnIndex: TFontStyle): integer; override;
|
||||
procedure SetPriority(AnIndex: TLazTextAttributeColor; AValue: integer); override;
|
||||
procedure SetStylePriority(AnIndex: TFontStyle; AValue: integer); override;
|
||||
|
||||
function GetColorStored(AnIndex: TLazTextAttributeColor): Boolean;
|
||||
function GetPriorityStored(AnIndex: TLazTextAttributeColor): Boolean;
|
||||
function GetFrameStyleStored: Boolean;
|
||||
function GetFrameEdgesStored: Boolean;
|
||||
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 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 InternalSaveDefaultValues; virtual;
|
||||
procedure SetAllPriorities(APriority: integer); override;
|
||||
|
||||
property Caption: PString read FCaption; // will never be nil
|
||||
property StoredName: string read FStoredName write FStoredName; // name for storage (e.g. xml)
|
||||
|
||||
published
|
||||
property Foreground stored GetColorStored;
|
||||
property Background stored GetColorStored;
|
||||
property FrameColor stored GetColorStored;
|
||||
|
||||
property ForePriority stored GetPriorityStored;
|
||||
property BackPriority stored GetPriorityStored;
|
||||
property FramePriority stored GetPriorityStored;
|
||||
|
||||
property FrameStyle stored GetFrameStyleStored;
|
||||
property FrameEdges stored GetFrameEdgesStored;
|
||||
|
||||
property Style stored GetStyleStored;
|
||||
property BoldPriority stored GetStylePriorityStored;
|
||||
property ItalicPriority stored GetStylePriorityStored;
|
||||
property UnderlinePriority stored GetStylePriorityStored;
|
||||
property StrikeOutPriority stored GetStylePriorityStored;
|
||||
|
||||
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||
end;
|
||||
|
||||
{ TLazEditTextAttributeModifier }
|
||||
|
||||
TLazEditTextAttributeModifier = class(TLazEditTextAttribute)
|
||||
private
|
||||
FAlpha: array[TLazTextAttributeColor] of Byte;
|
||||
FStyleMask: TFontStyles;
|
||||
|
||||
FDefaultAlpha: array[TLazTextAttributeColor] of Byte;
|
||||
FDefaultStyleMask: TFontStyles;
|
||||
protected
|
||||
function GetAlpha(AnIndex: TLazTextAttributeColor): byte; override;
|
||||
function GetStyleMask: TFontStyles; override;
|
||||
procedure SetAlpha(AnIndex: TLazTextAttributeColor; AValue: byte); override;
|
||||
procedure SetStyleMask(AValue: TFontStyles); override;
|
||||
|
||||
function GetAlphaStored(AnIndex: TLazTextAttributeColor): Boolean;
|
||||
function GetStyleMaskStored: Boolean;
|
||||
|
||||
procedure DoClearThis; reintroduce; inline;
|
||||
procedure DoClear; override;
|
||||
procedure AssignFrom(ASource: TLazCustomEditTextAttribute); override;
|
||||
public
|
||||
function IsEnabled: boolean; override;
|
||||
procedure InternalSaveDefaultValues; override;
|
||||
|
||||
published
|
||||
property BackAlpha stored GetAlphaStored;
|
||||
property ForeAlpha stored GetAlphaStored;
|
||||
property FrameAlpha stored GetAlphaStored;
|
||||
|
||||
property StyleMask stored GetStyleMaskStored;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TLazCustomEditTextAttribute }
|
||||
|
||||
function TLazCustomEditTextAttribute.GetColor(AnIndex: TLazTextAttributeColor): TColor;
|
||||
begin
|
||||
Result := FColors[AnIndex];
|
||||
end;
|
||||
|
||||
function TLazCustomEditTextAttribute.GetAlpha(AnIndex: TLazTextAttributeColor): byte;
|
||||
begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TLazCustomEditTextAttribute.GetPriority(AnIndex: TLazTextAttributeColor): integer;
|
||||
begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TLazCustomEditTextAttribute.GetFrameStyle: TLazTextAttrLineStyle;
|
||||
begin
|
||||
Result := FFrameStyle;
|
||||
end;
|
||||
|
||||
function TLazCustomEditTextAttribute.GetFrameEdges: TLazTextAttrFrameEdges;
|
||||
begin
|
||||
Result := FFrameEdges;
|
||||
end;
|
||||
|
||||
function TLazCustomEditTextAttribute.GetFrameSideColors(Side: TLazTextAttrBorderSide): TColor;
|
||||
begin
|
||||
Result := FColors[lacFrameColor];
|
||||
end;
|
||||
|
||||
function TLazCustomEditTextAttribute.GetFrameSidePriority(Side: TLazTextAttrBorderSide): integer;
|
||||
begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TLazCustomEditTextAttribute.GetFrameSideStyles(Side: TLazTextAttrBorderSide
|
||||
): TLazTextAttrLineStyle;
|
||||
begin
|
||||
Result := FFrameStyle;
|
||||
end;
|
||||
|
||||
function TLazCustomEditTextAttribute.GetStyle: TFontStyles;
|
||||
begin
|
||||
Result := FStyle;
|
||||
end;
|
||||
|
||||
function TLazCustomEditTextAttribute.GetStyleMask: TFontStyles;
|
||||
begin
|
||||
Result := [low(TFontStyle)..High(TFontStyle)];
|
||||
end;
|
||||
|
||||
function TLazCustomEditTextAttribute.GetStylePriority(AnIndex: TFontStyle): integer;
|
||||
begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.SetColor(AnIndex: TLazTextAttributeColor; AValue: TColor);
|
||||
begin
|
||||
if FColors[AnIndex] = AValue then
|
||||
exit;
|
||||
FColors[AnIndex] := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.SetAlpha(AnIndex: TLazTextAttributeColor; AValue: byte);
|
||||
begin
|
||||
raise exception.Create('abstract');
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.SetPriority(AnIndex: TLazTextAttributeColor; AValue: integer
|
||||
);
|
||||
begin
|
||||
assert(false, 'TLazCustomEditTextAttribute.SetPriority: abstract');
|
||||
//raise exception.Create('abstract');
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.SetFrameStyle(AValue: TLazTextAttrLineStyle);
|
||||
begin
|
||||
if FFrameStyle = AValue then
|
||||
exit;
|
||||
FFrameStyle := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.SetFrameEdges(AValue: TLazTextAttrFrameEdges);
|
||||
begin
|
||||
if FFrameEdges = AValue then
|
||||
exit;
|
||||
FFrameEdges := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.SetStyle(AValue: TFontStyles);
|
||||
begin
|
||||
if FStyle = AValue then
|
||||
exit;
|
||||
FStyle := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.SetStyleMask(AValue: TFontStyles);
|
||||
begin
|
||||
assert(false, 'TLazCustomEditTextAttribute.SetStyleMask: abstract');
|
||||
//raise exception.Create('abstract');
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.SetStylePriority(AnIndex: TFontStyle; AValue: integer);
|
||||
begin
|
||||
assert(false, 'TLazCustomEditTextAttribute.SetStylePriority: abstract');
|
||||
//raise exception.Create('abstract');
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.Changed;
|
||||
begin
|
||||
FHasUpdates := FUpdateCount > 0;
|
||||
if FHasUpdates then
|
||||
exit;
|
||||
DoChanged;
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.DoChanged;
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.Init;
|
||||
begin
|
||||
Clear;
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.DoClear;
|
||||
var
|
||||
c: TLazTextAttributeColor;
|
||||
begin
|
||||
for c := low(TLazTextAttributeColor) to high(TLazTextAttributeColor) do
|
||||
FColors[c] := clNone;
|
||||
FFrameEdges := sfeAround;
|
||||
FFrameStyle := slsSolid;
|
||||
FStyle := [];
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.AssignFrom(ASource: TLazCustomEditTextAttribute);
|
||||
begin
|
||||
FColors := ASource.FColors;
|
||||
FFrameEdges := ASource.FFrameEdges;
|
||||
FFrameStyle := ASource.FFrameStyle;
|
||||
FStyle := ASource.FStyle;
|
||||
end;
|
||||
|
||||
constructor TLazCustomEditTextAttribute.Create;
|
||||
begin
|
||||
Init;
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.Assign(ASource: TPersistent);
|
||||
var
|
||||
Src: TLazCustomEditTextAttribute absolute ASource;
|
||||
begin
|
||||
if ASource is TLazCustomEditTextAttribute then begin
|
||||
BeginUpdate;
|
||||
AssignFrom(Src);
|
||||
Changed;
|
||||
EndUpdate;
|
||||
end
|
||||
else
|
||||
inherited Assign(ASource);
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.Clear;
|
||||
begin
|
||||
BeginUpdate;
|
||||
DoClear;
|
||||
Changed;
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.BeginUpdate;
|
||||
begin
|
||||
inc(FUpdateCount);
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.EndUpdate;
|
||||
begin
|
||||
if FUpdateCount > 0 then begin
|
||||
dec(FUpdateCount);
|
||||
if FHasUpdates and (FUpdateCount = 0) then
|
||||
Changed;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TLazCustomEditTextAttribute.IsEnabled: boolean;
|
||||
var
|
||||
c: TLazTextAttributeColor;
|
||||
begin
|
||||
Result := True;
|
||||
if FStyle <> [] then
|
||||
exit;
|
||||
for c := low(TLazTextAttributeColor) to high(TLazTextAttributeColor) do
|
||||
if FColors[c] <> clNone then
|
||||
exit;
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
procedure TLazCustomEditTextAttribute.SetAllPriorities(APriority: integer);
|
||||
begin
|
||||
assert(false, 'TLazCustomEditTextAttribute.SetAllPriorities: abstract');
|
||||
//raise exception.Create('abstract');
|
||||
end;
|
||||
|
||||
{ TLazEditTextAttribute }
|
||||
|
||||
function TLazEditTextAttribute.GetPriority(AnIndex: TLazTextAttributeColor): integer;
|
||||
begin
|
||||
Result := FPriority[AnIndex];
|
||||
end;
|
||||
|
||||
function TLazEditTextAttribute.GetFrameSidePriority(Side: TLazTextAttrBorderSide): integer;
|
||||
begin
|
||||
Result := FPriority[lacFrameColor];
|
||||
end;
|
||||
|
||||
function TLazEditTextAttribute.GetStylePriority(AnIndex: TFontStyle): integer;
|
||||
begin
|
||||
Result := inherited GetStylePriority(AnIndex);
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttribute.SetPriority(AnIndex: TLazTextAttributeColor; AValue: integer);
|
||||
begin
|
||||
if FPriority[AnIndex] = AValue then
|
||||
exit;
|
||||
FPriority[AnIndex] := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttribute.SetStylePriority(AnIndex: TFontStyle; AValue: integer);
|
||||
begin
|
||||
if FStylePriority[AnIndex] = AValue then
|
||||
exit;
|
||||
FStylePriority[AnIndex] := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
function TLazEditTextAttribute.GetColorStored(AnIndex: TLazTextAttributeColor): Boolean;
|
||||
begin
|
||||
Result := FColors[AnIndex] = FDefaultColors[AnIndex];
|
||||
end;
|
||||
|
||||
function TLazEditTextAttribute.GetPriorityStored(AnIndex: TLazTextAttributeColor): Boolean;
|
||||
begin
|
||||
Result := FPriority[AnIndex] = FDefaultPriority[AnIndex];
|
||||
end;
|
||||
|
||||
function TLazEditTextAttribute.GetFrameStyleStored: Boolean;
|
||||
begin
|
||||
Result := FFrameStyle = FDefaultFrameStyle;
|
||||
end;
|
||||
|
||||
function TLazEditTextAttribute.GetFrameEdgesStored: Boolean;
|
||||
begin
|
||||
Result := FFrameEdges = FDefaultFrameEdges;
|
||||
end;
|
||||
|
||||
function TLazEditTextAttribute.GetStyleStored: Boolean;
|
||||
begin
|
||||
Result := FStyle = FDefaultStyle;
|
||||
end;
|
||||
|
||||
function TLazEditTextAttribute.GetStylePriorityStored(AnIndex: TFontStyle): Boolean;
|
||||
begin
|
||||
Result := FStylePriority[AnIndex] = FDefaultStylePriority[AnIndex];
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttribute.SetCaption(ACaption: String);
|
||||
begin
|
||||
FFixedCaption := ACaption;
|
||||
FCaption := @FFixedCaption;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttribute.DoChanged;
|
||||
begin
|
||||
inherited DoChanged;
|
||||
if FOnChange <> nil then
|
||||
FOnChange(Self);
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttribute.Init;
|
||||
begin
|
||||
inherited Init;
|
||||
InternalSaveDefaultValues;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttribute.DoClearThis;
|
||||
var
|
||||
c: TLazTextAttributeColor;
|
||||
f: TFontStyle;
|
||||
begin
|
||||
for c := low(TLazTextAttributeColor) to high(TLazTextAttributeColor) do
|
||||
FPriority[c] := 0;
|
||||
for f := low(TFontStyle) to high(TFontStyle) do
|
||||
FStylePriority[f] := 0;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttribute.DoClear;
|
||||
begin
|
||||
inherited DoClear;
|
||||
DoClearThis;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttribute.AssignFrom(ASource: TLazCustomEditTextAttribute);
|
||||
var
|
||||
Source: TLazEditTextAttribute absolute ASource;
|
||||
begin
|
||||
inherited AssignFrom(ASource);
|
||||
if ASource is TLazEditTextAttribute then begin
|
||||
FStoredName := Source.FStoredName;
|
||||
FFixedCaption := Source.FFixedCaption;
|
||||
FCaption := Source.FCaption;
|
||||
FPriority := Source.FPriority;
|
||||
FStylePriority := Source.FStylePriority;
|
||||
end
|
||||
else
|
||||
DoClearThis;
|
||||
end;
|
||||
|
||||
constructor TLazEditTextAttribute.Create;
|
||||
begin
|
||||
FCaption := @FFixedCaption;
|
||||
inherited Create;
|
||||
end;
|
||||
|
||||
constructor TLazEditTextAttribute.Create(ACaption: string; AStoredName: String);
|
||||
begin
|
||||
FFixedCaption := ACaption;
|
||||
Create(@FFixedCaption, AStoredName);
|
||||
end;
|
||||
|
||||
constructor TLazEditTextAttribute.Create(ACaption: PString; AStoredName: String);
|
||||
begin
|
||||
Create;
|
||||
if ACaption <> nil then
|
||||
FCaption := ACaption;
|
||||
|
||||
FStoredName := AStoredName;
|
||||
if FStoredName = '' then
|
||||
FStoredName := FCaption^;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttribute.InternalSaveDefaultValues;
|
||||
begin
|
||||
FDefaultColors := FColors;
|
||||
FDefaultPriority := FPriority;
|
||||
FDefaultFrameEdges := FFrameEdges;
|
||||
FDefaultFrameStyle := FFrameStyle;
|
||||
FDefaultStyle := FStyle;
|
||||
FDefaultStylePriority := FStylePriority;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttribute.SetAllPriorities(APriority: integer);
|
||||
var
|
||||
c: TLazTextAttributeColor;
|
||||
f: TFontStyle;
|
||||
begin
|
||||
for c := low(TLazTextAttributeColor) to high(TLazTextAttributeColor) do
|
||||
FPriority[c] := APriority;
|
||||
for f := low(TFontStyle) to high(TFontStyle) do
|
||||
FStylePriority[f] := APriority;
|
||||
end;
|
||||
|
||||
{ TLazEditTextAttributeModifier }
|
||||
|
||||
function TLazEditTextAttributeModifier.GetAlpha(AnIndex: TLazTextAttributeColor): byte;
|
||||
begin
|
||||
Result := FAlpha[AnIndex];
|
||||
end;
|
||||
|
||||
function TLazEditTextAttributeModifier.GetStyleMask: TFontStyles;
|
||||
begin
|
||||
Result := FStyleMask;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttributeModifier.SetAlpha(AnIndex: TLazTextAttributeColor; AValue: byte);
|
||||
begin
|
||||
if FAlpha[AnIndex] = AValue then
|
||||
exit;
|
||||
FAlpha[AnIndex] := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttributeModifier.SetStyleMask(AValue: TFontStyles);
|
||||
begin
|
||||
if FStyleMask = AValue then
|
||||
exit;
|
||||
FStyleMask := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
function TLazEditTextAttributeModifier.GetAlphaStored(AnIndex: TLazTextAttributeColor): Boolean;
|
||||
begin
|
||||
Result := FAlpha[AnIndex] = FDefaultAlpha[AnIndex];
|
||||
end;
|
||||
|
||||
function TLazEditTextAttributeModifier.GetStyleMaskStored: Boolean;
|
||||
begin
|
||||
Result := FStyleMask = FDefaultStyleMask;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttributeModifier.DoClearThis;
|
||||
var
|
||||
c: TLazTextAttributeColor;
|
||||
begin
|
||||
for c := low(TLazTextAttributeColor) to high(TLazTextAttributeColor) do
|
||||
FAlpha[c] := 0;
|
||||
FStyleMask := [];
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttributeModifier.DoClear;
|
||||
begin
|
||||
inherited DoClear;
|
||||
DoClearThis;
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttributeModifier.AssignFrom(ASource: TLazCustomEditTextAttribute);
|
||||
var
|
||||
Source: TLazEditTextAttributeModifier absolute ASource;
|
||||
begin
|
||||
inherited AssignFrom(ASource);
|
||||
if ASource is TLazEditTextAttributeModifier then begin
|
||||
FAlpha := Source.FAlpha;
|
||||
FStyleMask := Source.FStyleMask;
|
||||
end
|
||||
else
|
||||
DoClearThis;
|
||||
end;
|
||||
|
||||
function TLazEditTextAttributeModifier.IsEnabled: boolean;
|
||||
begin
|
||||
Result := inherited IsEnabled;
|
||||
if Result then
|
||||
exit;
|
||||
Result := FStyleMask <> [];
|
||||
end;
|
||||
|
||||
procedure TLazEditTextAttributeModifier.InternalSaveDefaultValues;
|
||||
begin
|
||||
inherited InternalSaveDefaultValues;
|
||||
FDefaultAlpha := FAlpha;
|
||||
FDefaultStyleMask := FStyleMask;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -9,9 +9,10 @@ unit LazSynIMM;
|
||||
interface
|
||||
|
||||
uses
|
||||
windows, imm, LazSynIMMBase, Classes, SysUtils, Controls, LazLoggerBase, LCLType, LazUTF8, Graphics,
|
||||
SynEditMiscClasses, SynTextDrawer, SynEditPointClasses, SynEditMarkupSelection,
|
||||
SynEditMarkup, SynEditTypes, SynEditKeyCmds, LazSynEditText, SynEditTextBase;
|
||||
windows, imm, LazSynIMMBase, Classes, SysUtils, Controls, LazLoggerBase, LCLType, LazUTF8,
|
||||
Graphics, SynEditMiscClasses, SynTextDrawer, SynEditPointClasses, SynEditMarkupSelection,
|
||||
SynEditMarkup, SynEditTypes, SynEditKeyCmds, LazSynEditText, SynEditTextBase,
|
||||
LazEditTextAttributes;
|
||||
|
||||
type
|
||||
|
||||
|
@ -13,7 +13,7 @@ uses
|
||||
LazMethodList,
|
||||
// SynEdit
|
||||
SynEditTypes, SynEditMiscProcs, SynEditMiscClasses, LazSynEditText,
|
||||
SynEditMarkup, SynEditHighlighter, SynTextDrawer, LazEditMiscProcs;
|
||||
SynEditMarkup, SynEditHighlighter, SynTextDrawer, LazEditMiscProcs, LazEditTextAttributes;
|
||||
|
||||
|
||||
type
|
||||
@ -520,7 +520,7 @@ end;
|
||||
function TLazSynPaintTokenBreaker.GetNextHighlighterTokenFromView(out
|
||||
ATokenInfo: TLazSynDisplayTokenInfoEx; APhysEnd: Integer; ALogEnd: Integer): Boolean;
|
||||
|
||||
procedure InitSynAttr(var ATarget: TSynSelectedColorMergeResult; const ASource: TLazSynCustomTextAttributes;
|
||||
procedure InitSynAttr(var ATarget: TSynSelectedColorMergeResult; const ASource: TLazEditTextAttribute;
|
||||
const AnAttrStartX: TLazSynDisplayTokenBound);
|
||||
const
|
||||
NoEnd: TLazSynDisplayTokenBound = (Physical: -1; Logical: -1; Offset: 0);
|
||||
|
@ -144,7 +144,7 @@ uses
|
||||
SynEditMiscClasses, SynEditHighlighter, LazSynTextArea, SynTextDrawer,
|
||||
SynEditTextBidiChars, SynGutterCodeFolding, SynGutterChanges, SynGutterLineNumber,
|
||||
SynGutterMarks, SynGutterLineOverview,
|
||||
LazEditMiscProcs;
|
||||
LazEditMiscProcs, LazEditTextAttributes;
|
||||
|
||||
const
|
||||
// SynDefaultFont is determined in InitSynDefaultFont()
|
||||
|
@ -38,7 +38,7 @@ uses
|
||||
// LazUtils
|
||||
LazUTF8, LazMethodList,
|
||||
// SynEdit
|
||||
SynEditTypes, SynEditTextBase, SynEditMiscProcs;
|
||||
SynEditTypes, SynEditTextBase, SynEditMiscProcs, LazEditTextAttributes;
|
||||
|
||||
type
|
||||
{ TSynHighlighterRangeList }
|
||||
@ -70,114 +70,25 @@ type
|
||||
property NeedsReScanRealStartIndex: Integer read GetNeedsReScanRealStartIndex;
|
||||
end;
|
||||
|
||||
{ TLazSynCustomTextAttributes }
|
||||
TLazSynCustomTextAttributes = TLazEditTextAttribute deprecated 'use TLazEditTextAttribute // to be removed in 5.99';
|
||||
TSynHighlighterAttributes = TLazEditTextAttribute;
|
||||
TSynHighlighterAttributesModifier = TLazEditTextAttributeModifier;
|
||||
|
||||
TLazSynCustomTextAttributes = class(TPersistent)
|
||||
{strict} private
|
||||
FUpdateCount: Integer;
|
||||
FWasChanged: Boolean;
|
||||
{ TSynHighlighterAttributesHelper }
|
||||
|
||||
FBackground: TColor;
|
||||
FForeground: TColor;
|
||||
FFrameColor: TColor;
|
||||
FFrameEdges: TSynFrameEdges;
|
||||
FFrameStyle: TSynLineStyle;
|
||||
fStyle: TFontStyles;
|
||||
fStyleMask: TFontStyles;
|
||||
|
||||
FBackPriority: integer;
|
||||
FForePriority: integer;
|
||||
FFramePriority: integer;
|
||||
FStylePriority: Array [TFontStyle] of integer;
|
||||
|
||||
function GetStylePriority(AIndex: TFontStyle): integer;
|
||||
procedure SetBackground(AValue: TColor);
|
||||
procedure SetBackPriority(AValue: integer);
|
||||
procedure SetForeground(AValue: TColor);
|
||||
procedure SetForePriority(AValue: integer);
|
||||
procedure SetFrameColor(AValue: TColor);
|
||||
procedure SetFrameEdges(AValue: TSynFrameEdges);
|
||||
procedure SetFramePriority(AValue: integer);
|
||||
procedure SetFrameStyle(AValue: TSynLineStyle);
|
||||
procedure SetStyle(AValue: TFontStyles);
|
||||
procedure SetStyleMask(AValue: TFontStyles);
|
||||
procedure SetStylePriority(AIndex: TFontStyle; AValue: integer);
|
||||
protected
|
||||
procedure AssignFrom(Src: TLazSynCustomTextAttributes); virtual;
|
||||
procedure DoClear; virtual;
|
||||
procedure Changed;
|
||||
procedure DoChange; virtual;
|
||||
procedure Init; virtual;
|
||||
public
|
||||
constructor Create;
|
||||
procedure Clear;
|
||||
procedure Assign(aSource: TPersistent); override;
|
||||
procedure SetAllPriorities(APriority: integer);
|
||||
procedure BeginUpdate;
|
||||
procedure EndUpdate;
|
||||
public
|
||||
property Background: TColor read FBackground write SetBackground;
|
||||
property Foreground: TColor read FForeground write SetForeground;
|
||||
property FrameColor: TColor read FFrameColor write SetFrameColor;
|
||||
property FrameStyle: TSynLineStyle read FFrameStyle write SetFrameStyle;
|
||||
property FrameEdges: TSynFrameEdges read FFrameEdges write SetFrameEdges;
|
||||
property Style: TFontStyles read fStyle write SetStyle;
|
||||
property StyleMask: TFontStyles read fStyleMask write SetStyleMask;
|
||||
|
||||
property StylePriority[Index: TFontStyle]: integer read GetStylePriority write SetStylePriority;
|
||||
|
||||
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;
|
||||
property ItalicPriority: integer index fsItalic read GetStylePriority write SetStylePriority;
|
||||
property UnderlinePriority: integer index fsUnderline read GetStylePriority write SetStylePriority;
|
||||
property StrikeOutPriority: integer index fsStrikeOut read GetStylePriority write SetStylePriority;
|
||||
end;
|
||||
|
||||
{ TSynHighlighterAttributes }
|
||||
|
||||
TSynHighlighterAttributes = class(TLazSynCustomTextAttributes)
|
||||
TSynHighlighterAttributesHelper = class helper for TLazEditTextAttribute
|
||||
private
|
||||
FBackgroundDefault: TColor;
|
||||
FForegroundDefault: TColor;
|
||||
FFrameColorDefault: TColor;
|
||||
FFrameEdgesDefault: TSynFrameEdges;
|
||||
FFrameStyleDefault: TSynLineStyle;
|
||||
FStyleDefault: TFontStyles;
|
||||
FStyleMaskDefault: TFontStyles;
|
||||
FStoredName: string;
|
||||
FConstName: string;
|
||||
FCaption: PString;
|
||||
FOnChange: TNotifyEvent;
|
||||
function GetBackgroundColorStored: boolean;
|
||||
function GetFontStyleMaskStored : boolean;
|
||||
function GetForegroundColorStored: boolean;
|
||||
function GetFrameColorStored: boolean;
|
||||
function GetFrameEdgesStored: boolean;
|
||||
function GetFrameStyleStored: boolean;
|
||||
function GetConstName: string;
|
||||
function GetStyleFromInt: integer;
|
||||
procedure SetConstName(AValue: string);
|
||||
procedure SetStyleFromInt(const Value: integer);
|
||||
function GetFontStyleStored: boolean;
|
||||
function GetStyleMaskFromInt : integer;
|
||||
procedure SetStyleMaskFromInt(const Value : integer);
|
||||
protected
|
||||
function GetBackPriorityStored: Boolean; virtual;
|
||||
function GetForePriorityStored: Boolean; virtual;
|
||||
function GetFramePriorityStored: Boolean; virtual;
|
||||
function GetStylePriorityStored(AIndex: TFontStyle): Boolean; virtual;
|
||||
|
||||
procedure AssignFrom(Src: TLazSynCustomTextAttributes); override;
|
||||
procedure DoChange; override;
|
||||
property ConstName: string read FConstName write FConstName; // internal accessor
|
||||
property ConstName: string read GetConstName write SetConstName; // internal accessor
|
||||
public
|
||||
constructor Create;
|
||||
constructor Create(aCaption: string; aStoredName: String = '');
|
||||
constructor Create(aCaption: PString; aStoredName: String = '');
|
||||
function IsEnabled: boolean; virtual;
|
||||
procedure InternalSaveDefaultValues; virtual;
|
||||
function LoadFromBorlandRegistry(rootKey: HKEY; attrKey, attrName: string;
|
||||
oldStyle: boolean): boolean; virtual;
|
||||
oldStyle: boolean): boolean;
|
||||
function LoadFromRegistry(Reg: TRegistry): boolean;
|
||||
function SaveToRegistry(Reg: TRegistry): boolean;
|
||||
function LoadFromFile(Ini : TIniFile): boolean;
|
||||
@ -185,72 +96,9 @@ type
|
||||
public
|
||||
property IntegerStyle: integer read GetStyleFromInt write SetStyleFromInt;
|
||||
property IntegerStyleMask: integer read GetStyleMaskFromInt write SetStyleMaskFromInt;
|
||||
property Name: string read FConstName; // value of Caption at creation, use Caption instead, kept for compatibility
|
||||
property Caption: PString read FCaption; // is never nil
|
||||
property StoredName: string read FStoredName write FStoredName; // the identifier
|
||||
property OnChange: TNotifyEvent read fOnChange write fOnChange;
|
||||
published
|
||||
property Background stored GetBackgroundColorStored;
|
||||
property Foreground stored GetForegroundColorStored;
|
||||
property FrameColor stored GetFrameColorStored;
|
||||
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
|
||||
|
||||
property BackPriority stored GetBackPriorityStored;
|
||||
property ForePriority stored GetForePriorityStored;
|
||||
property FramePriority stored GetFramePriorityStored;
|
||||
property BoldPriority stored GetStylePriorityStored;
|
||||
property ItalicPriority stored GetStylePriorityStored;
|
||||
property UnderlinePriority stored GetStylePriorityStored;
|
||||
property StrikeOutPriority stored GetStylePriorityStored;
|
||||
property Name: string read GetConstName; deprecated 'use Caption'; // value of Caption at creation, use Caption instead, kept for compatibility
|
||||
end;
|
||||
|
||||
{ TSynHighlighterAttributesModifier }
|
||||
|
||||
TSynHighlighterAttributesModifier = class(TSynHighlighterAttributes)
|
||||
private
|
||||
FBackAlpha: byte;
|
||||
FForeAlpha: byte;
|
||||
FFrameAlpha: byte;
|
||||
|
||||
FBackAlphaDefault: byte;
|
||||
FForeAlphaDefault: byte;
|
||||
FFrameAlphaDefault: byte;
|
||||
FBackPriorityDefault: integer;
|
||||
FForePriorityDefault: integer;
|
||||
FFramePriorityDefault: integer;
|
||||
FStylePriorityDefault: Array [TFontStyle] of integer;
|
||||
|
||||
function GetBackAlphaStored: Boolean;
|
||||
function GetForeAlphaStored: Boolean;
|
||||
function GetFrameAlphaStored: Boolean;
|
||||
|
||||
procedure SetBackAlpha(AValue: byte);
|
||||
procedure SetForeAlpha(AValue: byte);
|
||||
procedure SetFrameAlpha(AValue: byte);
|
||||
protected
|
||||
function GetBackPriorityStored: Boolean; override;
|
||||
function GetForePriorityStored: Boolean; override;
|
||||
function GetFramePriorityStored: Boolean; override;
|
||||
function GetStylePriorityStored(Index: TFontStyle): Boolean; override;
|
||||
|
||||
procedure AssignFrom(Src: TLazSynCustomTextAttributes); override;
|
||||
procedure DoClear; override;
|
||||
public
|
||||
procedure InternalSaveDefaultValues; override;
|
||||
published
|
||||
// Alpha = 0 means solid // 1..255 means n of 256
|
||||
property BackAlpha: byte read FBackAlpha write SetBackAlpha stored GetBackAlphaStored;
|
||||
property ForeAlpha: byte read FForeAlpha write SetForeAlpha stored GetForeAlphaStored;
|
||||
property FrameAlpha: byte read FFrameAlpha write SetFrameAlpha stored GetFrameAlphaStored;
|
||||
end;
|
||||
|
||||
TSynCustomHighlighter = class;
|
||||
|
||||
@ -554,102 +402,6 @@ implementation
|
||||
const
|
||||
IDLE_SCAN_CHUNK_SIZE = 2500;
|
||||
|
||||
{ TSynHighlighterAttributesModifier }
|
||||
|
||||
procedure TSynHighlighterAttributesModifier.SetBackAlpha(AValue: byte);
|
||||
begin
|
||||
if FBackAlpha = AValue then Exit;
|
||||
FBackAlpha := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributesModifier.GetBackPriorityStored: Boolean;
|
||||
begin
|
||||
Result := FBackPriority <> FBackPriorityDefault;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributesModifier.GetBackAlphaStored: Boolean;
|
||||
begin
|
||||
Result := FBackAlpha <> FBackAlphaDefault;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributesModifier.GetForeAlphaStored: Boolean;
|
||||
begin
|
||||
Result := FForeAlpha <> FForeAlphaDefault;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributesModifier.GetForePriorityStored: Boolean;
|
||||
begin
|
||||
Result := FForePriority <> FForePriorityDefault;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributesModifier.GetFrameAlphaStored: Boolean;
|
||||
begin
|
||||
Result := FFrameAlpha <> FForeAlphaDefault;
|
||||
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.SetForeAlpha(AValue: byte);
|
||||
begin
|
||||
if FForeAlpha = AValue then Exit;
|
||||
FForeAlpha := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributesModifier.SetFrameAlpha(AValue: byte);
|
||||
begin
|
||||
if FFrameAlpha = AValue then Exit;
|
||||
FFrameAlpha := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributesModifier.AssignFrom(Src: TLazSynCustomTextAttributes);
|
||||
var
|
||||
Source: TSynHighlighterAttributesModifier;
|
||||
begin
|
||||
inherited AssignFrom(Src);
|
||||
if Src is TSynHighlighterAttributesModifier then begin
|
||||
Source := TSynHighlighterAttributesModifier(Src);
|
||||
FBackAlpha := Source.BackAlpha;
|
||||
FForeAlpha := Source.ForeAlpha;
|
||||
FFrameAlpha := Source.FrameAlpha;
|
||||
end
|
||||
else begin
|
||||
FBackAlpha := 0;
|
||||
FForeAlpha := 0;
|
||||
FFrameAlpha := 0;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributesModifier.DoClear;
|
||||
begin
|
||||
inherited DoClear;
|
||||
FBackAlpha := 0;
|
||||
FForeAlpha := 0;
|
||||
FFrameAlpha := 0;
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributesModifier.InternalSaveDefaultValues;
|
||||
begin
|
||||
inherited InternalSaveDefaultValues;
|
||||
FBackPriorityDefault := FBackPriority;
|
||||
FForePriorityDefault := FForePriority;
|
||||
FFramePriorityDefault := FFramePriority;
|
||||
FForeAlphaDefault := FForeAlpha;
|
||||
FBackAlphaDefault := FBackAlpha;
|
||||
FFrameAlphaDefault := FFrameAlpha;
|
||||
FStylePriorityDefault := FStylePriority;
|
||||
end;
|
||||
|
||||
{ TSynHighlighterAttributesModifierCollectionItem }
|
||||
|
||||
procedure TSynHighlighterAttributesModifierCollectionItem.SetAttribute(
|
||||
@ -854,286 +606,9 @@ begin
|
||||
G_PlaceableHighlighters.hlList.Add(highlighter);
|
||||
end;
|
||||
|
||||
{ TLazSynCustomTextAttributes }
|
||||
{ TSynHighlighterAttributesHelper }
|
||||
|
||||
procedure TLazSynCustomTextAttributes.SetBackground(AValue: TColor);
|
||||
begin
|
||||
if FBackground = AValue then Exit;
|
||||
FBackground := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
function TLazSynCustomTextAttributes.GetStylePriority(AIndex: TFontStyle
|
||||
): integer;
|
||||
begin
|
||||
Result := FStylePriority[AIndex];
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.SetBackPriority(AValue: integer);
|
||||
begin
|
||||
if FBackPriority = AValue then Exit;
|
||||
FBackPriority := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.SetForeground(AValue: TColor);
|
||||
begin
|
||||
if FForeground = AValue then Exit;
|
||||
FForeground := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.SetForePriority(AValue: integer);
|
||||
begin
|
||||
if FForePriority = AValue then Exit;
|
||||
FForePriority := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.SetFrameColor(AValue: TColor);
|
||||
begin
|
||||
if FFrameColor = AValue then Exit;
|
||||
FFrameColor := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.SetFrameEdges(AValue: TSynFrameEdges);
|
||||
begin
|
||||
if FFrameEdges = AValue then Exit;
|
||||
FFrameEdges := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.SetFramePriority(AValue: integer);
|
||||
begin
|
||||
if FFramePriority = AValue then Exit;
|
||||
FFramePriority := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.SetFrameStyle(AValue: TSynLineStyle);
|
||||
begin
|
||||
if FFrameStyle = AValue then Exit;
|
||||
FFrameStyle := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.SetStyle(AValue: TFontStyles);
|
||||
begin
|
||||
if fStyle = AValue then Exit;
|
||||
fStyle := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.SetStyleMask(AValue: TFontStyles);
|
||||
begin
|
||||
if fStyleMask = AValue then Exit;
|
||||
fStyleMask := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.SetStylePriority(AIndex: TFontStyle;
|
||||
AValue: integer);
|
||||
begin
|
||||
if FStylePriority[AIndex] = AValue then Exit;
|
||||
FStylePriority[AIndex] := AValue;
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.Changed;
|
||||
begin
|
||||
FWasChanged := True;
|
||||
if FUpdateCount > 0 then
|
||||
exit;
|
||||
FWasChanged := False;
|
||||
DoChange;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.AssignFrom(Src: TLazSynCustomTextAttributes);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.DoClear;
|
||||
var
|
||||
i: TFontStyle;
|
||||
begin
|
||||
Background := clNone;
|
||||
Foreground := clNone;
|
||||
FrameColor := clNone;
|
||||
FrameStyle := slsSolid;
|
||||
FrameEdges := sfeAround;
|
||||
Style := [];
|
||||
StyleMask := [];
|
||||
FForePriority := 0;
|
||||
FBackPriority := 0;
|
||||
FFramePriority := 0;
|
||||
for i := Low(TFontStyle) to High(TFontStyle) do
|
||||
FStylePriority[i] := 0;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.DoChange;
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.Init;
|
||||
begin
|
||||
// called by create
|
||||
Clear;
|
||||
end;
|
||||
|
||||
constructor TLazSynCustomTextAttributes.Create;
|
||||
begin
|
||||
inherited;
|
||||
FUpdateCount := 0;
|
||||
FWasChanged := False;
|
||||
Init;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.Clear;
|
||||
begin
|
||||
BeginUpdate;
|
||||
DoClear;
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.Assign(aSource: TPersistent);
|
||||
var
|
||||
Source : TLazSynCustomTextAttributes;
|
||||
begin
|
||||
if aSource is TLazSynCustomTextAttributes then
|
||||
begin
|
||||
BeginUpdate;
|
||||
Source := TLazSynCustomTextAttributes(aSource);
|
||||
Foreground := Source.Foreground;
|
||||
Background := Source.Background;
|
||||
FrameColor := Source.FrameColor;
|
||||
FrameStyle := Source.FrameStyle;
|
||||
FrameEdges := Source.FrameEdges;
|
||||
Style := Source.FStyle;
|
||||
StyleMask := Source.FStyleMask;
|
||||
ForePriority := Source.ForePriority;
|
||||
BackPriority := Source.BackPriority;
|
||||
FramePriority := Source.FramePriority;
|
||||
FStylePriority := Source.FStylePriority;
|
||||
AssignFrom(Source);
|
||||
EndUpdate;
|
||||
end
|
||||
else
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.SetAllPriorities(APriority: integer);
|
||||
var
|
||||
i: TFontStyle;
|
||||
begin
|
||||
BeginUpdate;
|
||||
ForePriority := APriority;
|
||||
BackPriority := APriority;
|
||||
FramePriority := APriority;
|
||||
for i := Low(TFontStyle) to High(TFontStyle) do
|
||||
StylePriority[i] := APriority;
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.BeginUpdate;
|
||||
begin
|
||||
inc(FUpdateCount);
|
||||
end;
|
||||
|
||||
procedure TLazSynCustomTextAttributes.EndUpdate;
|
||||
begin
|
||||
dec(FUpdateCount);
|
||||
if (FUpdateCount = 0) and FWasChanged then
|
||||
Changed;
|
||||
end;
|
||||
|
||||
{ TSynHighlighterAttributes }
|
||||
|
||||
constructor TSynHighlighterAttributes.Create(aCaption: string;
|
||||
aStoredName: String = '');
|
||||
begin
|
||||
Create;
|
||||
FConstName := aCaption;
|
||||
FCaption := @FConstName;
|
||||
if aStoredName = '' then
|
||||
aStoredName := FConstName;
|
||||
FStoredName := aStoredName;;
|
||||
end;
|
||||
|
||||
constructor TSynHighlighterAttributes.Create(aCaption: PString; aStoredName: String);
|
||||
begin
|
||||
Create;
|
||||
if aCaption<>nil then begin
|
||||
FConstName := aCaption^;
|
||||
FCaption := aCaption;
|
||||
end
|
||||
else begin
|
||||
FConstName := '';
|
||||
FCaption := @FConstName;
|
||||
end;
|
||||
if aStoredName = '' then
|
||||
aStoredName := FConstName;
|
||||
FStoredName := aStoredName;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.IsEnabled: boolean;
|
||||
begin
|
||||
Result := (Background <> clNone) or (Foreground <> clNone) or
|
||||
( (FrameColor <> clNone) and (FrameEdges <> sfeNone) ) or
|
||||
(Style <> []) or (StyleMask <> []);
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetBackgroundColorStored: boolean;
|
||||
begin
|
||||
Result := Background <> fBackgroundDefault;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetFontStyleMaskStored : boolean;
|
||||
begin
|
||||
Result := StyleMask <> fStyleMaskDefault;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetForegroundColorStored: boolean;
|
||||
begin
|
||||
Result := Foreground <> fForegroundDefault;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetFrameColorStored: boolean;
|
||||
begin
|
||||
Result := FrameColor <> FFrameColorDefault;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetFrameEdgesStored: boolean;
|
||||
begin
|
||||
Result := FrameEdges <> FFrameEdgesDefault;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetFrameStyleStored: boolean;
|
||||
begin
|
||||
Result := FrameStyle <> FFrameStyleDefault;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetFontStyleStored: boolean;
|
||||
begin
|
||||
Result := Style <> fStyleDefault;
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributes.InternalSaveDefaultValues;
|
||||
(* Called once from TSynCustomHighlighter.Create (and only from there),
|
||||
after all Attributes where created *)
|
||||
begin
|
||||
fForegroundDefault := Foreground;
|
||||
fBackgroundDefault := Background;
|
||||
FFrameColorDefault := FrameColor;
|
||||
FFrameStyleDefault := FrameStyle;
|
||||
FFrameEdgesDefault := FrameEdges;
|
||||
fStyleDefault := Style;
|
||||
fStyleMaskDefault := StyleMask;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.LoadFromBorlandRegistry(rootKey: HKEY;
|
||||
function TSynHighlighterAttributesHelper.LoadFromBorlandRegistry(rootKey: HKEY;
|
||||
attrKey, attrName: string; oldStyle: boolean): boolean;
|
||||
// How the highlighting information is stored:
|
||||
// Delphi 1.0:
|
||||
@ -1305,9 +780,9 @@ const
|
||||
begin
|
||||
if oldStyle then Result := LoadOldStyle(rootKey, attrKey, attrName)
|
||||
else Result := LoadNewStyle(rootKey, attrKey, attrName);
|
||||
end; { TSynHighlighterAttributes.LoadFromBorlandRegistry }
|
||||
end; { TSynHighlighterAttributesHelper.LoadFromBorlandRegistry }
|
||||
|
||||
function TSynHighlighterAttributes.LoadFromRegistry(Reg: TRegistry): boolean;
|
||||
function TSynHighlighterAttributesHelper.LoadFromRegistry(Reg: TRegistry): boolean;
|
||||
{$IFNDEF SYN_LAZARUS}
|
||||
var
|
||||
key: string;
|
||||
@ -1334,7 +809,7 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.SaveToRegistry(Reg: TRegistry): boolean;
|
||||
function TSynHighlighterAttributesHelper.SaveToRegistry(Reg: TRegistry): boolean;
|
||||
var
|
||||
key: string;
|
||||
begin
|
||||
@ -1350,7 +825,7 @@ begin
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.LoadFromFile(Ini : TIniFile): boolean; //DDH 10/16/01
|
||||
function TSynHighlighterAttributesHelper.LoadFromFile(Ini : TIniFile): boolean; //DDH 10/16/01
|
||||
var
|
||||
S: TStringListUTF8Fast;
|
||||
begin
|
||||
@ -1374,7 +849,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.SaveToFile(Ini : TIniFile): boolean; //DDH 10/16/01
|
||||
function TSynHighlighterAttributesHelper.SaveToFile(Ini : TIniFile): boolean; //DDH 10/16/01
|
||||
begin
|
||||
Ini.WriteInteger(StoredName, 'Background', Background);
|
||||
Ini.WriteInteger(StoredName, 'Foreground', Foreground);
|
||||
@ -1383,7 +858,12 @@ begin
|
||||
Result := true;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetStyleFromInt: integer;
|
||||
function TSynHighlighterAttributesHelper.GetConstName: string;
|
||||
begin
|
||||
Result := Caption^;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributesHelper.GetStyleFromInt: integer;
|
||||
begin
|
||||
if fsBold in Style then Result:= 1 else Result:= 0;
|
||||
if fsItalic in Style then Result:= Result + 2;
|
||||
@ -1391,7 +871,12 @@ begin
|
||||
if fsStrikeout in Style then Result:= Result + 8;
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributes.SetStyleFromInt(const Value: integer);
|
||||
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];
|
||||
if Value and $2 <> 0 then Style:= Style + [fsItalic];
|
||||
@ -1399,7 +884,7 @@ begin
|
||||
if Value and $8 <> 0 then Style:= Style + [fsStrikeout];
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetStyleMaskFromInt : integer;
|
||||
function TSynHighlighterAttributesHelper.GetStyleMaskFromInt : integer;
|
||||
begin
|
||||
if fsBold in StyleMask then Result:= 1 else Result:= 0;
|
||||
if fsItalic in StyleMask then Result:= Result + 2;
|
||||
@ -1407,7 +892,7 @@ begin
|
||||
if fsStrikeout in StyleMask then Result:= Result + 8;
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributes.SetStyleMaskFromInt(const Value : integer);
|
||||
procedure TSynHighlighterAttributesHelper.SetStyleMaskFromInt(const Value : integer);
|
||||
begin
|
||||
if Value and $1 = 0 then StyleMask:= [] else StyleMask:= [fsBold];
|
||||
if Value and $2 <> 0 then StyleMask:= StyleMask + [fsItalic];
|
||||
@ -1415,49 +900,6 @@ begin
|
||||
if Value and $8 <> 0 then StyleMask:= StyleMask + [fsStrikeout];
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetBackPriorityStored: Boolean;
|
||||
begin
|
||||
Result := FBackPriority <> 0;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetForePriorityStored: Boolean;
|
||||
begin
|
||||
Result := FForePriority <> 0;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetFramePriorityStored: Boolean;
|
||||
begin
|
||||
Result := FFramePriority <> 0;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetStylePriorityStored(AIndex: TFontStyle
|
||||
): Boolean;
|
||||
begin
|
||||
Result := FStylePriority[AIndex] <> 0;
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributes.AssignFrom(Src: TLazSynCustomTextAttributes);
|
||||
begin
|
||||
inherited AssignFrom(Src);
|
||||
if not (Src is TSynHighlighterAttributes) then exit;
|
||||
FConstName := TSynHighlighterAttributes(Src).FConstName;
|
||||
FStoredName:= TSynHighlighterAttributes(Src).FStoredName;
|
||||
Changed; {TODO: only if really changed}
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterAttributes.DoChange;
|
||||
begin
|
||||
inherited DoChange;
|
||||
if Assigned(fOnChange) then
|
||||
fOnChange(Self);
|
||||
end;
|
||||
|
||||
constructor TSynHighlighterAttributes.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
InternalSaveDefaultValues;
|
||||
end;
|
||||
|
||||
{ TSynEditLinesList }
|
||||
|
||||
function TSynEditLinesList.GetSynString(Index: Integer): TSynEditStringsBase;
|
||||
|
@ -54,7 +54,7 @@ uses
|
||||
SynEditHighlighter,
|
||||
SynEditHighlighterFoldBase, LazSynEditText, SynEditTextBase, SynEditTypes,
|
||||
{$IFDEF WithSynMarkupFoldColorDebugGutter}SynGutterBase, SynTextDrawer,{$ENDIF}
|
||||
SynEditMiscProcs, LazEditMiscProcs,
|
||||
SynEditMiscProcs, LazEditMiscProcs, LazEditTextAttributes,
|
||||
{$IFDEF SynEditMarkupFoldColoringDebug}
|
||||
SynHighlighterPas,
|
||||
strutils,
|
||||
|
@ -52,7 +52,7 @@ uses
|
||||
LCLIntf, LCLType, Graphics, Controls, Clipbrd, ImgList,
|
||||
// SynEdit
|
||||
SynEditHighlighter, SynEditMiscProcs, SynEditTypes, LazSynEditText, SynEditPointClasses, SynEditMouseCmds,
|
||||
SynEditTextBase;
|
||||
SynEditTextBase, LazEditTextAttributes;
|
||||
|
||||
const
|
||||
SYNEDIT_DEFAULT_MOUSE_OPTIONS = [];
|
||||
@ -485,7 +485,7 @@ type
|
||||
FStartX, FEndX: TLazSynDisplayTokenBound;
|
||||
protected
|
||||
procedure DoClear; override;
|
||||
procedure AssignFrom(Src: TLazSynCustomTextAttributes); override;
|
||||
procedure AssignFrom(Src: TLazCustomEditTextAttribute); override;
|
||||
procedure Init; override;
|
||||
public
|
||||
// boundaries of the frame
|
||||
@ -536,14 +536,15 @@ type
|
||||
FMergeInfos: array [TSynSelectedColorEnum] of TSynSelectedColorMergeInfo;
|
||||
|
||||
function IsMatching(ABound1, ABound2: TLazSynDisplayTokenBound): Boolean;
|
||||
function GetFrameSideColors(Side: TLazSynBorderSide): TColor;
|
||||
function GetFrameSideOrigin(Side: TLazSynBorderSide): TSynFrameEdges;
|
||||
function GetFrameSidePriority(Side: TLazSynBorderSide): integer;
|
||||
function GetFrameSideStyles(Side: TLazSynBorderSide): TSynLineStyle;
|
||||
procedure SetCurrentEndX(AValue: TLazSynDisplayTokenBound);
|
||||
procedure SetCurrentStartX(AValue: TLazSynDisplayTokenBound);
|
||||
protected
|
||||
procedure AssignFrom(Src: TLazSynCustomTextAttributes); override;
|
||||
function GetFrameSideColors(Side: TLazSynBorderSide): TColor; override;
|
||||
function GetFrameSidePriority(Side: TLazSynBorderSide): integer; override;
|
||||
function GetFrameSideStyles(Side: TLazSynBorderSide): TSynLineStyle; override;
|
||||
|
||||
procedure AssignFrom(Src: TLazCustomEditTextAttribute); override;
|
||||
procedure DoClear; override;
|
||||
procedure Init; override;
|
||||
|
||||
@ -552,13 +553,10 @@ type
|
||||
AColor: TColor; APriority, AnAlpha: Integer);
|
||||
function CalculateInfo(var AnInfo: TSynSelectedColorMergeInfo;
|
||||
ANoneColor: TColor; IsFrame: Boolean = False): TColor;
|
||||
property FrameSidePriority[Side: TLazSynBorderSide]: integer read GetFrameSidePriority;
|
||||
property FrameSideOrigin[Side: TLazSynBorderSide]: TSynFrameEdges read GetFrameSideOrigin;
|
||||
public
|
||||
destructor Destroy; override;
|
||||
|
||||
property FrameSideColors[Side: TLazSynBorderSide]: TColor read GetFrameSideColors;
|
||||
property FrameSideStyles[Side: TLazSynBorderSide]: TSynLineStyle read GetFrameSideStyles;
|
||||
// boundaries for current paint
|
||||
property CurrentStartX: TLazSynDisplayTokenBound read FCurrentStartX write SetCurrentStartX;
|
||||
property CurrentEndX: TLazSynDisplayTokenBound read FCurrentEndX write SetCurrentEndX;
|
||||
@ -1142,7 +1140,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynSelectedColorMergeResult.AssignFrom(Src: TLazSynCustomTextAttributes);
|
||||
procedure TSynSelectedColorMergeResult.AssignFrom(Src: TLazCustomEditTextAttribute);
|
||||
var
|
||||
i: TLazSynBorderSide;
|
||||
j: TSynSelectedColorEnum;
|
||||
@ -1554,7 +1552,7 @@ begin
|
||||
AStyle := GetModifiedStyle(AStyle);
|
||||
end;
|
||||
|
||||
procedure TSynSelectedColor.AssignFrom(Src: TLazSynCustomTextAttributes);
|
||||
procedure TSynSelectedColor.AssignFrom(Src: TLazCustomEditTextAttribute);
|
||||
begin
|
||||
inherited AssignFrom(Src);
|
||||
if not (Src is TSynSelectedColor) then exit;
|
||||
|
@ -41,7 +41,7 @@ unit SynEditTypes;
|
||||
|
||||
interface
|
||||
uses
|
||||
SysUtils, types, Classes, Controls, LCLType, SynEditKeyCmds;
|
||||
SysUtils, types, Classes, Controls, LCLType, SynEditKeyCmds, LazEditTextAttributes;
|
||||
|
||||
const
|
||||
TSynSpecialChars = [#128..#255]; // MG: special chars. Meaning depends on system encoding/codepage.
|
||||
@ -220,27 +220,10 @@ type
|
||||
TSynVisibleSpecialChar = (vscSpace, vscTabAtFirst, vscTabAtLast);
|
||||
TSynVisibleSpecialChars = set of TSynVisibleSpecialChar;
|
||||
|
||||
TSynLineStyle = (
|
||||
slsSolid, // PS_SOLID pen
|
||||
slsDashed, // PS_DASH pen
|
||||
slsDotted, // PS_DOT
|
||||
slsWaved // solid wave
|
||||
);
|
||||
|
||||
TSynFrameEdges = (
|
||||
sfeNone,
|
||||
sfeAround, // frame around
|
||||
sfeBottom, // bottom part of the frame
|
||||
sfeLeft // left part of the frame
|
||||
);
|
||||
|
||||
TLazSynBorderSide = (
|
||||
bsLeft,
|
||||
bsTop,
|
||||
bsRight,
|
||||
bsBottom
|
||||
);
|
||||
TLazSynBorderSides = set of TLazSynBorderSide;
|
||||
TSynLineStyle = TLazTextAttrLineStyle;
|
||||
TSynFrameEdges = TLazTextAttrFrameEdges;
|
||||
TLazSynBorderSide = TLazTextAttrBorderSide;
|
||||
TLazSynBorderSides = TLazTextAttrBorderSides;
|
||||
|
||||
THookedCommandEvent = procedure(Sender: TObject; AfterProcessing: boolean;
|
||||
var Handled: boolean; var Command: TSynEditorCommand;
|
||||
|
@ -8,8 +8,8 @@ uses
|
||||
Classes, SysUtils,
|
||||
Graphics, LCLType, Forms, LazLoggerBase,
|
||||
// SynEdit
|
||||
LazSynEditText, SynEdit, SynEditViewedLineMap, SynEditTypes,
|
||||
SynEditMiscProcs, SynEditMiscClasses, SynEditKeyCmds, SynEditFoldedView, LazEditMiscProcs;
|
||||
LazSynEditText, SynEdit, SynEditViewedLineMap, SynEditTypes, SynEditMiscProcs,
|
||||
SynEditMiscClasses, SynEditKeyCmds, SynEditFoldedView, LazEditMiscProcs, LazEditTextAttributes;
|
||||
|
||||
type
|
||||
TLazSynEditLineWrapPlugin = class;
|
||||
|
@ -74,7 +74,7 @@ uses
|
||||
// LazUtils
|
||||
LazMethodList, LazLoggerBase, LazTracer, LazUTF8,
|
||||
// SynEdit
|
||||
SynEditTypes, SynEditMiscProcs;
|
||||
SynEditTypes, SynEditMiscProcs, LazEditTextAttributes;
|
||||
|
||||
type
|
||||
TheStockFontPatterns = 0..(1 shl (1 + Ord(High(TFontStyle))));
|
||||
|
@ -5,8 +5,8 @@ unit TestPaintColorMerging;
|
||||
interface
|
||||
|
||||
uses
|
||||
testregistry, TestBase, SynEditHighlighter, SynEditMiscClasses, SynEditTypes, Graphics,
|
||||
sysutils;
|
||||
testregistry, TestBase, SynEditHighlighter, SynEditMiscClasses, SynEditTypes,
|
||||
LazEditTextAttributes, Graphics, sysutils;
|
||||
|
||||
type
|
||||
|
||||
@ -33,7 +33,8 @@ procedure TTestPaintColorMerging.MergeAttrib;
|
||||
AnAttrib.Background := ABack;
|
||||
AnAttrib.FrameColor := AFrame;
|
||||
AnAttrib.Style := AStyle;
|
||||
AnAttrib.StyleMask := AStyleMask;
|
||||
if AnAttrib is TSynHighlighterAttributesModifier then
|
||||
AnAttrib.StyleMask := AStyleMask;
|
||||
AnAttrib.FrameEdges := AFrameSides;
|
||||
AnAttrib.FrameStyle := AFrameStyle;
|
||||
if AnAttrib is TSynSelectedColor then begin
|
||||
|
@ -7,7 +7,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, testregistry, TestBase, LazSynTextArea, SynEditTypes,
|
||||
SynEditMarkupBracket, SynEdit, SynHighlighterPosition, SynEditMiscClasses,
|
||||
SynEditMarkupBracket, SynEdit, SynHighlighterPosition, SynEditMiscClasses, LazEditTextAttributes,
|
||||
Graphics;
|
||||
|
||||
type
|
||||
|
@ -54,7 +54,7 @@ uses
|
||||
SynEditMarkupBracket, SynEditMarkupHighAll, SynEditMarkupWordGroup,
|
||||
SynEditMarkupSpecialChar,
|
||||
// LazEdit
|
||||
TextMateGrammar,
|
||||
TextMateGrammar, LazEditTextAttributes,
|
||||
// SynEdit Highlighters
|
||||
SynEditHighlighter, SynEditHighlighterFoldBase, SynHighlighterCPP,
|
||||
SynHighlighterHTML, SynHighlighterJava, SynHighlighterLFM, SynHighlighterPas,
|
||||
@ -7180,10 +7180,12 @@ begin
|
||||
aDest.FrameEdges := Src.FrameEdges;
|
||||
aDest.FrameStyle := Src.FrameStyle;
|
||||
aDest.Style := Src.Style;
|
||||
if hafStyleMask in Src.Features then
|
||||
aDest.StyleMask := Src.StyleMask
|
||||
else
|
||||
aDest.StyleMask := [low(TFontStyle)..high(TFontStyle)];
|
||||
if aDest is TLazEditTextAttributeModifier then begin
|
||||
if hafStyleMask in Src.Features then
|
||||
aDest.StyleMask := Src.StyleMask
|
||||
else
|
||||
aDest.StyleMask := [low(TFontStyle)..high(TFontStyle)];
|
||||
end;
|
||||
|
||||
if aDest is TSynHighlighterAttributesModifier then begin
|
||||
TSynHighlighterAttributesModifier(aDest).ForeAlpha := Src.ForeAlpha;
|
||||
|
@ -37,6 +37,8 @@ uses
|
||||
Graphics, Controls, Forms, ImgList,
|
||||
// LazUtils
|
||||
LazLoggerBase, LazFileUtils,
|
||||
// LazEdit
|
||||
LazEditTextAttributes,
|
||||
// Codetools
|
||||
KeywordFuncLists,
|
||||
// SynEdit
|
||||
|
@ -14,8 +14,10 @@ uses
|
||||
LazLoggerBase,
|
||||
// Codetools
|
||||
CodeToolManager, CodeCache,
|
||||
//SynEdit
|
||||
SynEdit, SynEditHighlighter, SynEditMiscClasses, SynEditTypes,
|
||||
// LazEdit
|
||||
LazEditTextAttributes,
|
||||
// SynEdit
|
||||
SynEdit, SynEditHighlighter, SynEditMiscClasses,
|
||||
// IdeIntf
|
||||
IDEWindowIntf, IDECommands, IDEImagesIntf, SrcEditorIntf, IDEOptEditorIntf,
|
||||
IdeIntfStrConsts, EditorSyntaxHighlighterDef,
|
||||
|
@ -62,6 +62,7 @@ uses
|
||||
SynEditMarkupHighAll, SynEditKeyCmds, SynEditMarkupIfDef, SynEditMiscProcs,
|
||||
SynPluginMultiCaret, SynEditPointClasses,
|
||||
SynEditMarkupFoldColoring, SynEditTextTabExpander, SynEditMouseCmds, SynEditWrappedView,
|
||||
LazEditTextAttributes,
|
||||
// IDE
|
||||
etSrcEditMarks, LazarusIDEStrConsts, SourceMarks;
|
||||
|
||||
@ -383,7 +384,7 @@ type
|
||||
procedure DoWordsChanged(Sender: TObject);
|
||||
procedure SetCustomWordTokenKind(AValue: TtkTokenKindEx);
|
||||
protected
|
||||
procedure AssignFrom(Src: TLazSynCustomTextAttributes); override;
|
||||
procedure AssignFrom(Src: TLazCustomEditTextAttribute); override;
|
||||
procedure DoClear; override;
|
||||
procedure Init; override;
|
||||
public
|
||||
@ -2167,7 +2168,7 @@ begin
|
||||
Changed;
|
||||
end;
|
||||
|
||||
procedure TSynHighlighterLazCustomPasAttribute.AssignFrom(Src: TLazSynCustomTextAttributes);
|
||||
procedure TSynHighlighterLazCustomPasAttribute.AssignFrom(Src: TLazCustomEditTextAttribute);
|
||||
begin
|
||||
inherited AssignFrom(Src);
|
||||
if Src is TSynHighlighterLazCustomPasAttribute then begin
|
||||
|
@ -12,7 +12,7 @@ uses
|
||||
// IdeIntf
|
||||
EditorSyntaxHighlighterDef,
|
||||
// SynEdit
|
||||
SynEditTypes, SynTextDrawer, SynHighlighterPas,
|
||||
SynEditTypes, SynTextDrawer, SynHighlighterPas, LazEditTextAttributes,
|
||||
// IdeConfig
|
||||
EnvironmentOpts,
|
||||
// IDE
|
||||
|
Loading…
Reference in New Issue
Block a user