Recent

Author Topic: Tooltip formating  (Read 19267 times)

yamer

  • Jr. Member
  • **
  • Posts: 87
Tooltip formating
« on: July 21, 2015, 03:06:15 pm »
Hi all,

When I leave my mouse cursor on an identifier Lazarus displays a tooltip showing the comment just before the identifier declaration.

See: tooltip.png

Is there a way to tell Lararus keep original comment indentation ?

Original comment: comment.png

Thanks

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: Tooltip formating
« Reply #1 on: July 22, 2015, 01:09:29 am »
It's maybe no solution, just a workaround
Code: [Select]
{** Procedure Execute

  This procedure will :
    - Go Up
    - Go Down
    - And Running again
}
Procedure Execute [...]     
Replace every second space (#32) with specialspace (#255) then the trim-function has nothing to trim.
 
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

yamer

  • Jr. Member
  • **
  • Posts: 87
Re: Tooltip formating
« Reply #2 on: July 22, 2015, 06:34:08 pm »
Thank you, but I'm afraid that this approach makes the comments too difficult to edit for me.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4574
  • I like bugs.
Re: Tooltip formating
« Reply #3 on: July 22, 2015, 07:08:33 pm »
Is there a way to tell Lararus keep original comment indentation ?

No but it should be kept.
The rendering is done by the IPro package which is full of bugs. If somebody can improve the indentation, good.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

yamer

  • Jr. Member
  • **
  • Posts: 87
Re: Tooltip formating
« Reply #4 on: July 22, 2015, 08:02:07 pm »
The rendering is done by the IPro package which is full of bugs. If somebody can improve the indentation, good.

I just tried without IPro package and the problem is still there. Maybe IPro is not involved.

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: Tooltip formating
« Reply #5 on: July 22, 2015, 08:14:43 pm »
Is there a way to tell Lararus keep original comment indentation ?

No but it should be kept.
The rendering is done by the IPro package which is full of bugs. If somebody can improve the indentation, good.
Is it good for a bug-report ?
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

yamer

  • Jr. Member
  • **
  • Posts: 87
Re: Tooltip formating
« Reply #6 on: July 22, 2015, 10:17:31 pm »
I managed to improve the rendering with TurboPower IPro. I post the patch here so that interested people can test it and make corrections. If there are no major problems I'll post the patch to the bug tracker.
« Last Edit: July 22, 2015, 10:21:47 pm by yamer »

rvk

  • Hero Member
  • *****
  • Posts: 6777
Re: Tooltip formating
« Reply #7 on: July 22, 2015, 11:08:36 pm »
Haha.. yeah, that works too. You just replace <span> by <pre> :)

I was more thinking in the line of replacing space by &nbsp; in TCodeHelpManager.TextToHTML procedure.

Your method has the downside that is displays in courier font.

Code: [Select]
function TCodeHelpManager.TextToHTML(Txt: string): string;
var
  p: Integer;
begin
  Result:=Txt;
  p:=length(Result);
  while p>0 do
  begin
    case Result[p] of
    ' ': Result:=copy(Result,1,p-1)+'&nbsp;'+copy(Result,p+1,length(Result)); // <-- this one
    '<': Result:=copy(Result,1,p-1)+'&lt;'+copy(Result,p+1,length(Result));
    '>': Result:=copy(Result,1,p-1)+'&gt;'+copy(Result,p+1,length(Result));
    '&': Result:=copy(Result,1,p-1)+'&amp;'+copy(Result,p+1,length(Result));

Works too and keeps a nice proportional font.

yamer

  • Jr. Member
  • **
  • Posts: 87
Re: Tooltip formating
« Reply #8 on: July 22, 2015, 11:38:43 pm »
Your method has the downside that is displays in courier font.
...
Works too and keeps a nice proportional font.
For me it is a fixed width font, but not the courier font. The style sheet 'lazdoc.css' asks for a fixed font and I guess it's your system that chooses the courier font.

In my opinion, a monospace font seems a better choice since a comment may contain code examples, tables, or ASCII art.
« Last Edit: July 22, 2015, 11:40:35 pm by yamer »

rvk

  • Hero Member
  • *****
  • Posts: 6777
