Vitalije,

On Wed, Aug 21, 2019 at 5:41 PM vitalije <[email protected]> wrote:

> Well I didn't tried too hard to make it more readable. It can be improved.
>

Ok, after looking at it some more, I see that the vnode tree structure
involves only a list of children and a list of parents (one parent for each
clone). That's pretty straight forward and I added a few comments and it
seems plenty readable. I was able to change the code (without breaking it!)
so it creates the day node at the second position instead of the last
position. That is an important feature for me.


> But changing tree using vnodes has several benefits. First of all, vnodes
> are stable (immune to tree changes) - positions are not.
>

And I think this is what appeals the most to me.  With the position code, I
tried to factor out some common code, but it took two positions as input
(saved positions issue!) and for one of the cases I was using it, one of
the positions got invalidated. I suspect if I try to factor out some of the
vnode code in a similar way, it won't be as fragile as that.


> The second they work much faster because every change in the tree
> performed through positions are followed by a redraw and a lot of code that
> doesn't need to be executed until the complete tree change is done. You
> don't usually want to see intermediate versions of tree. You want to see
> the finished tree. When making changes using vnodes, nothing is redrawn
> until you explicitly call `c.redraw()`.
>

I took a quick look through the vnode code and only saw the redraw for .h
and .b changes, but not for the tree structure changes. Is that what you
are referring to or was there something else I missed?

 [...]

> The function make_snapshot creates a snapshot of data needed to recreate
> subtree structure. In the variant where no changes to headlines nor bodies
> are made, this function takes enough data to undo the changes. However if
> you need to keep record of headlines and bodies too, then you should add
> them too to snapshot. Of course  in that case you must change the function
> from_snapshot too.
>

Got it, thanks.

[...]

> This two functions can store and recreate the exact copy of the given
> vnode. If you want to make snapshot of the whole outline, pass the
> c.hiddenRootNode as the argument to the make_snapshot function. However, if
> you are certain that the only changes made are under one vnode (for example
> @ftlist node), then it is more efficient to store only subtree of @ftlist.
>

Thanks a lot for your help.

Brian

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAO5X8Cy_37DQ0ZXT%3D6Bs%2BO7q9-9B2g-s9hC9Vmfhn7HjXF-nWQ%40mail.gmail.com.

Reply via email to