IDE: code browser: replace identifier

git-svn-id: trunk@22520 -
This commit is contained in:
mattias 2009-11-10 12:19:13 +00:00
parent 0fd3251391
commit d39dca6458

View File

@ -883,11 +883,14 @@ var
TargetCode: TCodeBuffer; TargetCode: TCodeBuffer;
TargetOwner: TObject; TargetOwner: TObject;
SrcEdit: TSourceEditorInterface; SrcEdit: TSourceEditorInterface;
InsertPos: TPoint;
Code: TCodeBuffer; Code: TCodeBuffer;
CodeMarker: TSourceLogMarker; CodeMarker: TSourceLogMarker;
Identifier: String; Identifier: String;
SelectedUnitFilename: String; SelectedUnitFilename: String;
IdentStart: integer;
IdentEnd: integer;
InsertStartPos: TPoint;
InsertEndPos: TPoint;
begin begin
TVNode:=BrowseTreeView.Selected; TVNode:=BrowseTreeView.Selected;
if TVNode=nil then exit; if TVNode=nil then exit;
@ -975,9 +978,9 @@ begin
try try
SrcEdit:=SourceEditorWindow.ActiveEditor; SrcEdit:=SourceEditorWindow.ActiveEditor;
if SrcEdit=nil then exit; if SrcEdit=nil then exit;
InsertPos:=SrcEdit.CursorTextXY; InsertStartPos:=SrcEdit.CursorTextXY;
Code:=TCodeBuffer(SrcEdit.CodeToolsBuffer); Code:=TCodeBuffer(SrcEdit.CodeToolsBuffer);
CodeMarker:=Code.AddMarkerXY(InsertPos.Y,InsertPos.X,Self); CodeMarker:=Code.AddMarkerXY(InsertStartPos.Y,InsertStartPos.X,Self);
List.Add(TargetOwner); List.Add(TargetOwner);
if (SelectedOwner is TLazPackage) then begin if (SelectedOwner is TLazPackage) then begin
@ -1019,9 +1022,12 @@ begin
DebugLn(['TCodeBrowserView.UseUnitInSrcEditor insert place was deleted']); DebugLn(['TCodeBrowserView.UseUnitInSrcEditor insert place was deleted']);
exit; exit;
end; end;
Code.AbsoluteToLineCol(CodeMarker.NewPosition,InsertPos.Y,InsertPos.X); GetIdentStartEndAtPosition(Code.Source,CodeMarker.NewPosition,
//GetIdentStartEndAtPosition(Code.Source,); IdentStart,IdentEnd);
SrcEdit.ReplaceText(InsertPos,InsertPos,Identifier); Code.AbsoluteToLineCol(IdentStart,InsertStartPos.Y,InsertStartPos.X);
InsertEndPos:=InsertStartPos;
inc(InsertEndPos.X,IdentEnd-IdentStart);
SrcEdit.ReplaceText(InsertStartPos,InsertEndPos,Identifier);
end; end;
finally finally
List.Free; List.Free;