mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 14:38:01 +02:00
SynEdit: remove circular dependency between SynGutterBase and SynEdit
git-svn-id: trunk@64458 -
This commit is contained in:
parent
b63e036f48
commit
d8a8497788
@ -134,8 +134,6 @@ uses
|
||||
SynEditTextBidiChars;
|
||||
|
||||
const
|
||||
ScrollBarWidth=0;
|
||||
|
||||
// SynDefaultFont is determined in InitSynDefaultFont()
|
||||
SynDefaultFontName: String = '';
|
||||
SynDefaultFontHeight: Integer = 13;
|
||||
@ -364,8 +362,6 @@ const
|
||||
eoAcceptDragDropEditing
|
||||
];
|
||||
|
||||
SYNEDIT_DEFAULT_MOUSE_OPTIONS = [];
|
||||
|
||||
SYNEDIT_DEFAULT_VISIBLESPECIALCHARS = [
|
||||
vscSpace,
|
||||
vscTabAtLast
|
||||
@ -665,7 +661,6 @@ type
|
||||
fStateFlags: TSynStateFlags;
|
||||
FOptions: TSynEditorOptions;
|
||||
FOptions2: TSynEditorOptions2;
|
||||
FMouseOptions: TSynEditorMouseOptions;
|
||||
fStatusChanges: TSynStatusChanges;
|
||||
fTSearch: TSynEditSearch;
|
||||
fHookedCommandHandlers: TList;
|
||||
@ -841,7 +836,6 @@ type
|
||||
procedure UpdateOptions;
|
||||
procedure SetOptions2(const Value: TSynEditorOptions2);
|
||||
procedure UpdateOptions2;
|
||||
procedure SetMouseOptions(AValue: TSynEditorMouseOptions);
|
||||
procedure UpdateMouseOptions;
|
||||
procedure SetOverwriteCaret(const Value: TSynEditCaretType);
|
||||
procedure SetRightEdge(Value: Integer);
|
||||
@ -978,6 +972,7 @@ type
|
||||
procedure RedoItem(Item: TSynEditUndoItem);
|
||||
procedure SetCaretXY(Value: TPoint);
|
||||
procedure CaretChanged(Sender: TObject);
|
||||
procedure SetMouseOptions(AValue: TSynEditorMouseOptions); override;
|
||||
procedure SetName(const Value: TComponentName); override;
|
||||
procedure SetReadOnly(Value: boolean); virtual;
|
||||
procedure SetSelTextPrimitive(PasteMode: TSynSelectionMode; Value: PChar;
|
||||
@ -1211,6 +1206,7 @@ type
|
||||
procedure WndProc(var Msg: TMessage); override;
|
||||
procedure EraseBackground(DC: HDC); override;
|
||||
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
|
||||
function FindGutterFromGutterPartList(const APartList: TObject): TObject; override;
|
||||
public
|
||||
procedure FindMatchingBracket; virtual;
|
||||
function FindMatchingBracket(PhysStartBracket: TPoint;
|
||||
@ -1307,8 +1303,6 @@ type
|
||||
// See SYNEDIT_UNIMPLEMENTED_OPTIONS for deprecated Values
|
||||
property Options: TSynEditorOptions read FOptions write SetOptions default SYNEDIT_DEFAULT_OPTIONS;
|
||||
property Options2: TSynEditorOptions2 read FOptions2 write SetOptions2 default SYNEDIT_DEFAULT_OPTIONS2;
|
||||
property MouseOptions: TSynEditorMouseOptions read FMouseOptions write SetMouseOptions
|
||||
default SYNEDIT_DEFAULT_MOUSE_OPTIONS;
|
||||
property ShareOptions: TSynEditorShareOptions read FShareOptions write SetShareOptions
|
||||
default SYNEDIT_DEFAULT_SHARE_OPTIONS; experimental;
|
||||
property VisibleSpecialChars: TSynVisibleSpecialChars read FVisibleSpecialChars write SetVisibleSpecialChars;
|
||||
@ -2549,7 +2543,6 @@ begin
|
||||
fTSearch := TSynEditSearch.Create;
|
||||
FOptions := SYNEDIT_DEFAULT_OPTIONS;
|
||||
FOptions2 := SYNEDIT_DEFAULT_OPTIONS2;
|
||||
FMouseOptions := SYNEDIT_DEFAULT_MOUSE_OPTIONS;
|
||||
FShareOptions := SYNEDIT_DEFAULT_SHARE_OPTIONS;
|
||||
FVisibleSpecialChars := SYNEDIT_DEFAULT_VISIBLESPECIALCHARS;
|
||||
fMarkupSpecialChar.VisibleSpecialChars := SYNEDIT_DEFAULT_VISIBLESPECIALCHARS;
|
||||
@ -3830,14 +3823,14 @@ begin
|
||||
(Y >= FTextArea.Bounds.Top) and (Y < FTextArea.Bounds.Bottom) and
|
||||
IsPointInSelection(FInternalCaret.LineBytePos)
|
||||
then
|
||||
if DoHandleMouseAction(FMouseSelActions.GetActionsForOptions(FMouseOptions), Info) then
|
||||
if DoHandleMouseAction(FMouseSelActions.GetActionsForOptions(MouseOptions), Info) then
|
||||
exit;
|
||||
// mouse event occured in text?
|
||||
if DoHandleMouseAction(FMouseTextActions.GetActionsForOptions(FMouseOptions), Info) then
|
||||
if DoHandleMouseAction(FMouseTextActions.GetActionsForOptions(MouseOptions), Info) then
|
||||
exit;
|
||||
end;
|
||||
|
||||
DoHandleMouseAction(FMouseActions.GetActionsForOptions(FMouseOptions), Info);
|
||||
DoHandleMouseAction(FMouseActions.GetActionsForOptions(MouseOptions), Info);
|
||||
finally
|
||||
if Info.IgnoreUpClick then
|
||||
include(fStateFlags, sfIgnoreUpClick);
|
||||
@ -3845,6 +3838,17 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCustomSynEdit.FindGutterFromGutterPartList(const APartList: TObject): TObject;
|
||||
begin
|
||||
if APartList is TSynGutterPartList then
|
||||
Result := Gutter
|
||||
else
|
||||
if APartList is TSynRightGutterPartList then
|
||||
Result := RightGutter
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: Integer);
|
||||
var
|
||||
@ -6828,11 +6832,11 @@ end;
|
||||
|
||||
procedure TCustomSynEdit.ResetMouseActions;
|
||||
begin
|
||||
FMouseActions.Options := FMouseOptions;
|
||||
FMouseActions.Options := MouseOptions;
|
||||
FMouseActions.ResetUserActions;
|
||||
FMouseSelActions.Options := FMouseOptions;
|
||||
FMouseSelActions.Options := MouseOptions;
|
||||
FMouseSelActions.ResetUserActions;
|
||||
FMouseTextActions.Options := FMouseOptions;
|
||||
FMouseTextActions.Options := MouseOptions;
|
||||
FMouseTextActions.ResetUserActions;
|
||||
|
||||
FLeftGutter.ResetMouseActions;
|
||||
@ -8390,7 +8394,7 @@ begin
|
||||
As long as the default mouse actions are set, the below will act as normal
|
||||
*)
|
||||
|
||||
MOpt := FMouseOptions;
|
||||
MOpt := MouseOptions;
|
||||
f := False;
|
||||
for m := low(SYNEDIT_OLD_MOUSE_OPTIONS_MAP) to high(SYNEDIT_OLD_MOUSE_OPTIONS_MAP) do
|
||||
if (m in SYNEDIT_OLD_MOUSE_OPTIONS) and (m in ChangedOptions) then begin
|
||||
@ -8447,16 +8451,16 @@ var
|
||||
ChangedOptions: TSynEditorMouseOptions;
|
||||
m: TSynEditorOption;
|
||||
begin
|
||||
if FMouseOptions = AValue then Exit;
|
||||
if MouseOptions = AValue then Exit;
|
||||
|
||||
ChangedOptions := (FMouseOptions-AValue)+(AValue-FMouseOptions);
|
||||
FMouseOptions := AValue;
|
||||
ChangedOptions := (MouseOptions-AValue)+(AValue-MouseOptions);
|
||||
inherited;
|
||||
// changes take effect when MouseActions are accessed
|
||||
|
||||
for m := low(SYNEDIT_OLD_MOUSE_OPTIONS_MAP) to high(SYNEDIT_OLD_MOUSE_OPTIONS_MAP) do
|
||||
if (m in SYNEDIT_OLD_MOUSE_OPTIONS) and
|
||||
(SYNEDIT_OLD_MOUSE_OPTIONS_MAP[m] in ChangedOptions) and
|
||||
not(SYNEDIT_OLD_MOUSE_OPTIONS_MAP[m] in FMouseOptions)
|
||||
not(SYNEDIT_OLD_MOUSE_OPTIONS_MAP[m] in MouseOptions)
|
||||
then
|
||||
FOptions := FOptions - [m];
|
||||
|
||||
|
@ -49,7 +49,10 @@ uses
|
||||
// LCL
|
||||
LCLIntf, LCLType, Graphics, Controls, Clipbrd, ImgList,
|
||||
// SynEdit
|
||||
SynEditHighlighter, SynEditMiscProcs, SynEditTypes, LazSynEditText, SynEditPointClasses;
|
||||
SynEditHighlighter, SynEditMiscProcs, SynEditTypes, LazSynEditText, SynEditPointClasses, SynEditMouseCmds;
|
||||
|
||||
const
|
||||
SYNEDIT_DEFAULT_MOUSE_OPTIONS = [];
|
||||
|
||||
type
|
||||
|
||||
@ -99,6 +102,8 @@ type
|
||||
{ TSynEditBase }
|
||||
|
||||
TSynEditBase = class(TCustomControl)
|
||||
private
|
||||
FMouseOptions: TSynEditorMouseOptions;
|
||||
protected
|
||||
FWordBreaker: TSynWordBreaker;
|
||||
FBlockSelection: TSynEditSelection;
|
||||
@ -111,14 +116,22 @@ type
|
||||
function GetFoldedTextBuffer: TObject; virtual; abstract;
|
||||
function GetTextBuffer: TSynEditStrings; virtual; abstract;
|
||||
function GetPaintArea: TLazSynSurface; virtual; abstract; // TLazSynSurfaceManager
|
||||
procedure SetMouseOptions(AValue: TSynEditorMouseOptions); virtual;
|
||||
|
||||
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
|
||||
property TextBuffer: TSynEditStrings read GetTextBuffer; // (TSynEditStringList) No uncommited (trailing/trimmable) spaces
|
||||
property WordBreaker: TSynWordBreaker read FWordBreaker;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
|
||||
function FindGutterFromGutterPartList(const APartList: TObject): TObject; virtual; abstract;
|
||||
public
|
||||
property Lines: TStrings read GetLines write SetLines;
|
||||
|
||||
property MouseOptions: TSynEditorMouseOptions read FMouseOptions write SetMouseOptions
|
||||
default SYNEDIT_DEFAULT_MOUSE_OPTIONS;
|
||||
end;
|
||||
|
||||
{ TSynEditFriend }
|
||||
@ -622,6 +635,21 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
{ TSynEditBase }
|
||||
|
||||
constructor TSynEditBase.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
|
||||
FMouseOptions := SYNEDIT_DEFAULT_MOUSE_OPTIONS;
|
||||
end;
|
||||
|
||||
procedure TSynEditBase.SetMouseOptions(AValue: TSynEditorMouseOptions);
|
||||
begin
|
||||
if FMouseOptions = AValue then Exit;
|
||||
FMouseOptions := AValue;
|
||||
end;
|
||||
|
||||
{ TSynEditFriend }
|
||||
|
||||
function TSynEditFriend.GetViewedTextBuffer: TSynEditStringsLinked;
|
||||
|
@ -122,7 +122,6 @@ type
|
||||
function GetSynEdit: TSynEditBase;
|
||||
procedure PutPart(Index: Integer; const AValue: TSynGutterPartBase);
|
||||
protected
|
||||
function FindGutter: TSynGutterBase; virtual; abstract;
|
||||
procedure RegisterItem(AnItem: TSynObjectListItem); override;
|
||||
property Gutter: TSynGutterBase read FGutter;
|
||||
property SynEdit:TSynEditBase read GetSynEdit;
|
||||
@ -141,18 +140,12 @@ type
|
||||
{ TSynGutterPartList
|
||||
GutterPartList for the left side Gutter. Historically the left Gutter is reffered to as Gutter without prefix }
|
||||
|
||||
TSynGutterPartList = class(TSynGutterPartListBase)
|
||||
protected
|
||||
function FindGutter: TSynGutterBase; override;
|
||||
end;
|
||||
TSynGutterPartList = class(TSynGutterPartListBase);
|
||||
|
||||
{ TSynRightGutterPartList
|
||||
GutterPartList for the right side Gutter. }
|
||||
|
||||
TSynRightGutterPartList = class(TSynGutterPartListBase)
|
||||
protected
|
||||
function FindGutter: TSynGutterBase; override;
|
||||
end;
|
||||
TSynRightGutterPartList = class(TSynGutterPartListBase);
|
||||
|
||||
{ TSynGutterPartBase }
|
||||
|
||||
@ -228,8 +221,10 @@ type
|
||||
end;
|
||||
|
||||
|
||||
const
|
||||
ScrollBarWidth=0;
|
||||
|
||||
implementation
|
||||
uses SynEdit;
|
||||
|
||||
{ TSynGutterBase }
|
||||
|
||||
@ -325,12 +320,12 @@ end;
|
||||
function TSynGutterBase.MaybeHandleMouseAction(var AnInfo: TSynEditMouseActionInfo;
|
||||
HandleActionProc: TSynEditMouseActionHandler): Boolean;
|
||||
begin
|
||||
Result := HandleActionProc(FMouseActions.GetActionsForOptions(TCustomSynEdit(SynEdit).MouseOptions), AnInfo);
|
||||
Result := HandleActionProc(FMouseActions.GetActionsForOptions(SynEdit.MouseOptions), AnInfo);
|
||||
end;
|
||||
|
||||
procedure TSynGutterBase.ResetMouseActions;
|
||||
begin
|
||||
FMouseActions.Options := TCustomSynEdit(SynEdit).MouseOptions;
|
||||
FMouseActions.Options := SynEdit.MouseOptions;
|
||||
FMouseActions.ResetUserActions;
|
||||
end;
|
||||
|
||||
@ -766,7 +761,7 @@ end;
|
||||
function TSynGutterPartBase.MaybeHandleMouseAction(var AnInfo: TSynEditMouseActionInfo;
|
||||
HandleActionProc: TSynEditMouseActionHandler): Boolean;
|
||||
begin
|
||||
Result := HandleActionProc(FMouseActions.GetActionsForOptions(TCustomSynEdit(SynEdit).MouseOptions), AnInfo);
|
||||
Result := HandleActionProc(FMouseActions.GetActionsForOptions(SynEdit.MouseOptions), AnInfo);
|
||||
end;
|
||||
|
||||
function TSynGutterPartBase.DoHandleMouseAction(AnAction: TSynEditMouseAction;
|
||||
@ -777,7 +772,7 @@ end;
|
||||
|
||||
procedure TSynGutterPartBase.ResetMouseActions;
|
||||
begin
|
||||
FMouseActions.Options := TCustomSynEdit(SynEdit).MouseOptions;
|
||||
FMouseActions.Options := SynEdit.MouseOptions;
|
||||
FMouseActions.ResetUserActions;
|
||||
end;
|
||||
|
||||
@ -801,8 +796,8 @@ constructor TSynGutterPartListBase.Create(AOwner: TComponent);
|
||||
begin
|
||||
Inherited Create(AOwner);
|
||||
include(FComponentStyle, csTransient);
|
||||
if FindGutter <> nil then
|
||||
FGutter := FindGutter;
|
||||
if (FGutter = nil) and (SynEdit.FindGutterFromGutterPartList(Self) <> nil) then
|
||||
FGutter := SynEdit.FindGutterFromGutterPartList(Self) as TSynGutterBase;
|
||||
Gutter.RegisterNewGutterPartList(self);
|
||||
end;
|
||||
|
||||
@ -864,19 +859,5 @@ begin
|
||||
inc(Result);
|
||||
end;
|
||||
|
||||
{ TSynGutterPartList }
|
||||
|
||||
function TSynGutterPartList.FindGutter: TSynGutterBase;
|
||||
begin
|
||||
Result := TCustomSynEdit(SynEdit).Gutter;
|
||||
end;
|
||||
|
||||
{ TSynRightGutterPartList }
|
||||
|
||||
function TSynRightGutterPartList.FindGutter: TSynGutterBase;
|
||||
begin
|
||||
Result := TCustomSynEdit(SynEdit).RightGutter;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user