Re: Tooltip formating
« Reply #9 on: July 22, 2015, 11:58:31 pm »
Your method has the downside that is displays in courier font.
For me it is a fixed width font, but not the courier font. The style sheet 'lazdoc.css' asks for a fixed font and I guess it's your system that chooses the courier font.

In my opinion, a monospace font seems a better choice since a comment may contain code examples, tables, or ASCII art.
You are absolutely correct. I failed to apply the entire patch  :-[

But for me the font is still proportional now. Indentation is correct. Mmm, I must have done something else wrong.

But you're right. A fixed width font would be better because of alignment in the source (which is also fixed width).


rvk

  • Hero Member
  • *****
  • Posts: 6777
Re: Tooltip formating
« Reply #10 on: July 23, 2015, 12:17:30 am »
I didn't find yet why the font is still proportional for me...

But I did find a potential problem.
You removed the TextToHTML-function call with LastComment.

That would mean that < and > is not translated into HTML.
This would mean tags in the comments will also be interpreted as HTML.

This could of course be an advantage (using tags in comments) but it's not the same behavior as the standard.

Edit:
I do think you need to add Courier to the font-family line.
Code: [Select]
/* comments in source fragments */
pre.comment {
  color: darkcyan;
  font-family: Courier, monospace;
}
This is also done on line 32 of that file (for tt, span.keyword, pre)
Otherwise it doesn't display a fixed width font for me.

(I'm puzzled why it would for you.)

Now I only have the problem that the urls in the hint don't work most of the time :(
« Last Edit: July 23, 2015, 12:32:38 am by rvk »

yamer

  • Jr. Member
  • **
  • Posts: 87
Re: Tooltip formating
« Reply #11 on: July 23, 2015, 01:14:51 pm »
But I did find a potential problem.
You removed the TextToHTML-function call with LastComment.

That would mean that < and > is not translated into HTML.
This would mean tags in the comments will also be interpreted as HTML.

This is a big problem ! I'm going to correct it.

yamer

  • Jr. Member
  • **
  • Posts: 87
Re: Tooltip formating
« Reply #12 on: July 23, 2015, 01:30:23 pm »
rvk, your idea of using non-breaking spaces is much better than mine.Your idea of using non-breaking spaces is much better than mine.

With your idea an a font change in the style sheet the result seems pretty good. There is still a slight indentation problem of disposal of the heading '{', '(*' and '//' from the comment.




jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: Tooltip formating
« Reply #13 on: July 23, 2015, 01:53:21 pm »
I come across another problem, using the <pre>-tag instead of the span and TextToHTML:
my comments in the Hint looked like this:
Code: [Select]
Line 1

Line 2

Line 3
This is because in TextToHTML the <br> is inserted before the CrLf
With:
Code: [Select]
function TCodeHelpManager.TextToHTML(Txt: string): string;
var
  p,po: Integer; // <-- New Variable here
begin
  Result:=Txt;
  p:=length(Result);
  while p>0 do
  begin
    case Result[p] of
    ' ',#255: Result:=copy(Result,1,p-1)+'&nbsp;'+copy(Result,p+1,length(Result));
    '<': Result:=copy(Result,1,p-1)+'&lt;'+copy(Result,p+1,length(Result));
    '>': Result:=copy(Result,1,p-1)+'&gt;'+copy(Result,p+1,length(Result));
    '&': Result:=copy(Result,1,p-1)+'&amp;'+copy(Result,p+1,length(Result));
    #10,#13:
      begin
        po:=p; // <-- Saving the old Position
        if (p>1) and (Result[p-1] in [#10,#13]) and (Result[p-1]<>Result[p]) then
          dec(p);
        Result:=copy(Result,1,p-1)+'<br>'+copy(Result,po+1,length(Result)); // <-- using the 'Old Position'
      end;
    end;
    dec(p);
  end;
end;
Removing the CrLf it works for me.
Maybe a parameter preformated:boolean := false; is the more flexible solution.
« Last Edit: July 23, 2015, 01:54:53 pm by jc99 »
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: Tooltip formating
« Reply #14 on: July 23, 2015, 02:08:21 pm »
I just noticed, there is also a problem with tabs (#9)
Code: [Select]
{** procedure Execute

  This procedure will :
        - Go Up
    - Go Down
      - And Running again
}                 
1. Line Blank only
2. Line 1 tab
3. Line 2 blank 1 tab
Result in: see picture:
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

 

TinyPortal © 2005-2018