Wordwrap relatively long lines

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Wordwrap relatively long lines

Postby michael88 » Sun Mar 24, 2013 2:09 am

Hi,

I'm aware that RSTA (and virtually every other text editor) has problems with wordwrapping really long lines: viewtopic.php?f=11&t=277&p=490#p490 and viewtopic.php?f=10&t=620. However, I don't know if 1000-2000 characters qualify as long lines.

Here's a sample text:

Code: Select all
For the next eight or ten months, Oliver was the victim of a systematic course of treachery and deception. He was brought up by hand. The hungry and destitute situation of the infant orphan was duly reported by the workhouse authorities to the parish authorities. The parish authorities inquired with dignity of the workhouse authorities, whether there was no female then domiciled in 'the house' who was in a situation to impart to Oliver Twist, the consolation and nourishment of which he stood in need. The workhouse authorities replied with humility, that there was not. Upon this, the parish authorities magnanimously and humanely resolved, that Oliver should be 'farmed,' or, in other words, that he should be dispatched to a branch-workhouse some three miles off, where twenty or thirty other juvenile offenders against the poor-laws, rolled about the floor all day, without the inconvenience of too much food or too much clothing, under the parental superintendence of an elderly female, who received the culprits at and for the consideration of sevenpence-halfpenny per small head per week. Sevenpence-halfpenny's worth per week is a good round diet for a child; a great deal may be got for sevenpence-halfpenny, quite enough to overload its stomach, and make it uncomfortable. The elderly female was a woman of wisdom and experience; she knew what was good for children; and she had a very accurate perception of what was good for herself. So, she appropriated the greater part of the weekly stipend to her own use, and consigned the rising parochial generation to even a shorter allowance than was originally provided for them. Thereby finding in the lowest depth a deeper still; and proving herself a very great experimental philosopher.

Everybody knows the story of another experimental philosopher who had a great theory about a horse being able to live without eating, and who demonstrated it so well, that he had got his own horse down to a straw a day, and would unquestionably have rendered him a very spirited and rampacious animal on nothing at all, if he had not died, four-and-twenty hours before he was to have had his first comfortable bait of air. Unfortunately for, the experimental philosophy of the female to whose protecting care Oliver Twist was delivered over, a similar result usually attended the operation of her system; for at the very moment when the child had contrived to exist upon the smallest possible portion of the weakest possible food, it did perversely happen in eight and a half cases out of ten, either that it sickened from want and cold, or fell into the fire from neglect, or got half-smothered by accident; in any one of which cases, the miserable little being was usually summoned into another world, and there gathered to the fathers it had never known in this.

Occasionally, when there was some more than usually interesting inquest upon a parish child who had been overlooked in turning up a bedstead, or inadvertently scalded to death when there happened to be a washing—though the latter accident was very scarce, anything approaching to a washing being of rare occurrence in the farm—the jury would take it into their heads to ask troublesome questions, or the parishioners would rebelliously affix their signatures to a remonstrance. But these impertinences were speedily checked by the evidence of the surgeon, and the testimony of the beadle; the former of whom had always opened the body and found nothing inside (which was very probable indeed), and the latter of whom invariably swore whatever the parish wanted; which was very self-devotional. Besides, the board made periodical pilgrimages to the farm, and always sent the beadle the day before, to say they were going. The children were neat and clean to behold, when they went; and what more would the people have!

It cannot be expected that this system of farming would produce any very extraordinary or luxuriant crop. Oliver Twist's ninth birthday found him a pale thin child, somewhat diminutive in stature, and decidedly small in circumference. But nature or inheritance had implanted a good sturdy spirit in Oliver's breast. It had had plenty of room to expand, thanks to the spare diet of the establishment; and perhaps to this circumstance may be attributed his having any ninth birth-day at all. Be this as it may, however, it was his ninth birthday; and he was keeping it in the coal-cellar with a select party of two other young gentleman, who, after participating with him in a sound thrashing, had been locked up for atrociously presuming to be hungry, when Mrs. Mann, the good lady of the house, was unexpectedly startled by the apparition of Mr. Bumble, the beadle, striving to undo the wicket of the garden-gate.

'Goodness gracious! Is that you, Mr. Bumble, sir?' said Mrs. Mann, thrusting her head out of the window in well-affected ecstasies of joy. '(Susan, take Oliver and them two brats upstairs, and wash 'em directly.)—My heart alive! Mr. Bumble, how glad I am to see you, sure-ly!'

Now, Mr. Bumble was a fat man, and a choleric; so, instead of responding to this open-hearted salutation in a kindred spirit, he gave the little wicket a tremendous shake, and then bestowed upon it a kick which could have emanated from no leg but a beadle's.

'Lor, only think,' said Mrs. Mann, running out,—for the three boys had been removed by this time,—'only think of that! That I should have forgotten that the gate was bolted on the inside, on account of them dear children! Walk in sir; walk in, pray, Mr. Bumble, do, sir.'


If you activate wordwrap, and resize RSTA to take the full screen (or a big part of the screen), you'll notice it's a little slow to edit text: it's more evident when you keep pressed down one key.

Now, if you do the same thing, but resizing down RSTA's window, it starts to get faster.

With a normal RSTA size, all work fast. As you increase the size of the RSTA, things start to get slower.

JTextArea doesn't seem to have this problem.

Michael.
michael88
 
Posts: 4
Joined: Tue Mar 19, 2013 11:34 am

Re: Wordwrap relatively long lines

Postby robert » Sun Mar 24, 2013 8:17 pm

I can't reproduce slowdown with 2000-character lines, but I understand this is system dependent. On an "old" Core 2 Duo (going on 5 years old), it takes about 8000 characters before I notice any slowdown when holding down a key to insert text, and even then it's barely noticeable. But this isn't an excuse - line wrapping performance could certainly use some improving.

I never got around to exploring the possible improvements I mentioned in this thread, so I might take a look soon. Any improvements made before the upcoming 2.0.7 release are likely to be modest though.

To mitigate the issue, you can try disabling any features you don't absolutely need - code folding and mark-occurrences (surprisingly) are two features that can slow down RSTA, though they usually affect very long files rather than very long lines.
User avatar
robert
 
Posts: 760
Joined: Sat May 10, 2008 5:16 pm

Re: Wordwrap relatively long lines

Postby michael88 » Tue Mar 26, 2013 1:34 am

I was doing my testing also in a Core 2 Duo. But, like you said, it's not very noticeable, unless RSTA is maximized, but even then, there's no problem for normal text insertion. I just thought that perhaps, it could be a rendering problem, given that I don't have that issue with JTextArea or any other text editor. But don't worry. I'll see if I can test it in another machine.

Michael.
michael88
 
Posts: 4
Joined: Tue Mar 19, 2013 11:34 am

Re: Wordwrap relatively long lines

Postby robert » Tue Mar 26, 2013 3:24 am

I'm aware of what the root cause is, RSTA simply re-parses the entire line for syntax highlighting info way too many times, especially when line wrap is enabled. Today I thought of a possible solution to improve the line wrapping scenario, but again, I probably won't explore it until after this coming release. If I can find a micro-optimization though I might squeeze it in.
User avatar
robert
 
Posts: 760
Joined: Sat May 10, 2008 5:16 pm

Re: Wordwrap relatively long lines

Postby robert » Sat Jun 08, 2013 3:42 am

I've finally got an update for this. I'm making some rendering improvements that should help performance with long lines and word wrap. It'll be in SVN soon. It's a pretty major API change, so feedback before the release would be great if possible.
User avatar
robert
 
Posts: 760
Joined: Sat May 10, 2008 5:16 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 4 guests

cron