Forum > RichMemo

TRichMemo Windows-Only Multicolor Line and HTML Links Issue

<< < (5/6) > >>

evoshroom:

--- Quote ---I assume you have a _lot_ of text.
--- End quote ---

Not really.  I start out with no text and then it gets longer as the chat log gets longer.  The chat log is for an application in which every action in the application posts an entry to the chat log, so it gets long fast, but by the time the slow down starts it isn't that long.  One part of the application has a list of things you can scroll through with a key bind, each item you pass on the list causes a chat entry, plays a sound and activates a graphic.  If I just continuously do this within 20 or 30 seconds it become apparent that each item is taking longer and longer to do and playing its sound slower and slower because the chat log is adding an artificial delay.  After maybe 60 seconds of this, the delay starts becoming apparent in other ways.  For example, if you click an item 4 times that posts to the chat, the posts take time to process and happen visibility after you clicked.


--- Quote ---And that you're not reading text from a file, but rather loading longer and longer strings, which loads slower and slower.
--- End quote ---

That is correct.  It is a chat dialog, not a saved file.


--- Quote ---Try speeding up the parser before doing anything else. Open the htmlcomp.lpk package (Package | Open) and in Options on the Other tab, delete the conditional -dDebugIt. Now rebuild Laz and test your app again. The package should now be compiled with range-checking, etc. turned off. If that speeds up things, then you could look at the code in readhtml.pas where the parsing takes place and see if there are other little changes here that could speed up parsing even more.

To make sure you've built without DebugIt, look at HtmlComp.compiled (text file) under package/units and make sure it doesn't show -dDebugIt.
--- End quote ---

I did all of this.  I'm sure it sped things up but it didn't help the basic issue, which is that a larger and larger section of HTML is being reprocessed, when only the new entry to the list should be processed as HTML and the old parts should be left in their pre-processed states.


--- Quote ---Note that when you move up to the real deal, WebView, it appears to have the kind of things you need - see the replaceSelectionWithMarkupString: method:
--- End quote ---

I mentioned this before.  I can't ever move to WebView.  My code needs to be cross-platform.

I'm going to go digging through the code of THTMLView now itself to see how hard it would be to code a new ApprendFromString procedure.  If you have any further ideas or suggestions, feel free to let me know.  Thanks!

Phil:

--- Quote from: evoshroom on August 24, 2012, 03:44:05 am ---I'm going to go digging through the code of THTMLView now itself to see how hard it would be to code a new ApprendFromString procedure.  If you have any further ideas or suggestions, feel free to let me know.  Thanks!

--- End quote ---

The unparsed HTML will be in FDocumentSource; the parsed tags will be in FSectionList. Since the properties that reference these fields are read-only and the fields are in the protected section of the class declaration, you'll need to subclass THtmlViewer to get at them.

But it would appear as though simply appending new unparsed HTML to FDocumentSource and the parsed HTML to FSectionList might be all that's needed (followed by a Repaint or something). But it could also be somewhat more complicated than that.

Thanks.

-Phil

evoshroom:

--- Quote ---The unparsed HTML will be in FDocumentSource; the parsed tags will be in FSectionList. Since the properties that reference these fields are read-only and the fields are in the protected section of the class declaration, you'll need to subclass THtmlViewer to get at them.

But it would appear as though simply appending new unparsed HTML to FDocumentSource and the parsed HTML to FSectionList might be all that's needed (followed by a Repaint or something). But it could also be somewhat more complicated than that.
--- End quote ---

What I did first was mirror LoadFromString and LoadString into AppendFromString and AppendString.  That fixed the protected problem like you said.  I modified the AppendString version to add to FDocumentSource instead of replacing it with the input Source string.  That part was easy since FDocumentSource is just a string.  At this point AppendFromString can be called from the program and will append a string to the DocumentSource.  However, it still also will parse the whole document leading to my lag issue, as is to be expected, because I haven't quite figured out how to add to FSectionList instead of having the whole document be parsed.

FSectionList is a TSectionList, which is a datatype I'm not familiar with.  I saw some .Add-type properties, but only to add lists, pointers or TSectionBase's.  Also, since it may be relevant the original code has a:


--- Code: ---if Ft = HTMLType then
    ParseHTMLString(FDocumentSource, FSectionList, FOnInclude, FOnSoundRequest, HandleMeta, FOnLink)
  else
    ParseTextString(FDocumentSource, FSectionList);
--- End code ---

The two parse functions seem to also be tied to the display, as if I changed what was parsed to just the input string by changing FDocumentSource to Source I only ever got the input string on the THTMLView.  I also noticed the FSectionList is tied to the display in it's .create, so I guess that makes sense.  I took a good look at ParseHTMLString and ParseTextString procedures, but I find them somewhat confusing to understand.

So, I'm almost there, but could use some assistance.  Any ideas how I can translate the input Source string into something the FSectionList would understand and add it to it?  Thanks for all your help!

evoshroom:
I've been bashing my head against this all night.  %)  Once you get into the Readhtml.pas so many things are using global variables it's hard to tell what is changing what and what to modify.  It looks like ParseHTMLString is what needs to be copied and reversioned as an AppendAndParseHTML procedure (or perhaps other procedures that ParseHTMLString relies on), but everything seems interdependent instead of modular in this .pas file so I am finding it horribly confusing.  I'm going to take a break and hopefully when you next read this you can maybe give me a clue.  %) %) %)

Phil:

--- Quote from: evoshroom on August 24, 2012, 12:28:41 pm ---I've been basing my head against this all night.  %)  Once you get into the Readhtml.pas so many things are using global variables it's hard to tell what is changing what and what to modify.  It looks like ParseHTMLString is what needs to be copied and reversioned as an AppendAndParseHTML procedure (or perhaps other procedures that ParseHTMLString relies on), but everything seems interdependent instead of modular in this .pas file so I am finding it horribly confusing.  I'm going to take a break and hopefully when you next read this you can maybe give me a clue.  %) %) %)

--- End quote ---

Welcome to the world of porting code.

I don't really see what you mean by global variables. ParseHTMLString is a standalone function that you should be able to call as needed - it's not part of a class.

In your AppendAndParseHTML, maybe parse what you want to append into variables local to AppendAndParseHTML, then append them to the object's FDocumentSource and FSectionList. A section list is just a TList - see FPC docs for more on TList. Also see comments at top of readhtml.pas.

Thanks.

-Phil


Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version