From ff25f13519723d86c4caa7a0841743705d27573f Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 30 Mar 2015 16:24:11 +0000 Subject: [PATCH] codetools: CodeXYToStr git-svn-id: trunk@48538 - --- components/codetools/customcodetool.pas | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/components/codetools/customcodetool.pas b/components/codetools/customcodetool.pas index 215974a4be..e7a49493a5 100644 --- a/components/codetools/customcodetool.pas +++ b/components/codetools/customcodetool.pas @@ -182,6 +182,7 @@ type function CleanPosToCaretAndTopLine(CleanPos: integer; out Caret:TCodeXYPosition; out NewTopLine: integer): boolean; // true=ok, false=invalid CleanPos function CleanPosToStr(CleanPos: integer; WithFilename: boolean = false): string; + function CodeXYToStr(const CodePos: TCodeXYPosition; WithFilename: boolean = false): string; function CleanPosToRelativeStr(CleanPos: integer; const BaseFilename: string): string; procedure GetCleanPosInfo(CodePosInFront, CleanPos: integer; @@ -2704,14 +2705,20 @@ var CodePos: TCodeXYPosition; begin if CleanPosToCaret(CleanPos,CodePos) then begin - Result:=''; - if WithFilename then - Result:=ExtractRelativepath(ExtractFilePath(MainFilename),CodePos.Code.Filename)+','; - Result:=Result+'line '+IntToStr(CodePos.Y)+', column '+IntToStr(CodePos.X); + Result:=CodeXYToStr(CodePos,WithFilename); end else Result:='outside scan range, pos='+IntToStr(CleanPos)+'('+dbgstr(copy(Src,CleanPos-5,5)+'|'+copy(Src,CleanPos,5))+')'; end; +function TCustomCodeTool.CodeXYToStr(const CodePos: TCodeXYPosition; + WithFilename: boolean): string; +begin + Result:=''; + if WithFilename then + Result:=ExtractRelativepath(ExtractFilePath(MainFilename),CodePos.Code.Filename)+','; + Result:=Result+'line '+IntToStr(CodePos.Y)+', column '+IntToStr(CodePos.X); +end; + function TCustomCodeTool.CleanPosToRelativeStr(CleanPos: integer; const BaseFilename: string): string; var