SynEdit: remove circular dependency between SynEdit and SynGutterCodeFolding

git-svn-id: trunk@64487 -
This commit is contained in:
ondrej 2021-02-05 13:43:42 +00:00
parent e966434b1a
commit 583d01104a
4 changed files with 46 additions and 22 deletions

View File

@ -224,6 +224,8 @@ type
function GetTextArea: TLazSynTextArea; override;
protected
procedure SetBackgroundColor(AValue: TColor); virtual;
function GetExtraCharSpacing: integer;
function GetExtraLineSpacing: integer;
procedure SetExtraCharSpacing(AValue: integer); virtual;
procedure SetExtraLineSpacing(AValue: integer); virtual;
procedure SetForegroundColor(AValue: TColor); virtual;
@ -252,8 +254,8 @@ type
property Padding[Side: TLazSynBorderSide]: integer write SetPadding;
property ForegroundColor: TColor write SetForegroundColor;
property BackgroundColor: TColor write SetBackgroundColor;
property ExtraCharSpacing: integer write SetExtraCharSpacing;
property ExtraLineSpacing: integer write SetExtraLineSpacing;
property ExtraCharSpacing: integer read GetExtraCharSpacing write SetExtraCharSpacing;
property ExtraLineSpacing: integer read GetExtraLineSpacing write SetExtraLineSpacing;
property VisibleSpecialChars: TSynVisibleSpecialChars write SetVisibleSpecialChars;
property RightEdgeColumn: integer write SetRightEdgeColumn;
property RightEdgeVisible: boolean write SetRightEdgeVisible;
@ -1135,6 +1137,16 @@ begin
FRightGutterArea.Paint(ACanvas, AClip);
end;
function TLazSynSurfaceManager.GetExtraCharSpacing: integer;
begin
Result := FTextArea.ExtraCharSpacing;
end;
function TLazSynSurfaceManager.GetExtraLineSpacing: integer;
begin
Result := FTextArea.ExtraLineSpacing;
end;
procedure TLazSynSurfaceManager.DoDisplayViewChanged;
begin
FLeftGutterArea.DisplayView := DisplayView;

View File

@ -501,7 +501,6 @@ type
FLines: TSynEditStringListBase; // The real (un-mapped) line-buffer
FStrings: TStrings; // External TStrings based interface to the Textbuffer
fExtraCharSpacing: integer;
fMaxLeftChar: Integer; // 1024
FOldWidth, FOldHeight: Integer;
@ -536,7 +535,6 @@ type
FMouseActionSearchHandlerList: TSynEditMouseActionSearchList;
FMouseActionExecHandlerList: TSynEditMouseActionExecList;
FMarkList: TSynEditMarkList;
fExtraLineSpacing: integer;
FUseUTF8: boolean;
fWantTabs: boolean;
FLeftGutter, FRightGutter: TSynGutter;
@ -675,14 +673,12 @@ type
);
procedure SetCaretX(const Value: Integer);
procedure SetCaretY(const Value: Integer);
procedure SetExtraLineSpacing(const Value: integer);
procedure SetGutter(const Value: TSynGutter);
procedure SetRightGutter(const AValue: TSynGutter);
procedure RemoveHooksFromHighlighter;
procedure SetInsertCaret(const Value: TSynEditCaretType);
procedure SetInsertMode(const Value: boolean);
procedure SetKeystrokes(const Value: TSynEditKeyStrokes);
procedure SetExtraCharSpacing(const Value: integer);
procedure SetLastMouseCaret(const AValue: TPoint);
function CurrentMaxLeftChar: Integer;
function CurrentMaxLineLen: Integer;
@ -809,6 +805,11 @@ type
procedure SetMouseSelActions(const AValue: TSynEditMouseActions); override;
procedure SetMouseTextActions(AValue: TSynEditMouseActions); override;
function GetExtraCharSpacing: integer; override;
function GetExtraLineSpacing: integer; override;
procedure SetExtraCharSpacing(const Value: integer); override;
procedure SetExtraLineSpacing(const Value: integer); override;
procedure SetHighlighter(const Value: TSynCustomHighlighter); virtual;
procedure UpdateShowing; override;
procedure SetColor(Value: TColor); override;
@ -1157,8 +1158,6 @@ type
property BookMarkOptions: TSynBookMarkOpt read fBookMarkOpt write fBookMarkOpt;
property BlockIndent: integer read FBlockIndent write SetBlockIndent default 2;
property BlockTabIndent: integer read FBlockTabIndent write SetBlockTabIndent default 0;
property ExtraCharSpacing: integer read fExtraCharSpacing write SetExtraCharSpacing default 0;
property ExtraLineSpacing: integer read fExtraLineSpacing write SetExtraLineSpacing default 0;
property Highlighter: TSynCustomHighlighter read fHighlighter write SetHighlighter;
property Gutter: TSynGutter read FLeftGutter write SetGutter;
property RightGutter: TSynGutter read FRightGutter write SetRightGutter;
@ -1843,6 +1842,16 @@ begin
Result := FBlockSelection.SelectionMode;
end;
function TCustomSynEdit.GetExtraCharSpacing: integer;
begin
Result := FPaintArea.ExtraCharSpacing;
end;
function TCustomSynEdit.GetExtraLineSpacing: integer;
begin
Result := FPaintArea.ExtraLineSpacing;
end;
function TCustomSynEdit.GetFoldedCodeLineColor: TSynSelectedColor;
begin
Result := FFoldedLinesView.MarkupInfoFoldedCodeLine;
@ -6659,8 +6668,7 @@ end;
procedure TCustomSynEdit.SetExtraCharSpacing(const Value: integer);
begin
if fExtraCharSpacing=Value then exit;
fExtraCharSpacing := Value;
if ExtraCharSpacing=Value then exit;
FPaintArea.ExtraCharSpacing := Value;
FontChanged(self);
end;
@ -7764,8 +7772,7 @@ end;
procedure TCustomSynEdit.SetExtraLineSpacing(const Value: integer);
begin
if fExtraLineSpacing=Value then exit;
fExtraLineSpacing := Value;
if ExtraLineSpacing=Value then exit;
FPaintArea.ExtraLineSpacing := Value;
FontChanged(self);
end;
@ -8581,7 +8588,7 @@ begin
if Assigned(fHighlighter) then
for i := 0 to Pred(fHighlighter.AttrCount) do
fTextDrawer.BaseStyle := fHighlighter.Attribute[i].Style;
fTextDrawer.CharExtra := fExtraCharSpacing;
fTextDrawer.CharExtra := ExtraCharSpacing;
FUseUTF8:=fTextDrawer.UseUTF8;
FLines.IsUtf8 := FUseUTF8;

