mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-25 12:09:16 +02:00
synedit: TSynEditLines: added TextChangeStamp
git-svn-id: trunk@22321 -
This commit is contained in:
parent
612a84b15e
commit
46d7c68244
@ -47,6 +47,7 @@ type
|
||||
fDosFileFormat: boolean;
|
||||
FTextBuffer: TSynEditStrings;
|
||||
FOnSaved: TSavedNotification;
|
||||
function GetTextChangeStamp: int64;
|
||||
protected
|
||||
function Get(Index: integer): string; override;
|
||||
function GetCapacity: integer;
|
||||
@ -69,6 +70,7 @@ type
|
||||
procedure LoadFromFile(const FileName: string); override;
|
||||
procedure SaveToFile(const FileName: string); override;
|
||||
property DosFileFormat: boolean read fDosFileFormat write fDosFileFormat;
|
||||
property TextChangeStamp: int64 read GetTextChangeStamp;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -278,6 +280,11 @@ begin
|
||||
FOnSaved := OnSaved;
|
||||
end;
|
||||
|
||||
function TSynEditLines.GetTextChangeStamp: int64;
|
||||
begin
|
||||
Result:=FTextBuffer.TextChangeStamp;
|
||||
end;
|
||||
|
||||
function TSynEditLines.Get(Index: integer): string;
|
||||
begin
|
||||
Result := FTextBuffer[Index];
|
||||
|
@ -74,6 +74,7 @@ type
|
||||
|
||||
TSynEditStrings = class(TStrings)
|
||||
protected
|
||||
FTextChangeStamp: int64;
|
||||
FIsUtf8: Boolean;
|
||||
function GetIsUtf8 : Boolean; virtual;
|
||||
procedure SetIsUtf8(const AValue : Boolean); virtual;
|
||||
@ -133,11 +134,13 @@ type
|
||||
property UndoList: TSynEditUndoList read GetUndoList;
|
||||
property RedoList: TSynEditUndoList read GetRedoList;
|
||||
property IsUndoing: Boolean write SetIsUndoing;
|
||||
procedure IncreaseTextChangeStamp;
|
||||
public
|
||||
property ExpandedStrings[Index: integer]: string read GetExpandedString;
|
||||
property LengthOfLongestLine: integer read GetLengthOfLongestLine;
|
||||
property IsUtf8: Boolean read GetIsUtf8 write SetIsUtf8;
|
||||
property Ranges: TSynEditStorageMem read GetRange write PutRange;
|
||||
property TextChangeStamp: int64 read FTextChangeStamp;
|
||||
end;
|
||||
|
||||
{ TSynEditStringsLinked }
|
||||
@ -443,6 +446,14 @@ begin
|
||||
Result := BytePos + 1 + PhysicalPos - ScreenPos;
|
||||
end;
|
||||
|
||||
procedure TSynEditStrings.IncreaseTextChangeStamp;
|
||||
begin
|
||||
if fTextChangeStamp=High(fTextChangeStamp) then
|
||||
fTextChangeStamp:=Low(fTextChangeStamp)
|
||||
else
|
||||
inc(fTextChangeStamp);
|
||||
end;
|
||||
|
||||
{ TSynEditStringsLinked }
|
||||
|
||||
constructor TSynEditStringsLinked.Create(ASynStringSource: TSynEditStrings);
|
||||
|
@ -556,6 +556,7 @@ end;
|
||||
|
||||
procedure TSynEditStringList.SetCount(const AValue: Integer);
|
||||
begin
|
||||
IncreaseTextChangeStamp;
|
||||
fList.Count := AValue;
|
||||
end;
|
||||
|
||||
@ -733,6 +734,7 @@ begin
|
||||
BeginUpdate;
|
||||
fIndexOfLongestLine := -1;
|
||||
FList[Index] := S;
|
||||
IncreaseTextChangeStamp;
|
||||
SendNotification(senrLineChange, self, Index, 1);
|
||||
EndUpdate;
|
||||
end;
|
||||
|
@ -48,10 +48,10 @@ uses
|
||||
// codetools
|
||||
CodeToolManager, CodeCache, SourceLog,
|
||||
// synedit
|
||||
SynEditStrConst, SynEditTypes, SynEdit, SynRegExpr, SynEditHighlighter,
|
||||
SynEditAutoComplete, SynEditKeyCmds, SynCompletion, SynEditMiscClasses,
|
||||
SynEditMarkupHighAll, SynGutterLineNumber, SynEditMarks, SynBeautifier,
|
||||
SynEditTextBase, SynPluginTemplateEdit, SynPluginSyncroEdit,
|
||||
SynEditLines, SynEditStrConst, SynEditTypes, SynEdit, SynRegExpr,
|
||||
SynEditHighlighter, SynEditAutoComplete, SynEditKeyCmds, SynCompletion,
|
||||
SynEditMiscClasses, SynEditMarkupHighAll, SynGutterLineNumber, SynEditMarks,
|
||||
SynBeautifier, SynEditTextBase, SynPluginTemplateEdit, SynPluginSyncroEdit,
|
||||
// IDE interface
|
||||
MacroIntf, ProjectIntf, SrcEditorIntf, MenuIntf, LazIDEIntf, PackageIntf,
|
||||
IDEDialogs, IDEHelpIntf, IDEWindowIntf, IDEImagesIntf,
|
||||
@ -2588,7 +2588,7 @@ begin
|
||||
FEditPlugin.Enabled := False;
|
||||
FEditor.BeginUpdate;
|
||||
FCodeBuffer.AssignTo(FEditor.Lines,true);
|
||||
FEditorStampCommitedToCodetools:=FEditor.ChangeStamp;
|
||||
FEditorStampCommitedToCodetools:=(FEditor.Lines as TSynEditLines).TextChangeStamp;
|
||||
FEditor.EndUpdate;
|
||||
if assigned(FEditPlugin) then
|
||||
FEditPlugin.Enabled := True;
|
||||
@ -2627,7 +2627,7 @@ begin
|
||||
writeln('[TSourceEditor.OnCodeBufferChanged] A ',FIgnoreCodeBufferLock,' ',SrcLogEntry<>nil);
|
||||
{$ENDIF}
|
||||
if FIgnoreCodeBufferLock>0 then exit;
|
||||
CodeToolsInSync:=FEditorStampCommitedToCodetools=FEditor.ChangeStamp;
|
||||
CodeToolsInSync:=not NeedsUpdateCodeBuffer;
|
||||
if SrcLogEntry<>nil then begin
|
||||
FEditor.BeginUpdate;
|
||||
FEditor.BeginUndoBlock;
|
||||
@ -2670,7 +2670,7 @@ begin
|
||||
end;
|
||||
if CodeToolsInSync then begin
|
||||
// synedit and codetools were in sync -> mark as still in sync
|
||||
FEditorStampCommitedToCodetools:=FEditor.ChangeStamp;
|
||||
FEditorStampCommitedToCodetools:=TSynEditLines(FEditor.Lines).TextChangeStamp;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -2725,7 +2725,8 @@ end;
|
||||
procedure TSourceEditor.UpdateCodeBuffer;
|
||||
// copy the source from EditorComponent to codetools
|
||||
begin
|
||||
if FEditor.ChangeStamp=FEditorStampCommitedToCodetools then exit;
|
||||
if TSynEditLines(FEditor.Lines).TextChangeStamp=FEditorStampCommitedToCodetools
|
||||
then exit;
|
||||
{$IFDEF IDE_DEBUG}
|
||||
if FCodeBuffer=nil then begin
|
||||
debugln('');
|
||||
@ -2738,14 +2739,14 @@ begin
|
||||
IncreaseIgnoreCodeBufferLock;
|
||||
FEditor.BeginUpdate;
|
||||
FCodeBuffer.Assign(FEditor.Lines);
|
||||
FEditorStampCommitedToCodetools:=FEditor.ChangeStamp;
|
||||
FEditorStampCommitedToCodetools:=(FEditor.Lines as TSynEditLines).TextChangeStamp;
|
||||
FEditor.EndUpdate;
|
||||
DecreaseIgnoreCodeBufferLock;
|
||||
end;
|
||||
|
||||
function TSourceEditor.NeedsUpdateCodeBuffer: boolean;
|
||||
begin
|
||||
Result:=FEditor.ChangeStamp<>FEditorStampCommitedToCodetools;
|
||||
Result:=TSynEditLines(FEditor.Lines).TextChangeStamp<>FEditorStampCommitedToCodetools;
|
||||
end;
|
||||
|
||||
Function TSourceEditor.GetSource: TStrings;
|
||||
@ -2850,7 +2851,7 @@ begin
|
||||
begin
|
||||
FEditor.Modified:=false; // needed for the undo stack
|
||||
FEditor.MarkTextAsSaved;
|
||||
FEditorStampCommitedToCodetools:=FEditor.ChangeStamp;
|
||||
FEditorStampCommitedToCodetools:=TSynEditLines(FEditor.Lines).TextChangeStamp;
|
||||
end;
|
||||
if OldModified <> Modified then
|
||||
UpdatePageName;
|
||||
|
Loading…
Reference in New Issue
Block a user