Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 51 of file undo.c.
Referenced by ME_CommitCoalescingUndo(), ME_CommitUndo(), ME_InsertRunAtCursor(), ME_InternalDeleteText(), ME_JoinParagraphs(), ME_PlayUndoItem(), ME_Redo(), ME_SetCharFormat(), ME_SetParaFormat(), ME_SplitParagraph(), and ME_Undo().
{ if (editor->nUndoMode == umIgnore) return NULL; else if (editor->nUndoLimit == 0) return NULL; else { ME_DisplayItem *pItem = ALLOC_OBJ(ME_UndoItem); switch(type) { case diUndoPotentialEndTransaction: /* only should be added for manually typed chars, not undos or redos */ assert(editor->nUndoMode == umAddToUndo); /* intentional fall-through to next case */ case diUndoEndTransaction: break; case diUndoSetParagraphFormat: assert(pdi); pItem->member.para = pdi->member.para; pItem->member.para.pFmt = ALLOC_OBJ(PARAFORMAT2); *pItem->member.para.pFmt = *pdi->member.para.pFmt; break; case diUndoInsertRun: assert(pdi); pItem->member.run = pdi->member.run; pItem->member.run.strText = ME_StrDup(pItem->member.run.strText); ME_AddRefStyle(pItem->member.run.style); if (pdi->member.run.ole_obj) { pItem->member.run.ole_obj = ALLOC_OBJ(*pItem->member.run.ole_obj); ME_CopyReObject(pItem->member.run.ole_obj, pdi->member.run.ole_obj); } else pItem->member.run.ole_obj = NULL; break; case diUndoSetCharFormat: break; case diUndoDeleteRun: case diUndoJoinParagraphs: break; case diUndoSplitParagraph: { ME_DisplayItem *prev_para = pdi->member.para.prev_para; assert(pdi->member.para.pFmt->cbSize == sizeof(PARAFORMAT2)); pItem->member.para.pFmt = ALLOC_OBJ(PARAFORMAT2); pItem->member.para.pFmt->cbSize = sizeof(PARAFORMAT2); pItem->member.para.pFmt->dwMask = 0; *pItem->member.para.pFmt = *pdi->member.para.pFmt; pItem->member.para.border = pdi->member.para.border; pItem->member.para.nFlags = prev_para->member.para.nFlags & ~MEPF_CELL; pItem->member.para.pCell = NULL; break; } default: assert(0 == "AddUndoItem, unsupported item type"); return NULL; } pItem->type = type; pItem->prev = NULL; if (editor->nUndoMode == umAddToUndo || editor->nUndoMode == umAddBackToUndo) { if (editor->pUndoStack && editor->pUndoStack->type == diUndoPotentialEndTransaction) { editor->pUndoStack->type = diUndoEndTransaction; } if (editor->nUndoMode == umAddToUndo) TRACE("Pushing id=%s to undo stack, deleting redo stack\n", ME_GetDITypeName(type)); else TRACE("Pushing id=%s to undo stack\n", ME_GetDITypeName(type)); pItem->next = editor->pUndoStack; if (type == diUndoEndTransaction || type == diUndoPotentialEndTransaction) editor->nUndoStackSize++; if (editor->pUndoStack) editor->pUndoStack->prev = pItem; else editor->pUndoStackBottom = pItem; editor->pUndoStack = pItem; if (editor->nUndoStackSize > editor->nUndoLimit) { /* remove oldest undo from stack */ ME_DisplayItem *p = editor->pUndoStackBottom; while (p->type !=diUndoEndTransaction) p = p->prev; /*find new stack bottom */ editor->pUndoStackBottom = p->prev; editor->pUndoStackBottom->next = NULL; do { ME_DisplayItem *pp = p->next; ME_DestroyDisplayItem(p); p = pp; } while (p); editor->nUndoStackSize--; } /* any new operation (not redo) clears the redo stack */ if (editor->nUndoMode == umAddToUndo) { ME_DisplayItem *p = editor->pRedoStack; while(p) { ME_DisplayItem *pp = p->next; ME_DestroyDisplayItem(p); p = pp; } editor->pRedoStack = NULL; } } else if (editor->nUndoMode == umAddToRedo) { TRACE("Pushing id=%s to redo stack\n", ME_GetDITypeName(type)); pItem->next = editor->pRedoStack; if (editor->pRedoStack) editor->pRedoStack->prev = pItem; editor->pRedoStack = pItem; } else assert(0); return (ME_UndoItem *)pItem; } }