Example #1
0
/*
 * StartUndoGroupWithPosition - begin set of undos, save start position
 */
void StartUndoGroupWithPosition( undo_stack *stack, linenum lne,
                                 linenum top, int col )
{
    undo        *cundo;

    if( !EditFlags.Undo || stack == NULL ) {
        return;
    }

    cundo = UndoAlloc( stack, START_UNDO_GROUP );

    if( cundo == NULL ) {
        stack->OpenUndo++;
        return;
    }

    /*
     * check if there is an undo group in progress
     */
    if( stack->current >= 0 && stack->OpenUndo > 0 ) {
        stack->OpenUndo++;
        AddUndoToCurrent( cundo, stack );
        cundo->data.sdata.depth = stack->OpenUndo;
        return;
    }

    /*
     * no group active, make this the head group
     */
    stack->OpenUndo = 1;
    if( cundo == NULL ) {
        return;
    }
    cundo->data.sdata.depth = 1;
    cundo->data.sdata.p.line = lne;
    cundo->data.sdata.top = top;
    cundo->data.sdata.time_stamp = ClockTicks;
    if( col == 0 ) {
        col = 1;
    }
    cundo->data.sdata.p.column = col;
    PushUndoStack( cundo, stack );

    /*
     * check if we are adding something to the undo stack, and
     * if this is NOT during an undo operation.  If so, then we
     * cannot do an undo-undo, since there have been text changes
     */
    if( stack == UndoStack && !EditFlags.UndoInProg ) {
        PurgeUndoStack( UndoUndoStack );
    }

} /* StartUndoGroupWithPosition */
Example #2
0
/*
 * FreeAllUndos - release contents of all undo stacks
 */
void FreeAllUndos( void )
{
    PurgeUndoStack( UndoStack );
    PurgeUndoStack( UndoUndoStack );

} /* FreeAllUndos */