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

View File

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

View File

@ -199,6 +199,11 @@ type
procedure SetMouseSelActions(const AValue: TSynEditMouseActions); virtual; abstract; procedure SetMouseSelActions(const AValue: TSynEditMouseActions); virtual; abstract;
procedure SetMouseTextActions(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 MarkupMgr: TObject read GetMarkupMgr;
property FoldedTextBuffer: TObject read GetFoldedTextBuffer; // TSynEditFoldedView 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 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; Index, PhysicalPos: integer): integer; virtual; abstract;
function PhysicalLineLength(Line: String; Index: integer): integer; virtual; abstract; function PhysicalLineLength(Line: String; Index: integer): integer; virtual; abstract;
public 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; property Lines: TStrings read GetLines write SetLines;
// See SYNEDIT_UNIMPLEMENTED_OPTIONS for deprecated Values // See SYNEDIT_UNIMPLEMENTED_OPTIONS for deprecated Values
property Options: TSynEditorOptions read FOptions write SetOptions default SYNEDIT_DEFAULT_OPTIONS; property Options: TSynEditorOptions read FOptions write SetOptions default SYNEDIT_DEFAULT_OPTIONS;

View File

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