SynEdit: remove circular dependency between SynEdit and SynGutterLineNumber

git-svn-id: trunk@64488 -
This commit is contained in:
ondrej 2021-02-05 13:48:38 +00:00
parent 583d01104a
commit 0060c09037
3 changed files with 27 additions and 19 deletions

View File

@ -625,12 +625,9 @@ type
function FindHookedCmdEvent(AHandlerProc: THookedCommandEvent): integer;
function GetBracketHighlightStyle: TSynEditBracketHighlightStyle;
function GetCanPaste: Boolean;
function GetCaretXY: TPoint;
function GetFoldedCodeColor: TSynSelectedColor;
function GetMarkup(Index: integer): TSynEditMarkup;
function GetMarkupByClass(Index: TSynEditMarkupClass): TSynEditMarkup;
function GetCaretX : Integer;
function GetCaretY : Integer;
function GetCaretUndo: TSynEditUndoItem;
function GetHighlightAllColor : TSynSelectedColor;
function GetIncrementColor : TSynSelectedColor;
@ -646,8 +643,6 @@ type
function GetHookedCommandHandlersCount: integer;
function GetLineText: string;
function GetCharLen(const Line: string; CharStartPos: integer): integer; // TODO: deprecated
function GetLogicalCaretXY: TPoint;
procedure SetLogicalCaretXY(const NewLogCaretXY: TPoint);
procedure SetBeautifier(NewBeautifier: TSynCustomBeautifier);
function GetMaxUndo: Integer;
procedure SetTrimSpaceType(const AValue: TSynEditStringTrimmingType);
@ -671,8 +666,6 @@ type
Mode: TSynSelectionMode = smCurrent;
MakeSelectionVisible: Boolean = False
);
procedure SetCaretX(const Value: Integer);
procedure SetCaretY(const Value: Integer);
procedure SetGutter(const Value: TSynGutter);
procedure SetRightGutter(const AValue: TSynGutter);
procedure RemoveHooksFromHighlighter;
@ -798,6 +791,15 @@ type
procedure SetLeftChar(Value: Integer); override;
procedure SetTopLine(Value: Integer); override;
function GetCaretX : Integer; override;
function GetCaretY : Integer; override;
function GetCaretXY: TPoint; override;
procedure SetCaretX(const Value: Integer); override;
procedure SetCaretY(const Value: Integer); override;
procedure SetCaretXY(Value: TPoint); override;
function GetLogicalCaretXY: TPoint; override;
procedure SetLogicalCaretXY(const NewLogCaretXY: TPoint); override;
function GetMouseActions: TSynEditMouseActions; override;
function GetMouseSelActions: TSynEditMouseActions; override;
function GetMouseTextActions: TSynEditMouseActions; override;
@ -850,7 +852,6 @@ type
function PrevWordLogicalPos(ABoundary: TLazSynWordBoundary = swbWordBegin): TPoint;
procedure RecalcCharExtent;
procedure RedoItem(Item: TSynEditUndoItem);
procedure SetCaretXY(Value: TPoint);
procedure CaretChanged(Sender: TObject);
procedure SetMouseOptions(AValue: TSynEditorMouseOptions); override;
procedure SetName(const Value: TComponentName); override;
@ -903,11 +904,6 @@ type
procedure MoveCaretIgnoreEOL(const NewCaret: TPoint);
procedure MoveLogicalCaretIgnoreEOL(const NewLogCaret: TPoint);
property CaretX: Integer read GetCaretX write SetCaretX;
property CaretY: Integer read GetCaretY write SetCaretY;
property CaretXY: TPoint read GetCaretXY write SetCaretXY;// screen position
property LogicalCaretXY: TPoint read GetLogicalCaretXY write SetLogicalCaretXY;
// Selection
procedure ClearSelection;
procedure SelectAll;

View File

@ -204,6 +204,15 @@ type
procedure SetExtraCharSpacing(const aExtraCharSpacing: integer); virtual; abstract;
procedure SetExtraLineSpacing(const aExtraLineSpacing: integer); virtual; abstract;
function GetCaretX : Integer; virtual; abstract;
function GetCaretY : Integer; virtual; abstract;
function GetCaretXY: TPoint; virtual; abstract;
procedure SetCaretX(const Value: Integer); virtual; abstract;
procedure SetCaretY(const Value: Integer); virtual; abstract;
procedure SetCaretXY(Value: TPoint); virtual; abstract;
function GetLogicalCaretXY: TPoint; virtual; abstract;
procedure SetLogicalCaretXY(const NewLogCaretXY: TPoint); virtual; abstract;
property MarkupMgr: TObject read GetMarkupMgr;
property FoldedTextBuffer: TObject read GetFoldedTextBuffer; // TSynEditFoldedView
property ViewedTextBuffer: TSynEditStringsLinked read GetViewedTextBuffer; // As viewed internally (with uncommited spaces / TODO: expanded tabs, folds). This may change, use with care
@ -318,6 +327,11 @@ type
property Options2: TSynEditorOptions2 read FOptions2 write SetOptions2 default SYNEDIT_DEFAULT_OPTIONS2;
property ReadOnly: Boolean read GetReadOnly write SetReadOnly default FALSE;
property CaretX: Integer read GetCaretX write SetCaretX;
property CaretY: Integer read GetCaretY write SetCaretY;
property CaretXY: TPoint read GetCaretXY write SetCaretXY;// screen position
property LogicalCaretXY: TPoint read GetLogicalCaretXY write SetLogicalCaretXY;
property CharsInWindow: Integer read GetCharsInWindow;
property CharWidth: integer read GetCharWidth;
property LeftChar: Integer read GetLeftChar write SetLeftChar;

View File

@ -68,8 +68,6 @@ type
end;
implementation
uses
SynEdit;
{ TSynGutterLineNumber }
@ -244,8 +242,8 @@ var
begin
if not Visible then exit;
LineHeight := TCustomSynEdit(SynEdit).LineHeight;
c := TCustomSynEdit(SynEdit).Lines.Count;
LineHeight := SynEdit.LineHeight;
c := SynEdit.Lines.Count;
t := ToIdx(GutterArea.TextArea.TopLine);
// Changed to use fTextDrawer.BeginDrawing and fTextDrawer.EndDrawing only
// when absolutely necessary. Note: Never change brush / pen / font of the
@ -265,7 +263,7 @@ begin
if MarkupInfo.Foreground <> clNone then
fTextDrawer.SetForeColor(MarkupInfo.Foreground)
else
fTextDrawer.SetForeColor(TCustomSynEdit(SynEdit).Font.Color);
fTextDrawer.SetForeColor(SynEdit.Font.Color);
fTextDrawer.SetFrameColor(MarkupInfo.FrameColor);
fTextDrawer.Style := MarkupInfo.Style;
// prepare the rect initially
@ -281,7 +279,7 @@ begin
// line number is not the first, the last, the current line
// or a multiple of ShowOnlyLineNumbersMultiplesOf
LineInfo.ShowDot := ((iLine mod ShowOnlyLineNumbersMultiplesOf) <> 0)
and (iLine <> TCustomSynEdit(SynEdit).CaretY) and (iLine <> 1)
and (iLine <> SynEdit.CaretY) and (iLine <> 1)
and (iLine <> SynEdit.Lines.Count);
// Get the formatted line number or dot
if Assigned(FOnFormatLineNumber) then begin