On Oct 5, 6:12 pm, "Edward K. Ream" <[email protected]> wrote:

> We can fix this and clean up the code (make the hack official) this way:
>
>     next = p.nodeAfterTreeAfterDelete()

A better name is p.nodeAfterDeletedTree().

As of rev 4543 the clone-marked-nodes and delete-marked-nodes commands
work and are undoable.  Furthermore, both the command code and the
undoer code are straightforward.  Here is the complete code for the
delete-marked-nodes command::

    def deleteMarked (self,event=None):

        """Delete all marked nodes."""

        c = self ; u = c.undoer ; p1 = c.p.copy()

        undo_data,p = [],c.rootPosition()
        while p:
            if p.isMarked():
                undo_data.append(p.copy())
                next = p.positionAfterDeletedTree()
                p.doDelete()
                p = next
            else:
                p.moveToThreadNext()

        if undo_data:
            u.afterDeleteMarkedNodes(undo_data,p1)
            g.es('deleted %s nodes' % (len(undo_data)),color='blue')
            c.setChanged(True)

        # Don't even *think* about restoring the old position.
        c.contractAllHeadlines()
        c.selectPosition(c.rootPosition())
        c.redraw()

This is an happy result, much better than expected.

The undo code is also simpler than other undo code, due to its vnode
orientation.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to