Can't copy Lazarus help text
lazarus / 13-General
----------------------------------------------------------------------
BobS · 2015-10-08 00:17
Windows 8.1:
When I use the Lazarus help system, I select some text (say a
procedure name) and right click and choose copy or hit Ctrl-C go to
the editor and try to paste to find the clipboard does not have what I
just copied.
Only way I've found is to go to the individual chm (or pdf) files from
which I can copy fine.
Closing and restarting the help system and then Lazarus made no
difference.
Tried searching for people with a similar problem couldn't find any:
any ideas?
----------------------------------------------------------------------
BobS · 2015-10-08 03:44
A little more:
Some things can be copied like certain parts of the text, but things
like procedure names can't.
I know it not that important but wondered if anyone else is having
this problem?
A detailed example:
Open Lazarus help, in search type 'arctan' and open the help page on
the arctan function. Now select 'arctan' and copy it. Now go
somewhere and try to paste.
At least on my system with 1.4.2 32bit on Windows 8.1 64bit this does
not work.
You can however go into the rtl.chm routines by unit/math/arctan and
copy the definition there.
So seems like something about how the help program is placing certain
types of text seems to be killing the copy ability.
----------------------------------------------------------------------
BitBangerUSA · 2015-10-08 03:57
i see the same in Windows 10 and Lazarus 1.4.2 - if you have used
CTRL-C and CTRL-V
the shortcut (CTRL-C) doesn't work - but right-clicking after
selecting the text in the help app does copy and then CTRL-V works as
expecting in another app.
additional - same-same issue in Windows 7 and Lazarus 1.4.0
----------------------------------------------------------------------
Leledumbo · 2015-10-08 06:29
I remember having this problem a little while ago, it even applies to
the source editor (can't ctrl+c - ctrl+v, but copy - paste context
menu works). Probably a bug in 1.4.2, try with 1.4.4. One thing for
sure, it no longer exists in current trunk.
----------------------------------------------------------------------
BobS · 2015-10-08 06:41
Good to know, though in 8.1 right click-copy doesn't work either. I
looked through the bug tracker before posting but didn't see anything,
oh well. At least I'm not going crazy. Thanks BitRanger, Lele.
----------------------------------------------------------------------
BobS · 2015-10-08 07:03
1.4.4. has the same bug. I can wait for the next stable release (for
some reason today I can't seem to type anything right which is why I
was using copy paste ).
----------------------------------------------------------------------
JuhaManninen · 2015-10-08 08:54
Quote from: BobS on October 08, 2015, 02:17:41 amTried searching for
people with a similar problem couldn't find any:
any ideas?
There is a bug report:
http://bugs.freepascal.org/view.php?id=21935
Unfortunately nobody is actively investigating it now. The TurboPower
component is nasty.
Ideas? Well, somebody should dive into the code and fix it.
----------------------------------------------------------------------
BobS · 2015-10-09 20:27
Lele says the problem is gone in current trunk. I'll see if I can get
it tonight and verify if it is still a problem or not under 8.1 (it's
been a long time since I used a repository ). If it is I'll see if I
can look into it once I'm finished with my current project which is
about getting me back up to speed on Lazarus/FPC.
----------------------------------------------------------------------
wp · 2015-10-09 21:23
Just uploaded a patch to the issue cited by Juha which catches the
CTRL+C and CTRL+INSERT key presses and copies the selected text to the
clipboard. Seems to work for me although I am not 100% sure if the
patch is at the correct location.
----------------------------------------------------------------------
BobS · 2015-10-10 07:10
Ok I downloaded 1.5 and made it. Still the same problem. So I
applied the patch suggested by wp and remade it and still the same
problem... I doubled checked I'd applied the patch in the correct
place.
----------------------------------------------------------------------
wp · 2015-10-10 09:56
Did you manually recompile lhelp? I think the IDE does not do this if
it finds an exe already.
[EDIT] I see now that selection is limited to one paragraph only...
----------------------------------------------------------------------
BobS · 2015-10-10 16:32
I checked the time it was recompiled.
----------------------------------------------------------------------
BobS · 2015-10-10 16:43
Since right click and choose copy doesn't work either, I'm wondering
if the problem is in lhelp. I'd need to watch in the debugger to
figure out exactly what's going on.
----------------------------------------------------------------------
wp · 2015-10-10 17:56
Can you open lhelp (it is in lazarus/components/chmhelp/lhelp) and
load any chm file? Select some text and copy it to the clipboard, then
paste it somewhere. Does it work? It does work here (Laz 1.5/fpc2.6.4,
Laz 1.4.4/fpc2.6.4, Win 7)...
Is the patch applied correctly? Load
lazarus/components/turbopower_ipro/iphtml.pas. The patch added the two
lines marked as "new" near the bottom of TIpHtmlInternalPanel.KeyDown:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i ... end
else if ((key = VK_C) or (key = VK_INSERT)) and (ssCtrl in Shift) then
// <--- new FHyper.CopyToClipboard
// <--- new else if (key = VK_A) and (ssCtrl in
Shift) then FHyper.SelectAll else inherited KeyDown(Key,
Shift);end;
Not 100% sure, but I see from the other key processing a bit up in the
code that there should be a "Key := 0" after "FHyper.CopyToClipboard"
to inhibit further processing of the key press. Could you try that?
(Of course, add a "begin"/"end" to enclose the "CopyToClipboard" and
the "Key := 0").
----------------------------------------------------------------------
paweld · 2015-10-10 18:44
turbopower_ipro has problem with copy data from html-table.
Quote from: BobS on October 08, 2015, 05:44:20 amA detailed example:
Open Lazarus help, in search type 'arctan' and open the help page on
the arctan function. Now select 'arctan' and copy it. Now go
somewhere and try to paste.
arctan page html-source:
Code: HTML5 [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
arctan
Calculate inverse
tangent
Declaration
Source position: mathh.inc line
73
Description
Arc
tan returns the Arctangent of X, which can be any
Real type. The resulting angle is in radial units.
----------------------------------------------------------------------
wp · 2015-10-10 19:34
paweld, I don't know what you want to say. ipro copies only text, no
html code - look at the source code:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i procedure
TIpHtml.CopyToClipboard;var S : string;begin if HaveSelection then
begin S := ''; if FHtml <> nil then
FHtml.AppendSelection(S); if S <> '' then begin
Clipboard.Open; try Clipboard.Clear;
Clipboard.AsText := S; finally Clipboard.Close; end;
end; end;end;
----------------------------------------------------------------------
BobS · 2015-10-10 22:17
The whole second "else if" isn't showing in the bug tracker.
Unfortunately it still doesn't work and running lhelp separately
doesn't make any difference. So I added the Key:=0 alas still nothing
gets copied to the clipboard. Is it possible win8.1 is doing
something weird? Unfortunately I don't have 7 anymore.
I think what paweld meant is it's only things in the table that's
can't be copied to the clipboard. I haven't looked at the
AppendSelecton routine is it possible it's returning a null string
when it sees certain html code?
Anyway thanks for your persistence in this.
----------------------------------------------------------------------
wp · 2015-10-11 09:48
Quote from: BobS on October 11, 2015, 12:17:58 amThe whole second
"else if" isn't showing in the bug tracker. Sorry, my fault, I had
copied from a modified source where I wanted to check if CRTL+A can be
used to select the full text (it works, but it is missing an
"Invalidate" to show the selection) - this "if" is absent in the
original.
QuoteIs it possible win8.1 is doing something weird? I don't think so.
I tested on Win 10. Initially it did not work (as I had seen also with
the other systems), but after some unimportant modifications which I
cannot remember it did work, and then also the original patch worked.
I have the feeling that the patched source is not compiled in
initially, but cannot imagine why. As a test you could add some syntax
error to the code to check if the compiler touches the patched source.
----------------------------------------------------------------------
BobS · 2015-10-11 11:23
Actually I did do that (made an error just after the patch text) and
indeed it was caught and when removed it compiled and the times were
correct.
----------------------------------------------------------------------
wp · 2015-10-11 12:05
Slowly running out of ideas...
One more maybe: Could you temporarily add a "WriteLn" to the KeyPress
method to see if the correct key is detected. And another one in
TIpHtml.CopyToClipboard to see which string is pasted to the
clipboard? And maybe one more in the if of the KeyPress for the
CTRL+C?
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i procedure
TIpHtmlInternalPanel.KeyDown(var Key: Word; Shift: TShiftState);var
TabList: TIpHtmlTabList;begin WriteLn('Key: 'Key, ' Shift = ',
[ord(Shift)]); // <--- new if (key = VK_TAB) and
TIpHtmlCustomPanel(Owner).WantTabs then begin TabList :=
FHyper.FTabList; //.... else if ((key = VK_C) or (key = VK_INSERT))
and (Shift = [ssCtrl]) then begin WriteLn('Key for
CopyToClipboard detected.'); // <--- new FHyper.CopyToClipboard;
Key := 0; end // ... procedure TIpHtml.CopyToClipboard;var S :
string;begin if HaveSelection then begin S := ''; if FHtml <>
nil then FHtml.AppendSelection(S); WriteLn('Copying to
clipboard: ', S); <--- new if S <> '' then begin
Clipboard.Open; try Clipboard.Clear;
Clipboard.AsText := S; finally Clipboard.Close; end;
end; end;end;
----------------------------------------------------------------------
JuhaManninen · 2015-10-11 13:06
I applied the patch in r50030 although it does not work very well.
More patches are welcome of course.
----------------------------------------------------------------------
BobS · 2015-10-11 16:01
Ok I added the writeln statements and compiled (after adding in the
missing ord ). Need a bit of guidance it's been like 20 years since
I did any console stuff, where is the output from these writeln
statements going and what do I need to do to see it? Running lhelp
from the console of course just runs lhelp in a window so no output
going there.
Also what's needed to use the debugger on these so I can just put a
breakpoint in ipHTML (old programmer trying to remember all this stuff
and pick up on the new things at the same time ).
I do appreciate your work on this, doing debugging by forum isn't
easy.
----------------------------------------------------------------------
wp · 2015-10-11 18:13
For the "WriteLn" method: Go to "Project options" / "Compiler options"
/ "Config and Target", uncheck "Win32 Gui application". This will
automatically open a console window when you run lhelp in which you
can see the WriteLn messages. Then select some text in the lhelp
window. Press CTRL+C.
On my system (where the patch is working) I get the following messages
(ah, and I replaced the "ord(shift)" by "integer(shift)"):
- "Key 17 Shift 4" (depending on how long the CTRL is is pressed this
may be repeated several times; 17 = CTRL key).
- "Key 67 Shift 4" (67 = $43 = VK_C -- see the VK_XXXX declarations in
lclType.)
- "Key for CopyToClipboard detected"
- "Copying to clipboard: "
If the "Key..." messages do not appear then the keyboard is not
correctly handled by IpHTMLPanel. If there is no text after "Copying
to clipboard" the FHtml.AppendSelection is faulty, as you already
suggested.
To use the debugger you have to rebuild the IDE in debug mode: "Tools"
/ "Configure Build Lazarus" / "Profile to build" --> "Debug IDE". In
the "Options" you may want to remove the "-gh" parameter which will
show an annoying memory leak report when you close Lazarus. Then click
"Build". After a while Lazarus will restart, and you will be able to
trace into the package sources. This procedure is necessary because
the unit that you want to debug is in an installed package, i.e. part
of the IDE.
Reload lhelp. Go to "Project options" again, "Compiler options",
"Build modes" - select "Debug".- Then "Debugging". Uncheck "Use
heaptrc unit" (there's a lot of memory leaks...). Then go to
"Additions and overrides", click in line "Stored in session", "Add",
"Add custom option", line "Targets: Custom" and type "-gw2" (this
enables dwarf-2 debug information for the entire project and all
modules).
Set a breakpoint by clicking into the gutter part of the source editor
at the line where you want to stop.
If you worked with the debugger in the old Turbo Pascal days you can
use the same keys if the key mapping scheme is "Classic"-
----------------------------------------------------------------------
BobS · 2015-10-11 19:13
The compiler just didn't like that first writeln for various reasons
so I rewrote like this:
WriteLn('Key= ',Key);
if ssCtrl in Shift
then writeln('Shift=ssCtrl')
else writeln('Shift not ssCtrl');
Then it finally dawned on me to just write to file I specified (duh).
So here's the output:
Key= 67
Shift=ssCtrl
Key for CopyToClipboard detected.
Copying to clipboard
and yet getting copied to the clipboard. The previous contents of the
clipboard remain.
----------------------------------------------------------------------
BobS · 2015-10-11 19:24
@wp I'll do that next time to get to the console window, anyway
writing to a specific file did the trick for now. When I tried type
casting using integer(shift), like the first think I though of , but
the compiler complained about the typecast which is when I just
rewrote it, maybe I've got some dang complier option set or not set.
On the dubug, I just tried a $D directive which did zilch, I'll
rebuild as you said, see if I can't trace things a bit... after maybe
some sleep which might make things clearer . Thanks for the help.
Long unused things are starting to come back.
----------------------------------------------------------------------
BobS · 2015-10-11 19:40
And "and yet getting copied to the clipboard. The previous contents
of the clipboard remain."
should have been "and yet NOT getting..."
----------------------------------------------------------------------
wp · 2015-10-11 19:56
Quote from: BobS on October 11, 2015, 09:13:29 pmThe compiler just
didn't like that first writeln for various reasons so I rewrote like
this:
WriteLn('Key= ',Key);
if ssCtrl in Shift
then writeln('Shift=ssCtrl')
else writeln('Shift not ssCtrl');
Then it finally dawned on me to just write to file I specified (duh).
So here's the output:
Key= 67
Shift=ssCtrl
Key for CopyToClipboard detected.
Copying to clipboard
and yet getting copied to the clipboard. The previous contents of the
clipboard remain.
I interpret this such that
- the keypress is detected and the CopyToClipboard function is entered
- but the string to be copied is empty (it would appear after "Copying
to clipboard" if you wrote the code as I proposed above)
So, we should dig into the selection handling of IpHTMLPanel
("AppendSelection"). Will be hard stuff, I guess...
----------------------------------------------------------------------
BobS · 2015-10-12 04:11
Yes, s is null string.
I got the debugger working on the IDE stuff. So I put a breakpoint on
the first line of TIpHtml.CopyToClipboard. Run the project and lhelp
opens and I select the text hit ctrl-c and nothing happens. So right
click choose copy and my breakpoint works (at the if HaveSelection...)
so a little strange but anyway I can trace down now maybe see what's
going on...
and I end up at TIpHtmlNodeMulti.AppendSelection in lpHtml. Go into
the for loop which repeatedly takes me the TIpHtmlNode.AppendSelection
procedure in the same unit. This has no code in it--this goes for a
few loops. But now I've been taken to
TIpHtmlNodeBlock.AppendSelection which at least has some code in it.
So in that procedure when I get to the for i := StartSelIndex to
EndSelIndex statement StartSelIndex=33 and EndSelIndex=33
that doesn't sound right 33 would be the end of my selection. So
looks like maybe something is going on in the while loop that
increments StartSelIndex. I'll look into that.
----------------------------------------------------------------------
BobS · 2015-10-12 06:15
I synchronized the trunk remade everything and now the breakpoint is
working when I hit ctrl-c; so now I'll dig in a bit.
----------------------------------------------------------------------
BobS · 2015-10-12 07:15
So I think the problem might be here:
in the function TIpHtmlNodeBlock.CheckSelection(aSelIndex: Integer):
Boolean;
at this statement:
R := CurElem.WordRect2;
when the calling proc, TIpHtmlNodeBlock.AppendSelection, has reached
the start of the selected text (when the var StartSelIndex=14)
then the values in CurElem.WordRect2 all turn to 0 and stay there and
the StartSelIndex just keeps counting up until its the end of the
selection rectangle when StartSelIndex=33.
I have no clue, for now, as to why the rectangle suddenly has all 0
values. But it seems to bypass checkselection getting set to false
until the end of the selection is reached.
I don't suppose this could be related to my using a 4k display? I did
try putting lhelp in the upper left corner of the display where it
would more normally return values associated with a lower res display
but it still doesn't work. I was thinking maybe some value somewhere
goes over what is anticipated by an old bit of code. I suppose I
could dig out my old 1080p display if anyone thinks this is a
possibility, though right now I don't think this is the problem.
----------------------------------------------------------------------
BobS · 2015-10-12 07:23
I managed to coax my monitor into 1080p long enough to check and as
expected this is not the problem.
----------------------------------------------------------------------
BobS · 2015-10-15 04:52
I've come back to look at this some more. Every time I open the Lhelp
project I end up with two copies of lpHtml in the source editor. I
think I read this can happen if there is a corruption in the project
file somewhere. Can someone try this and let me know if it's in the
trunk or just local to my computer? I did have some trouble
downloading the trunk until I went to svn2 and it seemed fine then.
----------------------------------------------------------------------
BobS · 2015-10-15 05:32
Well some success I'm in the right ball park, now I can get it to copy
the procedure name but it also copies everything else below it like
the description so I just need to figure out the correct conditional
to stop it at the end of the selection. Sorry to post so much about
this but hey partial success excites me at this point!
----------------------------------------------------------------------
BobS · 2015-10-15 06:00
One other thing I'd like to know is what units are dependent on
TFPList in Clasesh.inc is there a chart or some easy way of
determining this? The deeper I go the more danger of unintended side
effects. I think the underlying problem may be in there . I may not
be able to go any farther in CheckSelection towards a fix (the above
partial solution is really just taking advantage of the under lying
bug). There is one possibility I can think of, but then if the
underlying problem was ever fixed then the patch would need to be
removed.
----------------------------------------------------------------------
BobS · 2015-10-15 07:09
One last post before I quit for a bit. It's an all or nothing right
now, get all the text or none of it (well it's possible skip over some
by hardcoding). So really it comes down to figuring out why
PIpHtmlElement(FLayouter.FElementQueue is providing all 0 rectangles
for certain elements especially when they seem to get right to the
beginning of the selection: if I'm understanding how these rectangles
are working...going deeper seems the only way at this point (to making
sure they work how I think and to finding the problem). I'll quit for
a bit and come back to it fresh. I would like to know what else might
be using these lower down classes though.
I see why people are not too excited about digging into this stuff .
----------------------------------------------------------------------
BobS · 2015-10-15 07:21
I had one thought that just for my purposes since all the procedure
and function descriptions start with the name I could just truncate
the string at the first space. This wouldn't let me copy anything
else out of the help files of course.
----------------------------------------------------------------------
JuhaManninen · 2015-10-15 08:14
Quote from: BobS on October 15, 2015, 08:00:34 amOne other thing I'd
like to know is what units are dependent on TFPList in Clasesh.inc is
there a chart or some easy way of determining this?
TFPList is a low level list of pointers. It is lighter than TList and
is used in many places. It surely does not cause this CHMHelp copy
issue.
You can jump into its source code if you have FPC source path
configured in Lazarus. Do you have it?
Searching under chmhelp, I found TFPList in unit ChmProg which is part
of package
components/chmhelp/packages/idehelp/chmhelppkg.lpk.
You must open the package to make the IDE understand all its
dependencies.
QuoteI see why people are not too excited about digging into this
stuff .
I believe you will fix this bug if you continue with the same
attitude. Good luck!
----------------------------------------------------------------------
wp · 2015-10-15 10:40
I would be willing to help you, but I still don't understand why the
bug does not show up on my system. Maybe we are doing things
differently? Here is what I am doing, step-by-step:
Compile and run lhelpIn lhelp, select "File", "Open"Navigate to
(lazarus)\docs\chm, select fcl.chmDrag the mouse across the word
"Reference" (or some other text) which gets highlighted.Press CTRL+CGo
back to the Lazarus source editor: Paste the clipboard contents into
the source editor (My short-cut with the "Classic" key settings is
"SHIFT+INS", "CTRL+V" does not work with "Classic") --> There's the
word "Reference"!When I tried this sequence before writing this post I
observed that it did not work at the very first time. But the second
time it was ok. How often do you try to copy?
----------------------------------------------------------------------
rvk · 2015-10-15 11:20
Quote from: wp on October 15, 2015, 12:40:24 pmI would be willing to
help you, but I still don't understand why the bug does not show up on
my system. Maybe we are doing things differently? Here is what I am
doing, step-by-step:
Compile and run lhelpIn lhelp, select "File", "Open"Navigate to
(lazarus)\docs\chm, select fcl.chmDrag the mouse across the word
"Reference" (or some other text) which gets highlighted.Press CTRL+CGo
back to the Lazarus source editor: Paste the clipboard contents into
the source editor (My short-cut with the "Classic" key settings is
"SHIFT+INS", "CTRL+V" does not work with "Classic") --> There's the
word "Reference"!When I tried this sequence before writing this post I
observed that it did not work at the very first time. But the second
time it was ok. How often do you try to copy?I think that's not the
text BobS was talking about. (That text "Reference" copies correctly
for me)
Try the following:
Compile and run lhelpIn lhelp, select "File", "Open"Navigate to
(lazarus)\docs\chm, select fcl.chmDrag the mouse across the sentence
"Unit implementing blowfish...." which gets highlighted.Press CTRL+C
(or right-click and Copy)Go back to the Lazarus source editor: Paste
the clipboard contents into the source editor --> Nope, doesn't work!
----------------------------------------------------------------------
wp · 2015-10-15 11:38
Aah - we're getting closer. This does not work here too! I think the
source-code-formatted parts of the chm pages are coded as html-tables
which were demonstrated not to work a few posts above. You can even
drag across the entire text, but the code parts will not be in the
pasted text.
Maybe related: the IpNodeTableLayouter does not implement its own
Layout and Render methods - but I still have to learn all these
details, though.
----------------------------------------------------------------------
BobS · 2015-10-15 12:11
RVK posted while I was writing this, but I'll leave it as is.
I think I see one possible problem: there are some things that do and
always have copied it's procedure/function names that don't (and maybe
some other stuff I'm too tried to remember right now anyway it's the
names I'm more concerned with at the moment and probably once this is
fixed anything selected will copy correctly). For testing convenience
I'll paste into notepad but pasting anywhere won't work as no text
goes into the clipboard when it's not working.
I'm copying out of rtl.chm as it's where I'm most likely to be when I
want to copy something. It's easiest is to go to the Alphabetical
Routines List, click on 'A' select the first entry which is
AbondonSignalHandler -- though I've of course tested with others.
Select: I'm usually selecting down where the actual procedure is
defined as sometimes I'd want to copy the declarations too, but
selecting and copying the name at the very top of the section does not
work either.
It's quite clear that it's in TIpHtmlNodeBlock.AppendSelection where
the problem can be seen and indeed by bypassing this routine I get
everything in that section copied to the clipboard (in case of
AbondonSignalHandler it's the name down to the final sentence in the
description sub-section).
I just changed the code that starts at line 9016 to read:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i if
(R.Bottom <> 0) and (R.Top > Owner.FStartSel.Y) and (R.Bottom <
Owner.FEndSel.Y) or (R.Top=0)) then Exit(False)the or R.Top=0 is
what's added. At least on my system this condition will be met almost
immediately shortcutting the routine and returning a copy of the
entire text in the section. I can reduce the amount of leading
material included by doing something like this to the same line:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i if
(R.Bottom <> 0) and (R.Top > Owner.FStartSel.Y) and (R.Bottom <
Owner.FEndSel.Y) or ( (R.Top=0) and (aSelIndex>13)) then
Exit(False) but again quickly R.Top becomes 0 the above condtion is
met and I get the text from the point of aSelIndex.
I think these changes may be causing some instability as lhelp
sometimes crashes with a dump afterwards (and has to be killed in Task
Manager), but at this point they are just there for trying to get an
idea of the problem not solutions. Also as noted I may have a corrupt
version of the lhelp project. If you aren't getting two copies of
lpHtml then I need to re-download them (though I don't believe this to
be causing any issues).
What would be really helpful is to find out what some of these values
look like on a working system and compare them to mine. I can write
an exact step by step tonight including what exactly to copy and some
of the values I get. If you'd be willing to then do the same on your
system that would be great. I find it strange that there are a lot of
0 filled rectangles in the array but maybe that's normal however on my
system the routine never exits because with the 0 filled rectangles
the conditions never get met to exit with a false instead it just
seems to count up until the begin and end selection values are the
same causing a null string eventually to be returned (a bit more
detail on that in an earlier post).
I can do that hopefully tonight or tomorrow (got to get some sleep
first ). Anyway no rush this isn't like the most serious bug in the
world but it would be nice to squash it.
----------------------------------------------------------------------
BobS · 2015-10-15 12:36
Ok I just got lhelp to crash without any modifications. Maybe the
answer will come in a dream.
----------------------------------------------------------------------
wp · 2015-10-15 13:01
Do you work with the trunk version of Lazarus? In this case, just
delete the lhelp folder and do an "svn update" to go back to the
original version.
If you use a release version go to http://svn.freepascal.org/cgi-
bin/viewvc.cgi/tags/?root=lazarus, navigate to your version, then to
components/turbopower_ipro and download the files you destroyed. (Note
that my patch will not be included).
----------------------------------------------------------------------
wp · 2015-10-15 14:05
In reviewing the IpHTML code I found now that the patch submitted to
the bugtracker (now included in the current trunk version of Lazarus)
is probably not the most general case.
The IpHTMLPanel can contain several frames (TIpHtmlFrame) each of
which has its own HTML document (TIpHTML). The patch submitted
considers only the active frame. As I saw now TIpHtmlInternalPanel
which catches the key press has a function HTMLPanel which returns the
instance of the complete TIpHTML component.
Therefore, replace the "FHyper.CopyToClipboard" by
"HTMLPanel.CopyToClipboard" in my original patch.
It does not solve the issue that some parts of the HTML text are not
not copied to the clipboard, though. Interestingly, the original
Delphi version of Turbo Power works correctly as I found out with
Delphi 7. So, there's hope...
The original download of IPro contains also a pdf documentation which
helps to understand the classes in more detail
(http://download.sourceforge.net/tpipro/tpipro_docs.zip)
----------------------------------------------------------------------
wp · 2015-10-15 21:50
Bob, I don't think your R.Top discussion above is the root cause of
the issue. Since you see all these crashes the incorrect R.Top is just
the consequence of a bug somewhere else.
Based on the observation that the contents of html tables do not
appear in the clipboard I created a minimal html test file which you
can find in the attachment (testfile.html). It contains only tags for
a single-cell table plus two text paragraphs above and below the table
(as "anchors" for selection). This reduces the node tree for
debugging. (You can even remove the paragraphs above and below the
table element to speed up things even further).
Next, I no longer use lhelp for testing, but the project
htmlfileexplorer1 which you can find in the examples folder of the
turbopower_ipro directory. You can add the mentioned "testfile.hmtl"
as a command line parameter ("Run" / "Run parameters" / "Command line
parameters"), i.e. the test file is loaded immediately when the test
program starts.
Next, I implemented the CTRL+A shortcut to select the entire text ->
no more mouse dragging. For this purpose, go to
TIpHtmlInternalPanel.KeyDown once more and add these lines close to
the end:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i ... else
if ((key = VK_C) or (key = VK_INSERT)) and (Shift = [ssCtrl]) then
// copy to clipboard begin HtmlPanel.CopyToClipboard; Key :=
0; end // ----------- this is block new else if (key = VK_A) and
(Shift = [ssCtrl]) then // select all begin
HtmlPanel.SelectAll; Key := 0; end // ----------- end of new
block else if key = VK_RETURN then // return begin
...
Now it is easy to find the starting point for debugging: run the
htmlfileexplorer1, click into the html windows, press CTRL+A and
CTRL+C, and you are ready to begin debugging.
When stepping into the "CopyToClipboard" code I came into
"TIpHtmlNodeBlock.AppendSelection" which you already mentioned. At
first the program goes through the html elements in the i loop - there
are mostly LineFeed elements and word elements. Thats ok. But there is
also an "Object" element ("etObject" branch of the "case" instruction)
which must refer to the table. Digging into this we come back into the
same routine. But now the EndSelIndex is -1, i.e. the program jumps
over the i loop of the table and does not add anything from the table
to the clipboard string.
If I run a similar demo project with Delphi, EndSelIndex is 0 at the
same point. EndSelIndex is defined as "FLayouter.FElementQueue.Count".
Therefore, the next question is: Why does the layouter determine an
incorrect number of elements for a table node?
----------------------------------------------------------------------
BobS · 2015-10-16 03:41
Yes, as I said the underlying problem is deeper though I admit I
wouldn't have been adverse to a quick and dirty fix at least
temporarily but soon realized that wasn't going to happen (well except
for my idea, but not real versatile).
I'll take a detailed look at what you posted in awhile downloading the
TurboPower zip now; alas real life intruded and one of my dogs
disappeared last night and my energy went into searching for her today
to no avail probably coyotes or maybe a mountain lion got her a
problem dog always but I miss her though she didn't care much for my
reinterest in programming so maybe she just went to find a new home.
----------------------------------------------------------------------
BobS · 2015-10-17 03:10
Dog found several miles away on the other side of a dam...guess she
was indeed looking for a non-programmer to live with. So back to
this.
I'll look at the other project be good to skip lhelp for now and get
to the heart of the matter. I did finally get lhelp and tpower
restored something strange was going on but good now and I'm even all
synced up with pretty green checkmarks on everything.
I need to play around a bit more, get a better feel for what's going
on lower down (and hopefully have the right packages open as per
Juha's suggestion so I can debug in them ).
Glad the routines do work somewhere that's good. So I'll take a
little time to get a handle on this and report back with my findings
when it's clear in my brain.
Thought I'd get my self back up to speed by writing a nice RPN
calculator, but I'm spending more time on this now--I've always been
kind of bulldogged once I find a bug and it's making me do things I
might otherwise not have so that's all good.
----------------------------------------------------------------------
wp · 2015-10-18 15:10
Finally, I found some modifications which make the IpHtmlPanel behave
like in Delphi. Just copy the attached iphtml.pas over the existing
one (make a backup copy first!) and recompile the TurboPower_iPro
package.
Now it is possible to select text in a table and paste it to the
clipboard. Note, however, that no additional spaces or tabs are
inserted between cells, and no linefeeds between rows. Also, if
selection begins or ends within the table the text is not properly
highlighted, although the selection is correct. So - far from perfect,
but at least something. (BTW, the Delphi version is at the same level
of imperfection here).
To continue I'll have to better understand the inner structure of the
unit. The official docs cited above do help a lot, but it does not go
as deep as required to understand the details required. Selection of
text is done on the basis of "TIpHtmlElement"s stored in an
"ElementQueue" of some nodes. I could imagine that the elements could
be helpful for rendering the html tree. But I do not understand the
principles how the elements are created and assigned to the html tree
nodes.
My question: Does anybody have closer experience with the TurboPower
Internet Professional components who could explain this to me?
----------------------------------------------------------------------
JuhaManninen · 2015-10-18 16:40
Quote from: wp on October 18, 2015, 05:10:31 pmMy question: Does
anybody have closer experience with the TurboPower Internet
Professional components who could explain this to me?
I don't think anybody can.
I desperately tried to understand it some time ago. I refactored some
big functions into smaller pieces etc., and I was even able to fix one
rendering bug. It does not help much, there are lots of rendering
errors with any non-trivial HTML.
Especially nasty is :
procedure TIpNodeBlockLayouter.LayoutQueue
It has 2 nested while loops using the same loop variable, and that
variable is changed inside the loop based on some arbitrary
conditions.
I believe this method is the home of many rendering bugs.
It is possible that this component was made open source because it was
difficult to maintain.
----------------------------------------------------------------------
wp · 2015-10-19 12:06
Here's another iphtm.pas for testing. Now tab characters and
LineEndings are inserted between cells and rows, respectively, of a
pasted table.
----------------------------------------------------------------------
BobS · 2015-10-19 14:21
Very nice defiantly a big step forward. Now when I copy just a
procedure name I get up to 6 extra line feeds:
abs
The worst offender I've noticed is the abs function. But generally
seems to be at least two extra CR/LFs. Looks like it has to do with
multiple definitions so it seems like it's copying the
procedure/function names plus the CR/LFs from the following
definitions i.e. ABS has three function decelerations so we get 3*2
CR/LF.
And in the separate bug department I can get this:
AddChar
C: Char;
const S: ;
N: Integer
but it's kind of hit or miss since the full selection doesn't
highlight just the 'AddChar(' part. But at least it copies!
For usefulness it would actually be better if the LFs didn't return
when copying functions like this. Also note the () chars don't get
copied (the lack of the function type is a fault of the text not the
copy).
Note in this example that the trailing ) is included and also I get
no extra CR/LF:
Align
Addr: PtrUInt;
Alignment: PtrUInt
):PtrUInt;
What procedures are you making changes to in ipHTML? I'd like to
follow along.
Seems like there are multiple problems reading the HTML alas my
knowledge of HTML/chm is superficial.
----------------------------------------------------------------------
wp · 2015-10-19 15:16
As I said, its far from being perfect, but at least more than
nothing...
There are - at least - four more bugs:
#1: "Select all" (= CTRL+A) and dragging across the hole document
produce different results regarding additional line feeds - "Select
all" seems to insert additional line feeds after each row.
#2: The selection is not highlighted in the table part.
#3: The selection is not displayed correctly if selection starts
within a table part (note: the procedure declarations are coded as
HTML tables).
#4: Sometimes, no text is copied to the clipboard, it seems this
happens for the first time after lhelp is opened, but not always.
Let's see how to continue...
Here's what I changed:
At first, I tried to come to the same level as Delphi because the
sequence of CTRL+A and CTRL+C works fine there. After long searching I
found that the html node TIpHtmlNodeTR ("table row") had changed its
inheritance in rev 22561: Before that it interited from TIpHtmlCore
like in the Delphi version, afterwards from TIpHtmlNodeBlock. Being a
child of TIpHtmlNodeBlock means that it has an "FLayouter". I do not
know what's the purpose of that "layouter", but in the AppendSelection
procedure the count of the elements of that layouter is queried and
determines further processing of the html nodes. Having an additional
node with a layouter now disrupted this procedure. I introduced an
intermediate class ("TIpHtmlNodeColoredCore") between TIpHtmlNodeCore
and TIpHtmlNodeBlock because the NodeBlock takes care of text and
background colors, and derived the TIpHtmlNodeTR from this
intermediate class. Then the table cells did show up in the pasted
clipboard copy! But without tabs between the cells and linefeeds
between the rows.
To fix this I overwrote the AppendSelection of TIpHtmlNodeTD (cells)
and TIpHtmlNodeTR (rows) and inserted tabs and lineendings into the
accumulated strings if the current cell or row have at least one other
cell/row in front of them. That's probably where the flood of line
feeds that you see comes from because fpc's chm creation tools enclose
the cell text by a "p" node (paragraph) which seems to create a
linefeed on its own. - I think that should not be too difficult to
detect.
I do not fully understand what you mean with the AddChar example, I
see the same issues that I noted above.
----------------------------------------------------------------------
BobS · 2015-10-19 22:24
When in Lhelp if I drag the mouse over something like AddChar to get
both the procedure name and the parameters on the following lines only
AddChar( highlights, so you can't actually see everything you are
selecting, it actually took me two tries to get the entire thing.
I'll look and see if I can understand what you're doing I'll did into
those reference documents. I do think you should submit this as a bug
fix (unless you are going to work on it some more) since it's still a
big improvement over never being able to copy anything. It's been
interesting and a good learning experience so big Thank you for
working on this.
----------------------------------------------------------------------
wp · 2015-10-19 22:47
Quote from: BobS on October 20, 2015, 12:24:41 amWhen in Lhelp if I
drag the mouse over something like AddChar to get both the procedure
name and the parameters on the following lines only AddChar(
highlights, so you can't actually see everything you are
selectingThat's actually what I was referring to as items #2 and #3
above. I don't know if I can fix this one, but I'll try at least to
find the bug with the additionally inserted linefeeds.
----------------------------------------------------------------------
wp · 2015-10-20 19:17
Since these fixes seem to go in the right direction I uploaded an
improved iphtml.pas to trunk (r50130). It fixes the copy-to-clipboard
issue, adds a short-cut CTRL+A to select the entire page, and fixes
some display issues. LHelp definitely looking better now. Still plenty
of issues left, though...
----------------------------------------------------------------------
BobS · 2015-10-20 20:19
That's a good start though. Once I've got fully back up to speed I
may look into it some more but if you get inspired and beat me to it
I'll be happy. Anyway it will be nice to use lhelp for this instead
of a pdf reader. So one more way for Lazarus to improve upon Delphi!
(Well until they incorporate your fixes.)
----------------------------------------------------------------------
wp · 2015-10-28 16:27
A bunch of improvements has been applied to TurboPower_iPro: selection
works (almost) as expected now, and some annoying display issues have
been fixed. Please test. If ok I'll request backporting to Laz 1.4.6
----------------------------------------------------------------------
BobS · 2015-11-03 13:17
Looks good. Sometimes extra lines that weren't highlighted in the
selection get included but that's still better than not being able to
select across lines (for example in the abs function, I'll select one
of the definitions but get two or sometimes all three of them in the
clipboard; this doesn't happen if there is only one definition in the
declaration section).
In the example section, when copying an entire example after each line
of code there is now an extra empty line. This is the way it works in
1.4.4 but actually your previous fix changed this and there were no
extra lines, so something reverted. But this is a pretty minor
problem (in fact if it hadn't been corrected in the previous fix I
probably wouldn't have even noticed).
So I'd say this should be committed, it's definitely an
improvement...good work!