View File

@ -199,6 +199,11 @@ type
procedure SetMouseSelActions(const AValue: TSynEditMouseActions); virtual; abstract;
procedure SetMouseTextActions(AValue: TSynEditMouseActions); virtual; abstract;
function GetExtraCharSpacing: integer; virtual; abstract;
function GetExtraLineSpacing: integer; virtual; abstract;
procedure SetExtraCharSpacing(const aExtraCharSpacing: integer); virtual; abstract;
procedure SetExtraLineSpacing(const aExtraLineSpacing: integer); 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
@ -305,6 +310,8 @@ type
Index, PhysicalPos: integer): integer; virtual; abstract;
function PhysicalLineLength(Line: String; Index: integer): integer; virtual; abstract;
public
property ExtraCharSpacing: integer read GetExtraCharSpacing write SetExtraCharSpacing default 0;
property ExtraLineSpacing: integer read GetExtraLineSpacing write SetExtraLineSpacing default 0;
property Lines: TStrings read GetLines write SetLines;
// See SYNEDIT_UNIMPLEMENTED_OPTIONS for deprecated Values
property Options: TSynEditorOptions read FOptions write SetOptions default SYNEDIT_DEFAULT_OPTIONS;

View File

@ -123,8 +123,6 @@ type
end;
implementation
uses
SynEdit;
var
GlobalPopUpImageList: TSynGutterImageList = nil;
@ -439,9 +437,9 @@ begin
tmp := FoldTypeForLine(ScrLine);
case tmp of
cfCollapsedFold, cfCollapsedHide:
Result := HandleActionProc(FMouseActionsCollapsed.GetActionsForOptions(TCustomSynEdit(SynEdit).MouseOptions), AnInfo);
Result := HandleActionProc(FMouseActionsCollapsed.GetActionsForOptions(SynEdit.MouseOptions), AnInfo);
cfFoldStart, cfHideStart:
Result := HandleActionProc(FMouseActionsExpanded.GetActionsForOptions(TCustomSynEdit(SynEdit).MouseOptions), AnInfo);
Result := HandleActionProc(FMouseActionsExpanded.GetActionsForOptions(SynEdit.MouseOptions), AnInfo);
end;
if not Result then
@ -533,9 +531,9 @@ end;
procedure TSynGutterCodeFolding.ResetMouseActions;
begin
inherited;
FMouseActionsExpanded.Options := TCustomSynEdit(SynEdit).MouseOptions;
FMouseActionsExpanded.Options := SynEdit.MouseOptions;
FMouseActionsExpanded.ResetUserActions;
FMouseActionsCollapsed.Options := TCustomSynEdit(SynEdit).MouseOptions;
FMouseActionsCollapsed.Options := SynEdit.MouseOptions;
FMouseActionsCollapsed.ResetUserActions;
end;
@ -623,7 +621,7 @@ function TSynGutterCodeFolding.PreferedWidth: Integer;
const PrefFullWidth = 10;
begin
Result :=
Max(PrefFullWidth div 2, Min(PrefFullWidth, TCustomSynEdit(SynEdit).LineHeight - cNodeOffset));
Max(PrefFullWidth div 2, Min(PrefFullWidth, SynEdit.LineHeight - cNodeOffset));
end;
procedure TSynGutterCodeFolding.Paint(Canvas : TCanvas; AClip : TRect; FirstLine, LastLine : integer);
@ -728,8 +726,8 @@ var
begin
if not Visible then exit;
LineHeight := TCustomSynEdit(SynEdit).LineHeight;
TextHeight := LineHeight - Max(0, TCustomSynEdit(SynEdit).ExtraLineSpacing);
LineHeight := SynEdit.LineHeight;
TextHeight := LineHeight - Max(0, SynEdit.ExtraLineSpacing);
LineOffset := 0;
if (FirstLine > 0) and
(FoldView.FoldType[FirstLine-1] - [cfFoldBody] = [cfFoldEnd]) then