Exemple #1
0
def next_selection(obj):
    if isinstance(obj, mutable.Document):
        return mutable.Selection(obj, len(obj))
    index = obj.parent.index(obj)
    if mutable.isstruct(obj.parent):
        if index + 1 < len(obj.parent):
            nxt = obj.parent[index+1]
            if mutable.islist(nxt):
                return mutable.Selection(nxt, 0)
            else:
                return nxt
        else:
            return next_selection(obj.parent)
    else:
        return mutable.Selection(obj.parent, index+1)
Exemple #2
0
def prev_selection(obj):
    if isinstance(obj, mutable.Document):
        return mutable.Selection(obj, 0)
    index = obj.parent.index(obj)
    if mutable.isstruct(obj.parent):
        if index > 0:
            nxt = obj.parent[index-1]
            if mutable.islist(nxt):
                return mutable.Selection(nxt, len(nxt))
            else:
                return nxt
        else:
            return prev_selection(obj.parent)
    else:
        return mutable.Selection(obj.parent, index)