TextArea.StyledText rendering to RTF still extremely slow

Since 2014 there have been reports on slow RTF issues both here and on Feedback where by the way most entries are marked as fixed&Verified. However I am getting the spinning wheel of death with that line: ‘myStr = TextArea.StyledText.RTFData’ with a text of 200 lines… I believe there is still a problem to fix. I mean, rendering styled text into RTF is far too slow (any workaround?). On Windows by the way wit the same line you get the whole TextArea text scrolled up and down :-/

Stan

In fact, it always have been slow.

Up to date solution(s) ?

For larger text I acquired Formatted Text Control from http://bkeeney.com/

Try the RTFDataMBS method from MBS plugins. In some cases works much better.

styledtext.rtfData is still a dog and useless for text of even moderate length. In addition to MBS, if you’re writing for OS X check out the TextAreaExtension module in MacOSLib. It has some very useful and extremely fast methods, such as getting and setting the .RTFValue for a TextArea.

For OSX try this Xojo Forum Post

As the one who wrote the MacOSLib extensions for RTF (if I recall properly), I could say the MBS methods just use exactly the same methods, so using MBS or MacOSLib should be the same.

4276 characters
151 lines
seconds taken to load 0.3524155
with the standard Xojo styled text.append method
This includes numerous queries to the db and formatting
I do not call this slow

I stay away from rtf.data method as I found this stuffs up previous formatting

[quote=203403:@Gerd Wilmer]4276 characters
151 lines
seconds taken to load 0.3524155
with the standard Xojo styled text.append method
This includes numerous queries to the db and formatting
I do not call this slow

I stay away from rtf.data method as I found this stuffs up previous formatting[/quote]

But this only works when you already have the text into a StyledText object.
The matter here is how to read RTF data and transform it into a StyledText.

[quote=203407:@Massimo Valle]But this only works when you already have the text into a StyledText object.
The matter here is how to read RTF data and transform it into a StyledText.[/quote]

I can attest MacOSLib is way faster and allows much larger quantities of text. 30K hangs the app for good with native Xojo. It loads in less than a second with MacOSLib.

What MacOSLib function is? I tried TextArea.StyledText.RTFDataMBS, I don’t know if it is faster but I get the spinning wheel of death as well for a while.

The MacOSLib method is a TextArea extension, so that you write MyTextArea.RTFValue = sStringContainingRTFCode or aString = MyTextArea.RTFValue

Btw, as I already said I’m quite sure the MacOSLib and MBS use the same method, which is a call in the Cocoa framework (RTFFromRange:)

See TextAreaExtension, ReadRTFDFromFile.

[quote=203407:@Massimo Valle]But this only works when you already have the text into a StyledText object.
The matter here is how to read RTF data and transform it into a StyledText.[/quote]

Not correct Massimo
I start with a blank TextArea1 and step by step build it up with text from the db cursors (plenty of them)

[quote=203450:@Gerd Wilmer]Not correct Massimo
I start with a blank TextArea1 and step by step build it up with text from the db cursors (plenty of them)[/quote]

and what the db cursors contains?

Problem with the textarea on OS X is all kinds of text analyzers come to life when the text changes. I believe there had been a declare in an older XDev issue which switches these features on and off, boosting the update speed enormously. I only wish I knew where …

Edit: It was in 12.4, and it links to his article: http://www.realsoftwareblog.com/2012/11/speeding-up-textarea-modifications.html

Don’t know if it will help in this case, but could be worth a try.

[quote=203457:@Ulrich Bogun]Problem with the textarea on OS X is all kinds of text analyzers come to life when the text changes. I believe there had been a declare in an older XDev issue which switches these features on and off, boosting the update speed enormously. I only wish I knew where …

Edit: It was in 12.4, and it links to his article: http://www.realsoftwareblog.com/2012/11/speeding-up-textarea-modifications.html

Don’t know if it will help in this case, but could be worth a try.[/quote]

The problem is already known and discussed in many places.
Unfortunately the RTF standard is now quite a standard and this also makes things worst.
But really I still don’t know where the slowness of this RTF to StyledText come from.

[quote=203460:@Massimo Valle]The problem is already known and discussed in many places.
Unfortunately the RTF standard is now quite a standard and this also makes things worst.
But really I still don’t know where the slowness of this RTF to StyledText come from.[/quote]

I am sure there is much more than simple unoptimized code. Specifically, I had done a benchmark, and there is that treshold after which load time not simply augment proportionally, but exponentially, to reach quasi infinite pass 15 K.

I do not understand why, after all these years, the code in MacOSLib was never implemented within Xojo instead of the current disgrace. In Windows there must be some way to implement RichTextBox which has that natively built in as well.

I can only agree with you.
Only Xojo people can say something now.
Norman? :wink:

strings, numbers, dates, sometimes longer text strings like a newspaper paragraph

There are 8 sql queries. I know the fields for each query, but I have to test which cursors
contain rows and then which fields contain data.
That is why this is step by step approach
The queries are in no set order and are being repeated with different criteria as required