On Thu, May 23, 2013 at 2:58 AM, Fidel Pérez <[email protected]> wrote:
> - Cutting and pasting multiple selected nodes, moving multiple selected
> nodes, etc, becomes trivial too with this approach.
There are several ways to deal with multiple cuts/pastes/inserts/whatever.
1. Make the changes in a place so that positions do not change. This is
what the clone-find-all commands do.
2. Do all the real work using vnodes. You might say that this is cleaner
conceptually.
The important distinction to understand is that Leo stores all data in
vnodes, including structure data. Provided that you don't create loops
from child to any ancestor, the v.children array may contain any node any
number of times. Of course, the other data structures must be updated
(carefully!). This is what the low-level vnode methods do.
Unfortunately, the higher-level methods that insert and move nodes are
*position* methods. These do the tricky work of calling the low-level
*vnode* methods. There aren't any higher-level vnode methods that
insert/delete/clone/move vnodes. Perhaps there should be.
The best advice I can give is first, to use method 1 if you can. If not,
then you have to do some real thinking in order to understand what vnodes
you want where. Once you have that figured out, you can either use
positions as helpers, or do all the work at the vnode level, using the
corresponding position methods as a rough guide.
Finally, you might look at Leo's cut/paste code in leoCommands.py. See the
node::
leoPy.leo#Code-->Core classes-->@file leoCommands.py-->
class commands-->Command handlers...-->Outline menu...-->
Top Level... (Commands)-->c.Cut & Paste Outlines
These are solving a simpler problem, but some of this code might be useful.
HTH. Please feel free to ask more questions.
Edward
--
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?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.