Hi!
I've started to implement the new kernel as I think it should be. The result
is attached as a zip-file (sorry), and this is what it can do so far:
* Build the buffer consisting of parboxes, paragraphs and chunks using a
polymorphic iterator-like object, the BufferIterator
* Print out the tree
* Print out the BufferIterators
* The general framework is up
When you insert objects into the tree, the engine will automatically build the
necessary containers, split existing containers as necessary, and make sure
that everything is consistent.
The BufferIterator supports operator++ and operation-- to perform an exhaustive
walk of the entire tree.
It's also close to being able to copy and delete in the data structure, and
thus it's very close to being able to support all operations that are needed in
order to load, save and manipulate a document (of course except for all the
parameters.)
There are still a few open design issues:
* Querying in detail of the data structure. (The BufferIterator does not
support dereferencing yet, but there are problems attached to this, because
deferencing a generic BufferIterator will result in different types according
to where in the tree it's pointing. I have a scheme up the sleeve to enable
const iterator derefencing, but without support for non-const iterators, it
might not be that interesting.)
* The BufferIterators are invalidated after manipulation of the representation.
We need to come up with a scheme to keep all iterators updated, even after
updating
* Presentation of the structure on the screen.
* Mapping from screen coordinates to BufferIterators in order to support screen
editing
I'll be off the list for the next few days, but please have a look, play a bit
with it, and then tell me what you think. I know there is not much
documentation in it, so things might be confusing. However, I decided to post
it anyway, since I won't have time to work on it for the next couple of days,
and when you get into the methodology, I think you'll agree that it's a nice
kernel.
The most interesting files in order:
* InsetBuffer.h
This is the main interface to the data structure. The methods in this class
takes care of the manipulation of the data structure. All buffer manipulation
is done through this class.
* BufferIterator.h
This is the generic, polymorphic iterator that spans the entire data structure.
In general, operations on this are constant time. A BufferIterator can thus
point to any point in the data structure, and thus serves perfectly as the
medium to define what to work on.
* InsetChunk.h, InsetParagraph.h, InsetParbox.h
These are the container insets that build the tree structure.
* InsetSequence.h
This is a template class that helps unifying the container insets.
* InsetSequenceIterator.h
This is a class that unifies the iterators of the containers. Used internally
to realize the BufferIterator.
The rest of the files should be pretty self evident.
I have many more ideas on how this stuff should evolve, but for now, here's
your chance to start hacking, give me input, or whatever you feel like.
Enjoy,
Asger
kernel.zip (WinZip File)