SynEdit: LineMap, update all views, after new DisplayView

git-svn-id: trunk@63449 -
This commit is contained in:
martin 2020-06-27 19:23:59 +00:00
parent e6d5ca1609
commit 8fb8e98b28
3 changed files with 17 additions and 4 deletions

View File

@ -561,7 +561,6 @@ type
FNotifyLists: Array [TSynEditNotifyReason] of TMethodList;
function GetSynTextView(Index: integer): TSynEditStringsLinked;
function GetSynTextViewByClass(Index: TSynEditStringsLinkedClass): TSynEditStringsLinked;
procedure ReconnectViews;
procedure SetTextBuffer(AValue: TSynEditStringListBase);
protected
procedure AddGenericHandler(AReason: TSynEditNotifyReason; AHandler: TMethod);
@ -571,11 +570,13 @@ type
public
constructor Create(ATextBuffer: TSynEditStringListBase; ATopViewChangedCallback: TNotifyEvent);
destructor Destroy; override;
procedure ReconnectViews;
Procedure AddTextView(aTextView : TSynEditStringsLinked; AsFirst: Boolean = False);
Procedure AddTextView(aTextView : TSynEditStringsLinked; AIndex: Integer);
Procedure AddTextView(aTextView : TSynEditStringsLinked; AnAfter: TSynEditStringsLinked);
Procedure RemoveSynTextView(aTextView : TSynEditStringsLinked; aDestroy: Boolean = False);
function IndexOf(aTextView : TSynEditStringsLinked): integer;
function Count: Integer;
property SynTextView[Index: integer]: TSynEditStringsLinked read GetSynTextView;
property SynTextViewByClass[Index: TSynEditStringsLinkedClass]: TSynEditStringsLinked read GetSynTextViewByClass;
@ -2010,6 +2011,14 @@ begin
end;
end;
function TSynTextViewsManager.IndexOf(aTextView: TSynEditStringsLinked
): integer;
begin
Result := Count - 1;
while (Result >= 0) and (aTextView <> TSynEditStringsLinked(FTextViewsList[Result])) do
dec(Result);
end;
function TSynTextViewsManager.Count: Integer;
begin
Result := FTextViewsList.Count;

View File

@ -1491,6 +1491,7 @@ procedure TSynEditLineMappingView.SetDisplayView(
begin
FDisplayFiew.Free;
FDisplayFiew := ADisplayView;
Manager.ReconnectViews;
end;
function TSynEditLineMappingView.GetLengthOfLongestLine: integer;

View File

@ -1763,12 +1763,15 @@ begin
FLineMapView := TSynEditLineMappingView(TSynEdit(Editor).TextViewsManager.SynTextViewByClass[TSynEditLineMappingView]);
if FLineMapView = nil then begin
FLineMapView := TSynEditLineMappingView.Create;
FLineMapView.SetDisplayView(TLazSynDisplayWordWrap.Create(FLineMapView, Self));
TSynEdit(Editor).TextViewsManager.AddTextView(FLineMapView);
end;
if FLineMapView.PageMapCreator <> nil then
end
else
if (not(FLineMapView.DisplayView is TLazSynDisplayLineMapping)) or
(FLineMapView.PageMapCreator <> nil)
then
raise Exception.Create('Conflicting Plugin detected');
FLineMapView.SetDisplayView(TLazSynDisplayWordWrap.Create(FLineMapView, Self));
FLineMapView.PageMapCreator := @CreatePageMapNode;
FLineMapView.WrapInfoForViewedXYProc := @GetWrapInfoForViewedXY;
FLineMapView.AddLinesChangedHandler(@DoLinesChanged);