Interesting, and good to know. I always like to know implementation details. John On Sat, Jun 11, 2011 at 08:03:18PM -0600, Susan Jolly wrote: > StyledText by default represents the entire text of a document as a single > character array. So the only information it can know when it does a > modification is the index into the character array of where the > modification started and what characters were inserted or deleted. In the > case of an insertion, the size of the character array is increased, the > characters past the insertion point are shifted to the right, and the new > characters are inserted directly into the correct place in the array. In > the case of a delete, the size of the character array is decreased with the > relevant characters removed and the ones past the deletion point shifted to > the left. > > FYI, in practice, with an efficient implementation, there doesn't have to > be a shift every time a character is inserted since the character array > used for storage typically has a movable gap or empty section. (This > approach was apparently invented by the emacs developers.) If a character > is inserted or deleted, the gap is moved to the location after the > insertion or deletion position since usually someone using an editor makes > a number of consecutive insertions. However, the gap model is basically > hidden and when StyledText sends event information, the character positions > are the correct physical positions they would have if the storage array > didn't have a gap. > > Susan > -- John J. Boyer; President, Chief Software Developer Abilitiessoft, Inc. http://www.abilitiessoft.com Madison, Wisconsin USA Developing software for people with disabilities