On Friday, October 18, 2013 4:56:25 AM UTC-5, Edward K. Ream wrote:
>
> On Wed, Oct 16, 2013 at 3:12 AM, Fidel N <[email protected]> wrote:
>
> So the first suggestion I would like to do is for the expanding-clone 
>> behaviour.
>> When you select a clone, and expand its tree, all the clones in the full 
>> outline will do the same thing. 
>>
>
> There is no reasonable way to change this behavior.  The expansion state 
> of an outline node is carried by it's corresponding vnode.  Now that you've 
> read the new tutorial, you know that vnodes represent *all* clones of an 
> outline node.
>
> One could image a scheme in which the outline keeps track of the expansion 
> state of *positions*, not vnodes.  Again, now that you've read the new 
> tutorial, you will know how iffy that would be: positions become invalid 
> when the outline changes.
>

OMG: there *is* a way!  It's not foolproof, but it doesn't need to be.

The idea is store "ephemeral" or position-related data **in vnodes*.  This 
is a completely new idea in Leo's history!

Suppose every vnode contains a new ivar: v.expandedPositions, a list of 
(copies of) positions at which v is to be expanded.  This would work as 
follows:

1. Contracting a node at position p clears p.v.expandedPositions. The happy 
side effects is that contracting any clone
   will contract them all.

2. Expanding a node at position appends p.copy() to p.v.expandedPositions, 
and purges any no-longer-existing positions from that list.

3. Leo's drawing code will call c.shouldBeExpanded(p) (instead of 
p.isExpanded()) to determine whether to expand the outline node at position 
p.  c.shouldBeExpanded(p) will be something like::

    def shouldBeExpanded(self,p):
        c,v = self,p.v
        if p == c.p or p.isAncestorOf(c.p):
            return True
        if v.isExpanded():
            v.expandedList = [z for z in v.expandedList if 
c.positionExists(p,root=p.v)]
            for p2 in v.expandedList:
                if p == p2:
                    return True
        return False

As always, changing outline structure will invalidate positions.  Because 
c.p and all it's ancestors are always expanded, the worst that can happen 
when an outline changes is that some positions that *aren't* the present 
position will contract unexpectedly.  Most such contraction will occur off 
screen.

This is a most unexpected development. It won't happen in Leo 4.11b1: too 
much testing is required. It will probably happen for b2.

Edward

P.S. We could  add v ivars for other kinds of data, such as marks, but 
that's not going to happen.  I think this trick is appropriate only in very 
special circumstances. Furthermore, vnodes should be as small as possible.

EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to