mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-16 04:40:40 +01:00
synedit: immplemented ChangeStamp, IDE: using synedit changestamp, reducing commits to codetools
git-svn-id: trunk@18431 -
This commit is contained in:
parent
76c244d433
commit
e49f747043
@ -436,6 +436,7 @@ type
|
||||
FOnSpecialLineMarkup: TSpecialLineMarkupEvent;// needed, because bug fpc 11926
|
||||
FOnClickLink: TMouseEvent;
|
||||
FOnMouseLink: TSynMouseLinkEvent;
|
||||
fChangeStamp: int64;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
@ -596,6 +597,7 @@ type
|
||||
procedure Resize; override;
|
||||
function RealGetText: TCaption; override;
|
||||
procedure RealSetText(const Value: TCaption); override;
|
||||
procedure IncreaseChangeStamp;
|
||||
{$ENDIF}
|
||||
procedure SetRealLines(const AValue : TStrings); override;
|
||||
function GetTheLinesView: TStrings; override;
|
||||
@ -877,6 +879,7 @@ type
|
||||
property UseUTF8: boolean read FUseUTF8;
|
||||
procedure Update; override;
|
||||
procedure Invalidate; override;
|
||||
property ChangeStamp: int64 read fChangeStamp;
|
||||
{$ENDIF}
|
||||
public
|
||||
property OnKeyDown;
|
||||
@ -4442,6 +4445,14 @@ procedure TCustomSynEdit.RealSetText(const Value: TCaption);
|
||||
begin
|
||||
FLines.Text := Value; // Do not trim
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.IncreaseChangeStamp;
|
||||
begin
|
||||
if fChangeStamp=High(fChangeStamp) then
|
||||
fChangeStamp:=Low(fChangeStamp)
|
||||
else
|
||||
inc(fChangeStamp);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TCustomSynEdit.SetTopLine(Value: Integer);
|
||||
@ -9169,6 +9180,8 @@ end;
|
||||
|
||||
procedure TCustomSynEdit.SetModified(Value: boolean);
|
||||
begin
|
||||
if Value then
|
||||
IncreaseChangeStamp;
|
||||
if Value <> fModified then
|
||||
begin
|
||||
fModified := Value;
|
||||
@ -9802,6 +9815,7 @@ procedure TCustomSynEdit.UndoRedoAdded(Sender: TObject);
|
||||
var
|
||||
Item: TSynEditUndoItem;
|
||||
begin
|
||||
IncreaseChangeStamp;
|
||||
Item := TSynEditUndoList(Sender).PeekItem;
|
||||
if Item <> nil then
|
||||
TSynEditStringList(fLines).MarkModified(Item.ChangeStartPos.y - 1,
|
||||
|
||||
@ -12113,7 +12113,8 @@ var i: integer;
|
||||
AnUnitInfo: TUnitInfo;
|
||||
begin
|
||||
GetUnitWithPageIndex(APageIndex,SrcEdit,AnUnitInfo);
|
||||
if (SrcEdit<>nil) and (AnUnitInfo<>nil) and (SrcEdit.Modified) then begin
|
||||
if (SrcEdit<>nil) and (AnUnitInfo<>nil) and SrcEdit.NeedsUpdateCodeBuffer then
|
||||
begin
|
||||
SrcEdit.UpdateCodeBuffer;
|
||||
AnUnitInfo.Modified:=true;
|
||||
end;
|
||||
|
||||
@ -119,6 +119,7 @@ type
|
||||
|
||||
FCodeBuffer: TCodeBuffer;
|
||||
FIgnoreCodeBufferLock: integer;
|
||||
FEditorStampCommitedToCodetools: int64;
|
||||
|
||||
FPopUpMenu: TPopupMenu;
|
||||
FSyntaxHighlighterType: TLazSyntaxHighlighter;
|
||||
@ -227,6 +228,7 @@ type
|
||||
procedure IncreaseIgnoreCodeBufferLock; override;
|
||||
procedure DecreaseIgnoreCodeBufferLock; override;
|
||||
procedure UpdateCodeBuffer; override;// copy the source from EditorComponent
|
||||
function NeedsUpdateCodeBuffer: boolean; override;
|
||||
|
||||
// find
|
||||
procedure StartFindAndReplace(Replace:boolean);
|
||||
@ -1697,10 +1699,6 @@ begin
|
||||
|
||||
ecNone: ;
|
||||
|
||||
ecUndo:
|
||||
if (FEditor.Modified=false) and (CodeBuffer<>nil) then
|
||||
CodeBuffer.Assign(FEditor.Lines);
|
||||
|
||||
else
|
||||
begin
|
||||
Handled:=false;
|
||||
@ -2299,6 +2297,7 @@ begin
|
||||
{$ENDIF}
|
||||
FEditor.BeginUpdate;
|
||||
FCodeBuffer.AssignTo(FEditor.Lines,true);
|
||||
FEditorStampCommitedToCodetools:=FEditor.ChangeStamp;
|
||||
FEditor.EndUpdate;
|
||||
end;
|
||||
if IsActiveOnNoteBook then SourceNotebook.UpdateStatusBar;
|
||||
@ -2350,12 +2349,15 @@ procedure TSourceEditor.OnCodeBufferChanged(Sender: TSourceLog;
|
||||
end;
|
||||
end;
|
||||
|
||||
var StartPos, EndPos, MoveToPos: TPoint;
|
||||
var
|
||||
StartPos, EndPos, MoveToPos: TPoint;
|
||||
CodeToolsInSync: Boolean;
|
||||
begin
|
||||
{$IFDEF IDE_DEBUG}
|
||||
writeln('[TSourceEditor.OnCodeBufferChanged] A ',FIgnoreCodeBufferLock,' ',SrcLogEntry<>nil);
|
||||
{$ENDIF}
|
||||
if FIgnoreCodeBufferLock>0 then exit;
|
||||
CodeToolsInSync:=FEditorStampCommitedToCodetools=FEditor.ChangeStamp;
|
||||
if SrcLogEntry<>nil then begin
|
||||
FEditor.BeginUpdate;
|
||||
FEditor.BeginUndoBlock;
|
||||
@ -2396,6 +2398,10 @@ begin
|
||||
Sender.AssignTo(FEditor.Lines,false);
|
||||
FEditor.EndUpdate;
|
||||
end;
|
||||
if CodeToolsInSync then begin
|
||||
// synedit and codetools were in sync -> mark as still in sync
|
||||
FEditorStampCommitedToCodetools:=FEditor.ChangeStamp;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.StartIdentCompletion(JumpToError: boolean);
|
||||
@ -2443,24 +2449,29 @@ end;
|
||||
procedure TSourceEditor.UpdateCodeBuffer;
|
||||
// copy the source from EditorComponent to codetools
|
||||
begin
|
||||
if not FEditor.Modified then exit;
|
||||
if FEditor.ChangeStamp=FEditorStampCommitedToCodetools then exit;
|
||||
{$IFDEF IDE_DEBUG}
|
||||
if FCodeBuffer=nil then begin
|
||||
writeln('');
|
||||
writeln('*********** Oh, no: UpdateCodeBuffer ************');
|
||||
writeln('');
|
||||
debugln('');
|
||||
debugln('*********** Oh, no: UpdateCodeBuffer ************ ');
|
||||
debugln('');
|
||||
end;
|
||||
{$ENDIF}
|
||||
if FCodeBuffer=nil then exit;
|
||||
DebugLn(['TSourceEditor.UpdateCodeBuffer ',FileName]);
|
||||
IncreaseIgnoreCodeBufferLock;
|
||||
FModified:=FModified or FEditor.Modified;
|
||||
FEditor.BeginUpdate;
|
||||
FCodeBuffer.Assign(FEditor.Lines);
|
||||
FEditor.Modified:=false;
|
||||
FEditorStampCommitedToCodetools:=FEditor.ChangeStamp;
|
||||
FEditor.EndUpdate;
|
||||
DecreaseIgnoreCodeBufferLock;
|
||||
end;
|
||||
|
||||
function TSourceEditor.NeedsUpdateCodeBuffer: boolean;
|
||||
begin
|
||||
Result:=FEditor.ChangeStamp<>FEditorStampCommitedToCodetools;
|
||||
end;
|
||||
|
||||
Function TSourceEditor.GetSource: TStrings;
|
||||
Begin
|
||||
//return synedit's source.
|
||||
@ -2552,7 +2563,7 @@ end;
|
||||
|
||||
Function TSourceEditor.GetModified: Boolean;
|
||||
Begin
|
||||
Result := FEditor.Modified or FModified;
|
||||
Result := FModified or FEditor.Modified;
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.SetModified(const NewValue: Boolean);
|
||||
@ -2563,8 +2574,9 @@ begin
|
||||
FModified := NewValue;
|
||||
if not FModified then
|
||||
begin
|
||||
FEditor.Modified := False;
|
||||
FEditor.Modified:=false; // needed for the undo stack
|
||||
FEditor.MarkTextAsSaved;
|
||||
FEditorStampCommitedToCodetools:=FEditor.ChangeStamp;
|
||||
end;
|
||||
if OldModified <> Modified then
|
||||
UpdatePageName;
|
||||
|
||||
@ -109,6 +109,7 @@ type
|
||||
procedure IncreaseIgnoreCodeBufferLock; virtual; abstract;
|
||||
procedure DecreaseIgnoreCodeBufferLock; virtual; abstract;
|
||||
procedure UpdateCodeBuffer; virtual; abstract;// copy the source from EditorComponent to the codetools
|
||||
function NeedsUpdateCodeBuffer: boolean; virtual; abstract;// needs UpdateCodeBuffer
|
||||
|
||||
// search and replace
|
||||
function SearchReplace(const ASearch, AReplace: string;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user