PR #3473 <https://github.com/leo-editor/leo-editor/pull/3473> defines Leo's
first VNode generator, v.self_and_subtree generator.
This generator is more than a curiosity. It shows that for *some* purposes
VNodes can supplant positions. Here is the code:
def self_and_subtree(self) -> Generator:
"""
Yield v itself and all descendant vnodes.
It *is* valid for v to be c.hiddenRootNode
"""
v = self
seen: list[VNode] = [v]
to_be_visited = [z for z in v.children]
yield v
while to_be_visited:
v = to_be_visited.pop()
yield v
for child in v.children:
if child not in seen:
seen.append(child)
to_be_visited.append(child)
Not all Position generators have direct analogs in the VNode world. For
example, vnode generators can not emulate p.parents() and
p.self_and_parents() because VNodes may have multiple parent VNodes.
Otoh, a *v.all_parents()* generator might simplify Leo's code.
*Summary*
VNode generators are worth further investigation.
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 view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/82e4f1a5-6a70-4d40-b234-8760b6e4b2b2n%40googlegroups.com.