Kuba Ober wrote: > On Thursday 30 October 2003 11:26 am, Alfredo Braunstein wrote: >> Angus Leeming wrote: >> > Note that multiple BufferViews implies multiple Cursors. I'm sure >> > that I would be pissed off if I replaced "brown" with "red" in >> > one window and found that the cursor in my other BufferView had >> > also changed position. >> >> That's a very good point. > > I think that the only real solution is that the tree must know of > its iterators and adjust them if tree structure changes. > > I presume that it should call into existence a proper tree base > classes for leafs and nodes. I wonder if they exist in the current > design. [No time to look at the code, sorry :( ] > > Essentially, it should be tree's leaves and nodes which should be > able to know which cursors point at them. Since there will be > probably very few cursors in existence at any given time (say 10 or > something of that order), it's conceiveable that: > a) a tree element, upon each change, will look through the "global" > list of cursors to see which cursors point to it > b) it will adjust them per the pending change > > That also makes cursors invariants between changes to either tree > elements or cursor position, and makes all cursors automatically > always valid no matter what. > > Does it make any sense? Is that the direction you are going? Am I > talking rubbish? I'm just a bystander and overseer, but I would like > to know what pattern are you converging to in the long term.
It's pseudo-rubbish in that the lyx data structure is a tree in-concept only. It's actually a std::list<Paragraph> where each Paragraph contains a std::vector<char> and an InsetList. Insets are identified in the std::vector<char> by chars with value 'META_INSET' and a Buffer::inset_iterator class enables one to go from a (ParagraphList::iterator, lyx::pos_type) pair to the inset of interest. At least that is my understanding of things. Nonetheless, your basic idea is a good one. -- Angus