mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 16:49:07 +02:00
SynEdit: remove circular dependency between SynEdit and SynEditMarkupFoldColoring
git-svn-id: trunk@64479 -
This commit is contained in:
parent
5decda7645
commit
3afd98807d
@ -1001,14 +1001,14 @@ type
|
|||||||
procedure InvalidateLines(FirstLine, LastLine: integer); override;
|
procedure InvalidateLines(FirstLine, LastLine: integer); override;
|
||||||
|
|
||||||
// Byte to Char
|
// Byte to Char
|
||||||
function LogicalToPhysicalPos(const p: TPoint): TPoint;
|
function LogicalToPhysicalPos(const p: TPoint): TPoint; override;
|
||||||
function LogicalToPhysicalCol(const Line: String; Index, LogicalPos
|
function LogicalToPhysicalCol(const Line: String; Index, LogicalPos
|
||||||
: integer): integer;
|
: integer): integer; override;
|
||||||
// Char to Byte
|
// Char to Byte
|
||||||
function PhysicalToLogicalPos(const p: TPoint): TPoint;
|
function PhysicalToLogicalPos(const p: TPoint): TPoint; override;
|
||||||
function PhysicalToLogicalCol(const Line: string;
|
function PhysicalToLogicalCol(const Line: string;
|
||||||
Index, PhysicalPos: integer): integer;
|
Index, PhysicalPos: integer): integer; override;
|
||||||
function PhysicalLineLength(Line: String; Index: integer): integer;
|
function PhysicalLineLength(Line: String; Index: integer): integer; override;
|
||||||
|
|
||||||
(* from SynMemo - NOT recommended to use - Extremly slow code
|
(* 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
|
SynEdit (and SynMemo) is a Linebased Editor and not meant to be accessed as a contineous text
|
||||||
|
@ -51,9 +51,14 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, Graphics, SynEditMarkup, SynEditMiscClasses, Controls,
|
Classes, SysUtils, Graphics, SynEditMarkup, SynEditMiscClasses, Controls,
|
||||||
LCLProc, LCLType, SynEditHighlighter,
|
LCLProc, LCLType, SynEditHighlighter,
|
||||||
SynEditHighlighterFoldBase, LazSynEditText, SynEditTextBase, SynEditTypes
|
SynEditHighlighterFoldBase, LazSynEditText, SynEditTextBase, SynEditTypes,
|
||||||
{$IFDEF WithSynMarkupFoldColorDebugGutter}, SynGutterBase, SynTextDrawer{$ENDIF}
|
{$IFDEF WithSynMarkupFoldColorDebugGutter}SynGutterBase, SynTextDrawer,{$ENDIF}
|
||||||
;
|
SynEditMiscProcs,
|
||||||
|
{$IFDEF SynEditMarkupFoldColoringDebug}
|
||||||
|
SynHighlighterPas,
|
||||||
|
strutils,
|
||||||
|
{$endif}
|
||||||
|
Dialogs;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -197,14 +202,6 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses
|
|
||||||
SynEdit,
|
|
||||||
SynEditMiscProcs,
|
|
||||||
{$IFDEF SynEditMarkupFoldColoringDebug}
|
|
||||||
SynHighlighterPas,
|
|
||||||
strutils,
|
|
||||||
{$endif}
|
|
||||||
Dialogs;
|
|
||||||
|
|
||||||
{ TMarkupFoldColorsLineColor }
|
{ TMarkupFoldColorsLineColor }
|
||||||
|
|
||||||
@ -325,15 +322,15 @@ begin
|
|||||||
TextDrawer.BeginDrawing(dc);
|
TextDrawer.BeginDrawing(dc);
|
||||||
try
|
try
|
||||||
TextDrawer.SetBackColor(Gutter.Color);
|
TextDrawer.SetBackColor(Gutter.Color);
|
||||||
TextDrawer.SetForeColor(TCustomSynEdit(SynEdit).Font.Color);
|
TextDrawer.SetForeColor(SynEdit.Font.Color);
|
||||||
TextDrawer.SetFrameColor(clNone);
|
TextDrawer.SetFrameColor(clNone);
|
||||||
with AClip do
|
with AClip do
|
||||||
TextDrawer.ExtTextOut(Left, Top, ETO_OPAQUE, AClip, nil, 0);
|
TextDrawer.ExtTextOut(Left, Top, ETO_OPAQUE, AClip, nil, 0);
|
||||||
|
|
||||||
rcLine := AClip;
|
rcLine := AClip;
|
||||||
rcLine.Bottom := AClip.Top;
|
rcLine.Bottom := AClip.Top;
|
||||||
LineHeight := TCustomSynEdit(SynEdit).LineHeight;
|
LineHeight := SynEdit.LineHeight;
|
||||||
c := TCustomSynEdit(SynEdit).Lines.Count;
|
c := SynEdit.Lines.Count;
|
||||||
for i := FirstLine to LastLine do
|
for i := FirstLine to LastLine do
|
||||||
begin
|
begin
|
||||||
iLine := FoldView.DisplayNumber[i];
|
iLine := FoldView.DisplayNumber[i];
|
||||||
@ -385,13 +382,13 @@ begin
|
|||||||
inherited Create(pSynEdit);
|
inherited Create(pSynEdit);
|
||||||
|
|
||||||
{$IFDEF WithSynMarkupFoldColorDebugGutter}
|
{$IFDEF WithSynMarkupFoldColorDebugGutter}
|
||||||
FDebugGutter := TIDESynMarkupFoldColorDebugGutter.Create(TSynEdit(pSynEdit).RightGutter.Parts);
|
FDebugGutter := TIDESynMarkupFoldColorDebugGutter.Create(pSynEdit.RightGutter.Parts);
|
||||||
FDebugGutter.FOwner := Self;
|
FDebugGutter.FOwner := Self;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
FColumnCache := TSynEditMarkupFoldColorsColumnCache.Create;
|
FColumnCache := TSynEditMarkupFoldColorsColumnCache.Create;
|
||||||
|
|
||||||
fHighlighter := TSynCustomFoldHighlighter(TCustomSynEdit(SynEdit).Highlighter);
|
fHighlighter := TSynCustomFoldHighlighter(SynEdit.Highlighter);
|
||||||
if Assigned(fHighlighter)
|
if Assigned(fHighlighter)
|
||||||
and not (fHighlighter is TSynCustomFoldHighlighter) then
|
and not (fHighlighter is TSynCustomFoldHighlighter) then
|
||||||
fHighlighter := nil;
|
fHighlighter := nil;
|
||||||
@ -555,7 +552,7 @@ begin
|
|||||||
and (l[p] in [#9, #32]) do inc(p);
|
and (l[p] in [#9, #32]) do inc(p);
|
||||||
if p > s then
|
if p > s then
|
||||||
exit(high(Result));
|
exit(high(Result));
|
||||||
Result := TCustomSynEdit(SynEdit).LogicalToPhysicalPos(Point(p, toPos(pIndex))).x;
|
Result := SynEdit.LogicalToPhysicalPos(Point(p, toPos(pIndex))).x;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynEditMarkupFoldColors.TextBufferChanged(pSender: TObject);
|
procedure TSynEditMarkupFoldColors.TextBufferChanged(pSender: TObject);
|
||||||
@ -768,8 +765,8 @@ var
|
|||||||
// or at least has less characters as vertical line is on
|
// or at least has less characters as vertical line is on
|
||||||
if not(sfaCloseForNextLine in lCurNode.FoldAction) then begin
|
if not(sfaCloseForNextLine in lCurNode.FoldAction) then begin
|
||||||
Result := True;
|
Result := True;
|
||||||
lPhysX := TCustomSynEdit(SynEdit).LogicalToPhysicalPos(Point(ToPos(lCurNode.LogXStart), ToPos(lCurNode.LineIndex))).x;
|
lPhysX := SynEdit.LogicalToPhysicalPos(Point(ToPos(lCurNode.LogXStart), ToPos(lCurNode.LineIndex))).x;
|
||||||
lPhysX2 := TCustomSynEdit(SynEdit).LogicalToPhysicalPos(Point(ToPos(lCurNode.LogXEnd), ToPos(lCurNode.LineIndex))).x;
|
lPhysX2 := SynEdit.LogicalToPhysicalPos(Point(ToPos(lCurNode.LogXEnd), ToPos(lCurNode.LineIndex))).x;
|
||||||
if lCurNode.LogXStart < lCurNode.LogXEnd then begin
|
if lCurNode.LogXStart < lCurNode.LogXEnd then begin
|
||||||
{$IFDEF SynEditMarkupFoldColoringDebug}
|
{$IFDEF SynEditMarkupFoldColoringDebug}
|
||||||
//DebugLn(' %d < %d', [lCurNode.LogXStart, lCurNode.LogXEnd]);
|
//DebugLn(' %d < %d', [lCurNode.LogXStart, lCurNode.LogXEnd]);
|
||||||
@ -988,7 +985,7 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
if not Assigned(fHighlighter)
|
if not Assigned(fHighlighter)
|
||||||
and not (TCustomSynEdit(Self.SynEdit).Highlighter is TSynCustomFoldHighlighter) then
|
and not (SynEdit.Highlighter is TSynCustomFoldHighlighter) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
{$IFDEF SynEditMarkupFoldColoringDebug}
|
{$IFDEF SynEditMarkupFoldColoringDebug}
|
||||||
@ -1104,7 +1101,7 @@ begin
|
|||||||
lEndLine := pEndLine;
|
lEndLine := pEndLine;
|
||||||
FColumnCache[ToIdx(lEndLine)] := FirstCharacterColumn[ToIdx(lEndLine)];
|
FColumnCache[ToIdx(lEndLine)] := FirstCharacterColumn[ToIdx(lEndLine)];
|
||||||
x := FColumnCache[ToIdx(lEndLine)];
|
x := FColumnCache[ToIdx(lEndLine)];
|
||||||
lBottomLine := TCustomSynEdit(SynEdit).TopLine + TCustomSynEdit(SynEdit).LinesInWindow;
|
lBottomLine := SynEdit.TopLine + SynEdit.LinesInWindow;
|
||||||
|
|
||||||
fNestList.Clear;
|
fNestList.Clear;
|
||||||
fNestList2.Clear;
|
fNestList2.Clear;
|
||||||
@ -1222,7 +1219,7 @@ end;
|
|||||||
procedure TSynEditMarkupFoldColors.HighlightChanged(pSender: TSynEditStrings;
|
procedure TSynEditMarkupFoldColors.HighlightChanged(pSender: TSynEditStrings;
|
||||||
pIndex, pCount: Integer);
|
pIndex, pCount: Integer);
|
||||||
var
|
var
|
||||||
newHighlighter: TSynCustomHighlighter;
|
newHighlighter: TSynCustomFoldHighlighter;
|
||||||
begin
|
begin
|
||||||
{$IFDEF SynEditMarkupFoldColoringDebug}
|
{$IFDEF SynEditMarkupFoldColoringDebug}
|
||||||
//DebugLn(' HighlightChanged: aIndex=%d aCount=%d', [aIndex, aCount]);
|
//DebugLn(' HighlightChanged: aIndex=%d aCount=%d', [aIndex, aCount]);
|
||||||
@ -1232,9 +1229,9 @@ begin
|
|||||||
or (pCount <> -1) then
|
or (pCount <> -1) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
newHighlighter := TCustomSynEdit(self.SynEdit).Highlighter;
|
if SynEdit.Highlighter is TSynCustomFoldHighlighter then
|
||||||
if Assigned(newHighlighter)
|
newHighlighter := TSynCustomFoldHighlighter(SynEdit.Highlighter)
|
||||||
and not (newHighlighter is TSynCustomFoldHighlighter) then
|
else
|
||||||
newHighlighter := nil;
|
newHighlighter := nil;
|
||||||
|
|
||||||
if (newHighlighter = fHighlighter) then
|
if (newHighlighter = fHighlighter) then
|
||||||
|
@ -276,6 +276,16 @@ type
|
|||||||
procedure InvalidateLine(Line: integer); virtual; abstract;
|
procedure InvalidateLine(Line: integer); virtual; abstract;
|
||||||
procedure InvalidateGutterLines(FirstLine, LastLine: integer); virtual; abstract; // Currently invalidates full line => that may change
|
procedure InvalidateGutterLines(FirstLine, LastLine: integer); virtual; abstract; // Currently invalidates full line => that may change
|
||||||
procedure InvalidateLines(FirstLine, LastLine: integer); virtual; abstract;
|
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
|
public
|
||||||
property Lines: TStrings read GetLines write SetLines;
|
property Lines: TStrings read GetLines write SetLines;
|
||||||
// See SYNEDIT_UNIMPLEMENTED_OPTIONS for deprecated Values
|
// See SYNEDIT_UNIMPLEMENTED_OPTIONS for deprecated Values
|
||||||
|
Loading…
Reference in New Issue
Block a user