Re: Adding string to Memo
- From: erewhon@xxxxxxxxxx (J French)
- Date: Sun, 30 Oct 2005 17:45:13 +0000 (UTC)
On Sun, 30 Oct 2005 11:03:47 -0800, Jamie
<jamie_5_not_valid_after_5_Please@xxxxxxxxxxx> wrote:
>J French wrote:
<snip>
>seems strange that i always thought delphi kept a copy of the string
>in the stringlist ? so where are you saving anything?
I wondered about that as well
- although I had a gut instinct that it was not the case (because the
complexity would be a nightmare) , so I did a bit of drilling into
Memo.Text and Memo.Lines.Text
Memo.Text does not go anywhere near Memo.Lines.Text (which is a
TStrings)
- it seems to go straight for the jugular (TControl WM_GETTEXT)
The thing that gave me a hunch is that re-assigning the entire text
using WM_SETTEXT would necessitate reformatting the wrapping for all
the data rather than on/after the changed data.
EM_REPLACESEL is the normal thing for inserting just one key while
typing into a multiline Edit control, so it has to be optimized to
minimize wrapping.
It all goes back to writing a word wrapping text editor in 1986, so
I'm sensitive to what /has/ to go on behind the scenes.
Basically the insertion of a character is 95% likely to take place on
the screen so you insert the character in the buffer and wrap from the
line before until the last /visible/ line.
Once one has got that trick, you look for insertion before or after
the display lines, and you check for 'wrapping needed', if not you
don't bother.
If somebody punches in a totally new document, then there is a 95%
chance that it /is/ totally new, even if it is really the same thing
with a minor tweak, you have to compare it up to the start of the
displayed area - just to be sure.
I'm not entirely sure how optimized EM_SETTEXT is, but I'll bet that
EM_REPLACESEL has the best that Billy's boys can throw at it.
I'll also bet that the text in a multi line Edit control is not stored
as one contiguous string in a chunk of memory
- rather it will be a sort of linked list ( v*mit ) so that insertion
minimizes memory movement.
What looks as graceful as a Swan on the surface, normally has feet
paddling frantically out of sight.
I enjoyed that digression
- and would be very interested if anyone could confirm or refute my
hypothesis.
BTW - for mass manipulation - grabbing the .Text and mutilating it is
definately more sensible, as one Edit control refresh will generate
far more activity than creating and destroying a few strings.
.
- References:
- Adding string to Memo
- From: Brian
- Re: Adding string to Memo
- From: Heinrich Wolf
- Re: Adding string to Memo
- From: Brian
- Re: Adding string to Memo
- From: Jamie
- Re: Adding string to Memo
- From: J French
- Re: Adding string to Memo
- From: Jamie
- Adding string to Memo
- Prev by Date: Re: Version after Version
- Next by Date: Transparent window
- Previous by thread: Re: Adding string to Memo
- Next by thread: Re: Adding string to Memo
- Index(es):
Relevant Pages
|