On Mon, 23 Sep 2013 07:47:24 -0700 (PDT)
Fidel N <[email protected]> wrote:

> What should happen then with iterators that get the list of parents?
> Should c.p.parents() include that node?

I don't think so, Leo's data model is firmly established as a list of
top level nodes with no parent, so any changes to any existing methods
would require a ton of changes.  It wouldn't be hard to change
p.parents(), but hard to change all the callers of p.parents() which
weren't expecting that node to be included.

Cheers -Terry

> I like the idea very much btw.
> 
> On Monday, September 23, 2013 4:15:24 PM UTC+2, Terry wrote:
> >
> > I've run in to this many times, the 'insertBefore' example was just the 
> > most recent. 
> >
> > It seems to me that the API for handling top-level nodes is 
> > inconveniently inconsistent with the API for handling non-top-level 
> > nodes.  Here's my (corrected) insertBefore() snippet: 
> >
> > nd = p.insertAfter() 
> > nd.moveToNthChildOf(p.parent(), p.childIndex()) 
> > c.selectPosition(nd) 
> > c.redraw() 
> > c.editHeadline() 
> >
> > What's the simplest way to make it work when invoked on a top level 
> > node?  For top level nodes, p.parent() == None. 
> >
> > I can think of a few approaches, but they're quite verbose compared to 
> > the simplicity of the above.  Edward, perhaps you can show us your 
> > simplest solution to make that work with top-level nodes, and if it 
> > really is simple, then I'm wrong about the inconvenient inconsistency. 
> >
> > If I'm not wrong, then I wonder if it would be possible to add a method 
> > c.virtualRootPosition(), which would be a position that behaves as if 
> > it was the parent of top level nodes, so that in the above you could 
> > write: 
> >
> > nd.moveToNthChildOf(p.parent() or c.virtualRootPosition(), p.childIndex()) 
> >
> > Currently we have 
> >
> > c.hiddenRootNode - the vnode parent of all top level nodes 
> > c.rootPosition() - the first top level node, i.e. the node at the top 
> >                    of the tree display 
> > c.rootVnode()    - returns a *position*, alias for c.rootPosition()? 
> >
> > Is c.virtualRootPosition() doable?  It should support 
> >
> > c.virtualRootPosition().insertAsNthChild() 
> >     to create a new top level node 
> > c.virtualRootPosition().insertAsLastChild() 
> >     to create a new last top level node 
> >
> > currently 
> >
> > for nd in c.rootPosition().children(): 
> >     print nd.h 
> >
> > lists the children of the first top level node, which is not what I'd 
> > expect, but I'm not suggesting changing it.  But 
> >
> > for nd in c.virtualRootPosition().children(): 
> >     print nd.h 
> >
> > should do what you expect, same as c.all_positions(), the difference 
> > being that you could pass the value of c.virtualRootPosition() to a 
> > method expecting a position, which you can't do with c.all_positions(). 
> >
> > BTW, c.vnode2position(c.hiddenRootNode) does execute and return a 
> > position, but trying to use that position doesn't work.  Conceptually 
> >
> > def virtualRootPosition(self): 
> >     c = self 
> >     return c.vnode2position(c.hiddenRootNode) 
> >
> > but it's not that simple, understandably. 
> >
> > "virtualRootPosition" is just a name distinct from "rootPosition". 
> > Ideally you might rename rootPosition() firstPosition(), and call 
> > virtualRootPosition() rootPosition().  "realRootPosition" just seems 
> > wrong. 
> >
> > Cheers -Terry 
> >
> >
> 

-- 
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