BOOL ME_Redo(ME_TextEditor *editor) { ME_DisplayItem *p; ME_UndoMode nMode = editor->nUndoMode; assert(nMode == umAddToUndo || nMode == umIgnore); if (editor->nUndoMode == umIgnore) return FALSE; /* no redo items ? */ if (!editor->pRedoStack) return FALSE; /* watch out for uncommitted transactions ! */ assert(editor->pRedoStack->type == diUndoEndTransaction); editor->nUndoMode = umAddBackToUndo; p = editor->pRedoStack->next; ME_DestroyDisplayItem(editor->pRedoStack); editor->pRedoStack = p; do { p->prev = NULL; ME_PlayUndoItem(editor, p); editor->pRedoStack = p->next; ME_DestroyDisplayItem(p); p = editor->pRedoStack; } while(p && p->type != diUndoEndTransaction); if (p) p->prev = NULL; ME_MoveCursorFromTableRowStartParagraph(editor); ME_AddUndoItem(editor, diUndoEndTransaction, NULL); ME_CheckTablesForCorruption(editor); editor->nUndoMode = nMode; ME_UpdateRepaint(editor); return TRUE; }
void ME_Redo(ME_TextEditor *editor) { ME_DisplayItem *p; ME_UndoMode nMode = editor->nUndoMode; assert(nMode == umAddToUndo || nMode == umIgnore); if (editor->nUndoMode == umIgnore) return; /* no redo items ? */ if (!editor->pRedoStack) return; /* watch out for uncommitted transactions ! */ assert(editor->pRedoStack->type == diUndoEndTransaction); editor->nUndoMode = umAddBackToUndo; p = editor->pRedoStack->next; ME_DestroyDisplayItem(editor->pRedoStack); do { ME_DisplayItem *pp = p; ME_PlayUndoItem(editor, p); p = p->next; ME_DestroyDisplayItem(pp); } while(p && p->type != diUndoEndTransaction); ME_AddUndoItem(editor, diUndoEndTransaction, NULL); editor->pRedoStack = p; if (p) p->prev = NULL; editor->nUndoMode = nMode; ME_UpdateRepaint(editor); }