From ae4bac34362248903fbc0a8e4548d4206ab67233 Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 2 Jan 2008 23:20:53 +0000 Subject: [PATCH] IDE: code help: improved converting HTML to label caption git-svn-id: trunk@13595 - --- ide/codehelp.pas | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ide/codehelp.pas b/ide/codehelp.pas index df3beb00ce..d7a2d4821c 100644 --- a/ide/codehelp.pas +++ b/ide/codehelp.pas @@ -1217,7 +1217,7 @@ function TCodeHelpManager.GetHTMLHint(Code: TCodeBuffer; X, Y: integer; Complete: boolean; out BaseURL, HTMLHint: string; out CacheWasUsed: boolean ): TCodeHelpParseResult; const - le = '
'#13; + le = '
'+LineEnding; var IsHTML: boolean; @@ -1238,12 +1238,33 @@ var Result:=false; end; + function TextToHTML(const s: string): string; + var + p: Integer; + EndPos: Integer; + begin + Result:=s; + // replace line breaks with
+ p:=1; + while (p<=length(Result)) do begin + if Result[p] in [#10,#13] then begin + EndPos:=p+1; + if (EndPos<=length(Result)) and (Result[EndPos] in [#10,#13]) then + inc(EndPos); + Result:=copy(Result,1,p-1)+le+copy(Result,EndPos,length(Result)); + inc(p,length(le)); + end else begin + inc(p); + end; + end; + end; + procedure AddHTML(const s: string); begin if not IsHTML then begin IsHTML:=true; if HTMLHint<>'' then - HTMLHint:=HTMLHint+le+le; + HTMLHint:=TextToHTML(HTMLHint)+le+le; HTMLHint:=HTMLHint+s; end; end;