|
O Rich Text Brother, Can You Paradigm? I've been meaning to comment on this article that Ben wrote about "Chunks". Paul Ryan raised a valid point in his comment, but I think both Ben and Paul have both missed an opportunity. Actually, I doubt either are missing the concept... it's just that neither of them stated it The point I want to make is that chunks and cursors are both really examples of an even more general concept of "selection". A selection is a group of chunks, not necessarily (in fact probably not) contiguous). In other words, it is one or more parts of the whole. A chunk is a position and an extent, sufficient to uniquely identify one part of the whole. It doesn't matter whether the position is absolute or relative, and it doesn't matter whether the extent is defined forward or backward from the position. It's still a chunk.
A cursor is a chunk with a null extent. It is just a position, still possibly defined via an absolute or relative reference. It contains nothing.
You really should be able to do any rich text operation on a selection, meaning you should be able to insert before a selection or append after it -- so effectively you should be able to do a single operation that inserts one or more copies of new data in front of one or more chunks, or append the one or more copies of new data after one or more chunks. You should also be able to apply the same modification to the contents of one or more chunks Naturally, if the selection consists of one chunk instead of several, these operations should work the same way as the do when the selection consists of more than one chunk. And if the selection is just one chunk with no extent, or if one of the many chunks within a selection has no extent (i.e., it is really a cursor), then you should also be able to do the same things, but of course modifying the contents of a null extent is a no-op.
|