mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 13:50:06 +02:00
MG: acclerated parser read-undo-read combinations
git-svn-id: trunk@1501 -
This commit is contained in:
parent
8752d483cc
commit
c40bc842d5
@ -68,6 +68,7 @@ type
|
|||||||
SrcLen: integer;
|
SrcLen: integer;
|
||||||
CurNode: TCodeTreeNode;
|
CurNode: TCodeTreeNode;
|
||||||
LastAtoms: TAtomRing;
|
LastAtoms: TAtomRing;
|
||||||
|
NextPos: TAtomPosition;
|
||||||
|
|
||||||
CheckFilesOnDisk: boolean;
|
CheckFilesOnDisk: boolean;
|
||||||
IndentSize: integer;
|
IndentSize: integer;
|
||||||
@ -199,6 +200,7 @@ begin
|
|||||||
CurPos.StartPos:=1;
|
CurPos.StartPos:=1;
|
||||||
CurPos.EndPos:=-1;
|
CurPos.EndPos:=-1;
|
||||||
LastAtoms.Clear;
|
LastAtoms.Clear;
|
||||||
|
NextPos.StartPos:=-1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomCodeTool.RaiseException(const AMessage: string);
|
procedure TCustomCodeTool.RaiseException(const AMessage: string);
|
||||||
@ -539,11 +541,16 @@ procedure TCustomCodeTool.ReadNextAtom;
|
|||||||
var c1, c2: char;
|
var c1, c2: char;
|
||||||
CommentLvl: integer;
|
CommentLvl: integer;
|
||||||
begin
|
begin
|
||||||
// Skip all spaces and comments
|
|
||||||
CommentLvl:=0;
|
|
||||||
if (CurPos.StartPos<CurPos.EndPos) and (CurPos.StartPos>=1) then
|
if (CurPos.StartPos<CurPos.EndPos) and (CurPos.StartPos>=1) then
|
||||||
LastAtoms.Add(CurPos);
|
LastAtoms.Add(CurPos);
|
||||||
|
if NextPos.StartPos>=1 then begin
|
||||||
|
CurPos:=NextPos;
|
||||||
|
NextPos.StartPos:=-1;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
CurPos.StartPos:=CurPos.EndPos;
|
CurPos.StartPos:=CurPos.EndPos;
|
||||||
|
// Skip all spaces and comments
|
||||||
|
CommentLvl:=0;
|
||||||
//if CurPos.StartPos<1 then CurPos.StartPos:=SrcLen+1;
|
//if CurPos.StartPos<1 then CurPos.StartPos:=SrcLen+1;
|
||||||
while CurPos.StartPos<=SrcLen do begin
|
while CurPos.StartPos<=SrcLen do begin
|
||||||
if IsCommentStartChar[Src[CurPos.StartPos]] then begin
|
if IsCommentStartChar[Src[CurPos.StartPos]] then begin
|
||||||
@ -747,6 +754,7 @@ begin
|
|||||||
UndoReadNextAtom;
|
UndoReadNextAtom;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
NextPos:=CurPos;
|
||||||
// Skip all spaces and comments
|
// Skip all spaces and comments
|
||||||
CommentLvl:=0;
|
CommentLvl:=0;
|
||||||
dec(CurPos.StartPos);
|
dec(CurPos.StartPos);
|
||||||
@ -1009,6 +1017,7 @@ end;
|
|||||||
procedure TCustomCodeTool.UndoReadNextAtom;
|
procedure TCustomCodeTool.UndoReadNextAtom;
|
||||||
begin
|
begin
|
||||||
if LastAtoms.Count>0 then begin
|
if LastAtoms.Count>0 then begin
|
||||||
|
NextPos:=CurPos;
|
||||||
CurPos:=LastAtoms.GetValueAt(0);
|
CurPos:=LastAtoms.GetValueAt(0);
|
||||||
LastAtoms.UndoLastAdd;
|
LastAtoms.UndoLastAdd;
|
||||||
end else
|
end else
|
||||||
@ -1147,15 +1156,14 @@ begin
|
|||||||
CurPos.StartPos:=1;
|
CurPos.StartPos:=1;
|
||||||
CurPos.EndPos:=1;
|
CurPos.EndPos:=1;
|
||||||
LastAtoms.Clear;
|
LastAtoms.Clear;
|
||||||
|
NextPos.StartPos:=-1;
|
||||||
CurNode:=nil;
|
CurNode:=nil;
|
||||||
if DeleteNodes then DoDeleteNodes;
|
if DeleteNodes then DoDeleteNodes;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomCodeTool.MoveCursorToNodeStart(ANode: TCodeTreeNode);
|
procedure TCustomCodeTool.MoveCursorToNodeStart(ANode: TCodeTreeNode);
|
||||||
begin
|
begin
|
||||||
CurPos.StartPos:=ANode.StartPos;
|
MoveCursorToCleanPos(ANode.StartPos);
|
||||||
CurPos.EndPos:=ANode.StartPos;
|
|
||||||
LastAtoms.Clear;
|
|
||||||
CurNode:=ANode;
|
CurNode:=ANode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1164,6 +1172,7 @@ begin
|
|||||||
CurPos.StartPos:=ACleanPos;
|
CurPos.StartPos:=ACleanPos;
|
||||||
CurPos.EndPos:=ACleanPos;
|
CurPos.EndPos:=ACleanPos;
|
||||||
LastAtoms.Clear;
|
LastAtoms.Clear;
|
||||||
|
NextPos.StartPos:=-1;
|
||||||
CurNode:=nil;
|
CurNode:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1368,6 +1377,7 @@ begin
|
|||||||
// search first atom in line
|
// search first atom in line
|
||||||
CurPos.StartPos:=ALineStart;
|
CurPos.StartPos:=ALineStart;
|
||||||
CurPos.EndPos:=ALineStart;
|
CurPos.EndPos:=ALineStart;
|
||||||
|
NextPos.StartPos:=-1;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
AFirstAtomStart:=CurPos.StartPos;
|
AFirstAtomStart:=CurPos.StartPos;
|
||||||
// search last atom in line
|
// search last atom in line
|
||||||
|
@ -2960,8 +2960,7 @@ begin
|
|||||||
if (GrandPaNode=nil) or (GrandPaNode.Desc<>ctnClass) then exit;
|
if (GrandPaNode=nil) or (GrandPaNode.Desc<>ctnClass) then exit;
|
||||||
GrandPaNode:=GrandPaNode.Parent;
|
GrandPaNode:=GrandPaNode.Parent;
|
||||||
if GrandPaNode.Desc<>ctnTypeDefinition then exit;
|
if GrandPaNode.Desc<>ctnTypeDefinition then exit;
|
||||||
CurPos.StartPos:=GrandPaNode.StartPos;
|
MoveCursorToCleanPos(GrandPaNode.StartPos);
|
||||||
CurPos.EndPos:=CurPos.StartPos;
|
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
if not AtomIsWord then exit;
|
if not AtomIsWord then exit;
|
||||||
TheClassName:=GetAtom;
|
TheClassName:=GetAtom;
|
||||||
|
@ -34,31 +34,27 @@ end;
|
|||||||
function TGraphic.Equals(Graphic: TGraphic): Boolean;
|
function TGraphic.Equals(Graphic: TGraphic): Boolean;
|
||||||
var
|
var
|
||||||
SelfImage, GraphicsImage: TMemoryStream;
|
SelfImage, GraphicsImage: TMemoryStream;
|
||||||
|
IsEmpty: boolean;
|
||||||
begin
|
begin
|
||||||
Result := (Graphic <> nil);
|
Result := (Graphic <> nil) and (ClassType = Graphic.ClassType);
|
||||||
if not Result then exit;
|
if not Result then exit;
|
||||||
Result:=(ClassType = Graphic.ClassType);
|
IsEmpty:=Empty;
|
||||||
if not Result then exit;
|
Result:=(IsEmpty=Graphic.Empty);
|
||||||
if Empty or Graphic.Empty then
|
if (not Result) or IsEmpty or (Self=Graphic) then exit;
|
||||||
begin
|
// ToDo: check for same resource
|
||||||
Result := Empty and Graphic.Empty;
|
SelfImage := TMemoryStream.Create;
|
||||||
Exit;
|
try
|
||||||
end;
|
WriteData(SelfImage);
|
||||||
if Result then begin
|
GraphicsImage := TMemoryStream.Create;
|
||||||
SelfImage := TMemoryStream.Create;
|
|
||||||
try
|
try
|
||||||
WriteData(SelfImage);
|
Graphic.WriteData(GraphicsImage);
|
||||||
GraphicsImage := TMemoryStream.Create;
|
Result := (SelfImage.Size = GraphicsImage.Size) and
|
||||||
try
|
CompareMem(SelfImage.Memory, GraphicsImage.Memory, SelfImage.Size);
|
||||||
Graphic.WriteData(GraphicsImage);
|
|
||||||
Result := (SelfImage.Size = GraphicsImage.Size) and
|
|
||||||
CompareMem(SelfImage.Memory, GraphicsImage.Memory, SelfImage.Size);
|
|
||||||
finally
|
|
||||||
GraphicsImage.Free;
|
|
||||||
end;
|
|
||||||
finally
|
finally
|
||||||
SelfImage.Free;
|
GraphicsImage.Free;
|
||||||
end;
|
end;
|
||||||
|
finally
|
||||||
|
SelfImage.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -104,17 +100,16 @@ end;
|
|||||||
procedure TGraphic.SetModified(Value: Boolean);
|
procedure TGraphic.SetModified(Value: Boolean);
|
||||||
begin
|
begin
|
||||||
if Value then
|
if Value then
|
||||||
FModified := true // Changed(Self);
|
Changed(Self);
|
||||||
else
|
else
|
||||||
FModified := False;
|
FModified := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGraphic.SetTransparent(Value: Boolean);
|
procedure TGraphic.SetTransparent(Value: Boolean);
|
||||||
begin
|
begin
|
||||||
if Value <> FTransparent then
|
if Value <> FTransparent then begin
|
||||||
begin
|
|
||||||
FTransparent := Value;
|
FTransparent := Value;
|
||||||
//Changed(Self);
|
Changed(Self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user