Example #1
0
/*
 * EndUndoGroup - end set of undos
 */
void EndUndoGroup( undo_stack *stack )
{
    undo        *cundo;
    int         done;

    if( stack == NULL || !EditFlags.Undo ) {
        return;
    }
    if( stack->current < 0 ) {
        if( EditFlags.UndoLost ) {
            stack->OpenUndo--;
            if( stack->OpenUndo == 0 ) {
                EditFlags.UndoLost = FALSE;
            }
        }
        return;
    }
    cundo = UndoAlloc( stack, END_UNDO_GROUP );

    /*
     * decrement the open count and add element
     */
    stack->OpenUndo--;
    if( cundo == NULL ) {
        if( stack->OpenUndo == 0 ) {
            EditFlags.UndoLost = FALSE;
        }
        return;
    }
    AddUndoToCurrent( cundo, stack );

    /*
     * if we have just closed a group, make sure there is something
     * to do; if not, take this item off.  this gets rid of all those
     * annoying undo events created for something that didn't modify
     * the file
     */
    if( stack->OpenUndo == 0 ) {
        done = FALSE;
        for( ; cundo != NULL; cundo = cundo->next ) {
            if( cundo->type != START_UNDO_GROUP && cundo->type != END_UNDO_GROUP ) {
                done = TRUE;
                break;
            }
        }
        if( !done ) {
            cundo = PopUndoStack( stack );
            UndoFree( cundo, FALSE );
        }
    }

} /* EndUndoGroup */
Example #2
0
/*
 * dropUndoStackTop - clear top of undo stack
 */
static void dropUndoStackTop( undo_stack *stack )
{
    int i;

    if( stack->current < 0 ) {
        return;
    }
    UndoFree( stack->stack[0], true );
    for( i = 1; i <= stack->current; i++ ) {
        stack->stack[i - 1] = stack->stack[i];
    }
    stack->rolled = true;

} /* dropUndoStackTop */
Example #3
0
/*
 * PurgeUndoStack - do just that
 */
void PurgeUndoStack( undo_stack *stack )
{
    int i;

    if( stack == NULL ) {
        return;
    }

    for( i = stack->current; i >= 0; i-- ) {
        UndoFree( stack->stack[i], true );
    }
    MemFreePtr( (void **)&(stack->stack) );
    stack->current = -1;

} /* PurgeUndoStack */