SynEdit: remove circular dependency between SynEdit and SynEditMarkupFoldColoring

git-svn-id: trunk@64479 -
This commit is contained in:
ondrej 2021-02-05 13:16:45 +00:00
parent 5decda7645
commit 3afd98807d
3 changed files with 37 additions and 30 deletions

View File

@ -1001,14 +1001,14 @@ type
procedure InvalidateLines(FirstLine, LastLine: integer); override;
// Byte to Char
function LogicalToPhysicalPos(const p: TPoint): TPoint;
function LogicalToPhysicalPos(const p: TPoint): TPoint; override;
function LogicalToPhysicalCol(const Line: String; Index, LogicalPos
: integer): integer;
: integer): integer; override;
// Char to Byte
function PhysicalToLogicalPos(const p: TPoint): TPoint;
function PhysicalToLogicalPos(const p: TPoint): TPoint; override;
function PhysicalToLogicalCol(const Line: string;
Index, PhysicalPos: integer): integer;
function PhysicalLineLength(Line: String; Index: integer): integer;
Index, PhysicalPos: integer): integer; override;
function PhysicalLineLength(Line: String; Index: integer): integer; override;
(* from SynMemo - NOT recommended to use - Extremly slow code
SynEdit (and SynMemo) is a Linebased Editor and not meant to be accessed as a contineous text

View File

@ -51,9 +51,14 @@ interface
uses
Classes, SysUtils, Graphics, SynEditMarkup, SynEditMiscClasses, Controls,
LCLProc, LCLType, SynEditHighlighter,
SynEditHighlighterFoldBase, LazSynEditText, SynEditTextBase, SynEditTypes
{$IFDEF WithSynMarkupFoldColorDebugGutter}, SynGutterBase, SynTextDrawer{$ENDIF}
;
SynEditHighlighterFoldBase, LazSynEditText, SynEditTextBase, SynEditTypes,
{$IFDEF WithSynMarkupFoldColorDebugGutter}SynGutterBase, SynTextDrawer,{$ENDIF}
SynEditMiscProcs,
{$IFDEF SynEditMarkupFoldColoringDebug}
SynHighlighterPas,
strutils,
{$endif}
Dialogs;
type
@ -197,14 +202,6 @@ type
end;
implementation
uses
SynEdit,
SynEditMiscProcs,
{$IFDEF SynEditMarkupFoldColoringDebug}
SynHighlighterPas,
strutils,
{$endif}
Dialogs;
{ TMarkupFoldColorsLineColor }
@ -325,15 +322,15 @@ begin
TextDrawer.BeginDrawing(dc);
try
TextDrawer.SetBackColor(Gutter.Color);
TextDrawer.SetForeColor(TCustomSynEdit(SynEdit).Font.Color);
TextDrawer.SetForeColor(SynEdit.Font.Color);
TextDrawer.SetFrameColor(clNone);
with AClip do
TextDrawer.ExtTextOut(Left, Top, ETO_OPAQUE, AClip, nil, 0);
rcLine := AClip;
rcLine.Bottom := AClip.Top;
LineHeight := TCustomSynEdit(SynEdit).LineHeight;
c := TCustomSynEdit(SynEdit).Lines.Count;
LineHeight := SynEdit.LineHeight;
c := SynEdit.Lines.Count;
for i := FirstLine to LastLine do
begin
iLine := FoldView.DisplayNumber[i];
@ -385,13 +382,13 @@ begin
inherited Create(pSynEdit);
{$IFDEF WithSynMarkupFoldColorDebugGutter}
FDebugGutter := TIDESynMarkupFoldColorDebugGutter.Create(TSynEdit(pSynEdit).RightGutter.Parts);
FDebugGutter := TIDESynMarkupFoldColorDebugGutter.Create(pSynEdit.RightGutter.Parts);
FDebugGutter.FOwner := Self;
{$ENDIF}
FColumnCache := TSynEditMarkupFoldColorsColumnCache.Create;
fHighlighter := TSynCustomFoldHighlighter(TCustomSynEdit(SynEdit).Highlighter);
fHighlighter := TSynCustomFoldHighlighter(SynEdit.Highlighter);
if Assigned(fHighlighter)
and not (fHighlighter is TSynCustomFoldHighlighter) then
fHighlighter := nil;
@ -555,7 +552,7 @@ begin
and (l[p] in [#9, #32]) do inc(p);
if p > s then
exit(high(Result));
Result := TCustomSynEdit(SynEdit).LogicalToPhysicalPos(Point(p, toPos(pIndex))).x;
Result := SynEdit.LogicalToPhysicalPos(Point(p, toPos(pIndex))).x;
end;
procedure TSynEditMarkupFoldColors.TextBufferChanged(pSender: TObject);
@ -768,8 +765,8 @@ var
// or at least has less characters as vertical line is on
if not(sfaCloseForNextLine in lCurNode.FoldAction) then begin
Result := True;
lPhysX := TCustomSynEdit(SynEdit).LogicalToPhysicalPos(Point(ToPos(lCurNode.LogXStart), ToPos(lCurNode.LineIndex))).x;
lPhysX2 := TCustomSynEdit(SynEdit).LogicalToPhysicalPos(Point(ToPos(lCurNode.LogXEnd), ToPos(lCurNode.LineIndex))).x;
lPhysX := SynEdit.LogicalToPhysicalPos(Point(ToPos(lCurNode.LogXStart), ToPos(lCurNode.LineIndex))).x;
lPhysX2 := SynEdit.LogicalToPhysicalPos(Point(ToPos(lCurNode.LogXEnd), ToPos(lCurNode.LineIndex))).x;
if lCurNode.LogXStart < lCurNode.LogXEnd then begin
{$IFDEF SynEditMarkupFoldColoringDebug}
//DebugLn(' %d < %d', [lCurNode.LogXStart, lCurNode.LogXEnd]);
@ -988,7 +985,7 @@ var
begin
if not Assigned(fHighlighter)
and not (TCustomSynEdit(Self.SynEdit).Highlighter is TSynCustomFoldHighlighter) then
and not (SynEdit.Highlighter is TSynCustomFoldHighlighter) then
exit;
{$IFDEF SynEditMarkupFoldColoringDebug}
@ -1104,7 +1101,7 @@ begin
lEndLine := pEndLine;
FColumnCache[ToIdx(lEndLine)] := FirstCharacterColumn[ToIdx(lEndLine)];
x := FColumnCache[ToIdx(lEndLine)];
lBottomLine := TCustomSynEdit(SynEdit).TopLine + TCustomSynEdit(SynEdit).LinesInWindow;
lBottomLine := SynEdit.TopLine + SynEdit.LinesInWindow;
fNestList.Clear;
fNestList2.Clear;
@ -1222,7 +1219,7 @@ end;
procedure TSynEditMarkupFoldColors.HighlightChanged(pSender: TSynEditStrings;
pIndex, pCount: Integer);
var
newHighlighter: TSynCustomHighlighter;
newHighlighter: TSynCustomFoldHighlighter;
begin
{$IFDEF SynEditMarkupFoldColoringDebug}
//DebugLn(' HighlightChanged: aIndex=%d aCount=%d', [aIndex, aCount]);
@ -1232,9 +1229,9 @@ begin
or (pCount <> -1) then
exit;
newHighlighter := TCustomSynEdit(self.SynEdit).Highlighter;
if Assigned(newHighlighter)
and not (newHighlighter is TSynCustomFoldHighlighter) then
if SynEdit.Highlighter is TSynCustomFoldHighlighter then
newHighlighter := TSynCustomFoldHighlighter(SynEdit.Highlighter)
else
newHighlighter := nil;
if (newHighlighter = fHighlighter) then

View File

@ -276,6 +276,16 @@ type
procedure InvalidateLine(Line: integer); virtual; abstract;
procedure InvalidateGutterLines(FirstLine, LastLine: integer); virtual; abstract; // Currently invalidates full line => that may change
procedure InvalidateLines(FirstLine, LastLine: integer); virtual; abstract;
public
// Byte to Char
function LogicalToPhysicalPos(const p: TPoint): TPoint; virtual; abstract;
function LogicalToPhysicalCol(const Line: String; Index, LogicalPos
: integer): integer; virtual; abstract;
// Char to Byte
function PhysicalToLogicalPos(const p: TPoint): TPoint; virtual; abstract;
function PhysicalToLogicalCol(const Line: string;
Index, PhysicalPos: integer): integer; virtual; abstract;
function PhysicalLineLength(Line: String; Index: integer): integer; virtual; abstract;
public
property Lines: TStrings read GetLines write SetLines;
// See SYNEDIT_UNIMPLEMENTED_OPTIONS for deprecated Values