mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-08 04:02:28 +01:00
SynEdit: improved handling of Lines.Add while updating(locked) / Speed up loading files
git-svn-id: trunk@25706 -
This commit is contained in:
parent
d334372608
commit
db05dbd916
@ -126,6 +126,9 @@ type
|
|||||||
|
|
||||||
FAttachedSynEditList: TFPList;
|
FAttachedSynEditList: TFPList;
|
||||||
FNotifyLists: Array [TSynEditNotifyReason] of TSynMethodList;
|
FNotifyLists: Array [TSynEditNotifyReason] of TSynMethodList;
|
||||||
|
FCachedNotify: Boolean;
|
||||||
|
FCachedNotifyStart, FCachedNotifyCount: Integer;
|
||||||
|
FCachedNotifySender: TSynEditStrings;
|
||||||
|
|
||||||
FIgnoreSendNotification: array [TSynEditNotifyReason] of Integer;
|
FIgnoreSendNotification: array [TSynEditNotifyReason] of Integer;
|
||||||
fDosFileFormat: boolean;
|
fDosFileFormat: boolean;
|
||||||
@ -146,6 +149,7 @@ type
|
|||||||
Procedure SetAttributeSize(NewSize: Integer);
|
Procedure SetAttributeSize(NewSize: Integer);
|
||||||
procedure SetFlags(Index: Integer; const AValue: TSynEditStringFlags);
|
procedure SetFlags(Index: Integer; const AValue: TSynEditStringFlags);
|
||||||
procedure SetModified(const AValue: Boolean);
|
procedure SetModified(const AValue: Boolean);
|
||||||
|
procedure SendCachedNotify;
|
||||||
protected
|
protected
|
||||||
function GetExpandedString(Index: integer): string; override;
|
function GetExpandedString(Index: integer): string; override;
|
||||||
function GetLengthOfLongestLine: integer; override;
|
function GetLengthOfLongestLine: integer; override;
|
||||||
@ -558,7 +562,7 @@ begin
|
|||||||
BeginUpdate;
|
BeginUpdate;
|
||||||
SetCount(0);
|
SetCount(0);
|
||||||
SetCapacity(0);
|
SetCapacity(0);
|
||||||
FNotifyLists[senrCleared].CallNotifyEvents(Self);
|
SendNotification(senrCleared, Self);
|
||||||
SendNotification(senrLineCount, self, 0, -c);
|
SendNotification(senrLineCount, self, 0, -c);
|
||||||
EndUpdate;
|
EndUpdate;
|
||||||
end;
|
end;
|
||||||
@ -711,7 +715,7 @@ begin
|
|||||||
else
|
else
|
||||||
Modified := fUndoList.CanUndo or fUndoList.FullUndoImpossible;
|
Modified := fUndoList.CanUndo or fUndoList.FullUndoImpossible;
|
||||||
|
|
||||||
FNotifyLists[senrUndoRedoAdded].CallNotifyEvents(Sender);
|
SendNotification(senrUndoRedoAdded, Sender);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Maps the Physical Width (ScreenCells) to each character
|
// Maps the Physical Width (ScreenCells) to each character
|
||||||
@ -956,7 +960,14 @@ begin
|
|||||||
FUndoList.MarkTopAsUnmodified;
|
FUndoList.MarkTopAsUnmodified;
|
||||||
FRedoList.MarkTopAsUnmodified;
|
FRedoList.MarkTopAsUnmodified;
|
||||||
end;
|
end;
|
||||||
FNotifyLists[senrModifiedChanged].CallNotifyEvents(Self);
|
SendNotification(senrModifiedChanged, Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSynEditStringList.SendCachedNotify;
|
||||||
|
begin
|
||||||
|
TLineRangeNotificationList(FNotifyLists[senrLineCount])
|
||||||
|
.CallRangeNotifyEvents(FCachedNotifySender, FCachedNotifyStart, FCachedNotifyCount);
|
||||||
|
FCachedNotify := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynEditStringList.MarkModified(AFirst, ALast: Integer);
|
procedure TSynEditStringList.MarkModified(AFirst, ALast: Integer);
|
||||||
@ -1017,7 +1028,10 @@ begin
|
|||||||
if Updating then begin
|
if Updating then begin
|
||||||
SendNotification(senrIncPaintLock, Sender); // DoIncPaintLock
|
SendNotification(senrIncPaintLock, Sender); // DoIncPaintLock
|
||||||
SendNotification(senrAfterIncPaintLock, Sender);
|
SendNotification(senrAfterIncPaintLock, Sender);
|
||||||
|
FCachedNotify := False;
|
||||||
end else begin
|
end else begin
|
||||||
|
if FCachedNotify then
|
||||||
|
SendCachedNotify;
|
||||||
FIsInDecPaintLock := True;
|
FIsInDecPaintLock := True;
|
||||||
try
|
try
|
||||||
SendNotification(senrBeforeDecPaintLock, Sender);
|
SendNotification(senrBeforeDecPaintLock, Sender);
|
||||||
@ -1138,6 +1152,37 @@ procedure TSynEditStringList.SendNotification(AReason: TSynEditNotifyReason;
|
|||||||
aBytePos: Integer = -1; aLen: Integer = 0; aTxt: String = '');
|
aBytePos: Integer = -1; aLen: Integer = 0; aTxt: String = '');
|
||||||
begin
|
begin
|
||||||
if FIgnoreSendNotification[AReason] > 0 then exit;
|
if FIgnoreSendNotification[AReason] > 0 then exit;
|
||||||
|
|
||||||
|
if UpdateCount > 0 then begin;
|
||||||
|
if AReason = senrLineCount then begin
|
||||||
|
// maybe cache and combine
|
||||||
|
if not FCachedNotify then begin
|
||||||
|
FCachedNotify := True;
|
||||||
|
FCachedNotifySender := ASender;
|
||||||
|
FCachedNotifyStart := aIndex;
|
||||||
|
FCachedNotifyCount := aCount;
|
||||||
|
exit;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if (FCachedNotifySender = ASender) and (aIndex >= FCachedNotifyStart) and
|
||||||
|
(aIndex <= FCachedNotifyStart + FCachedNotifyCount) and
|
||||||
|
((aCount > 0) or (aIndex - aCount < FCachedNotifyStart + FCachedNotifyCount))
|
||||||
|
then begin
|
||||||
|
FCachedNotifyCount := FCachedNotifyCount + aCount;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if FCachedNotify and (AReason = senrLineChange) and
|
||||||
|
(ASender = FCachedNotifySender) and (FCachedNotifyCount > 0) and
|
||||||
|
(aIndex >= FCachedNotifyStart) and
|
||||||
|
(aIndex + aCount {- 1} <= FCachedNotifyStart + FCachedNotifyCount {- 1})
|
||||||
|
then
|
||||||
|
exit; // Will send senrLineCount instead
|
||||||
|
|
||||||
|
if FCachedNotify then
|
||||||
|
SendCachedNotify;
|
||||||
|
end;
|
||||||
|
|
||||||
case AReason of
|
case AReason of
|
||||||
senrLineChange, senrLineCount, senrHighlightChanged:
|
senrLineChange, senrLineCount, senrHighlightChanged:
|
||||||
TLineRangeNotificationList(FNotifyLists[AReason])
|
TLineRangeNotificationList(FNotifyLists[AReason])
|
||||||
@ -1154,6 +1199,10 @@ end;
|
|||||||
procedure TSynEditStringList.SendNotification(AReason: TSynEditNotifyReason;
|
procedure TSynEditStringList.SendNotification(AReason: TSynEditNotifyReason;
|
||||||
ASender: TObject);
|
ASender: TObject);
|
||||||
begin
|
begin
|
||||||
|
if FCachedNotify then
|
||||||
|
SendCachedNotify;
|
||||||
|
if AReason in [senrLineChange, senrLineCount, senrHighlightChanged, senrEditAction] then
|
||||||
|
raise Exception.Create('Invalid');
|
||||||
FNotifyLists[AReason].CallNotifyEvents(ASender);
|
FNotifyLists[AReason].CallNotifyEvents(ASender);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user