diff --git a/components/synedit/synedit.pp b/components/synedit/synedit.pp index b5f224d62e..9eb6f3279b 100644 --- a/components/synedit/synedit.pp +++ b/components/synedit/synedit.pp @@ -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 diff --git a/components/synedit/syneditmarkupfoldcoloring.pas b/components/synedit/syneditmarkupfoldcoloring.pas index 193fe46321..3e2763c4c5 100644 --- a/components/synedit/syneditmarkupfoldcoloring.pas +++ b/components/synedit/syneditmarkupfoldcoloring.pas @@ -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 diff --git a/components/synedit/syneditmiscclasses.pp b/components/synedit/syneditmiscclasses.pp index 0f7a253cdf..fabf81edb3 100644 --- a/components/synedit/syneditmiscclasses.pp +++ b/components/synedit/syneditmiscclasses.pp @@ -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