X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fundo_funcs.C;h=96d5497491b371cf036bd55a3747402be7032184;hb=5d3718cad2a2ef6a4d6a495054ab0705ba27b6b5;hp=4b67dfa20d7efbcc3dd3c6c42117df4d64477ad9;hpb=6894fa6008fcb92d385dade7168b09b3e4cb128f;p=lyx.git diff --git a/src/undo_funcs.C b/src/undo_funcs.C index 4b67dfa20d..96d5497491 100644 --- a/src/undo_funcs.C +++ b/src/undo_funcs.C @@ -9,10 +9,6 @@ #include -#ifdef __GNUG__ -#pragma implementation -#endif - #include "undo_funcs.h" #include "lyxtext.h" #include "BufferView.h" @@ -31,7 +27,7 @@ using boost::shared_ptr; /// the flag used by FinishUndo(); bool undo_finished; -/// FIXME +/// whether actions are not added to the undo stacks bool undo_frozen; namespace { @@ -105,7 +101,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo) // replace the paragraphs with the undo informations - Paragraph * tmppar3 = undo.par; + Paragraph * undopar = undo.par; undo.par = 0; /* otherwise the undo destructor would delete the paragraph */ @@ -113,17 +109,17 @@ bool textHandleUndo(BufferView * bv, Undo & undo) // paragraph if there is any. This is not needed if we don't have // a paragraph before because then in is automatically done in the // function which assigns the first paragraph to an InsetText. (Jug) - Paragraph * tmppar4 = tmppar3; - if (tmppar4) { + Paragraph * lastundopar = undopar; + if (lastundopar) { Inset * in = 0; if (before) in = before->inInset(); else if (undo.number_of_inset_id >= 0) in = bv->buffer()->getInsetFromID(undo.number_of_inset_id); - tmppar4->setInsetOwner(in); - while (tmppar4->next()) { - tmppar4 = tmppar4->next(); - tmppar4->setInsetOwner(in); + lastundopar->setInsetOwner(in); + while (lastundopar->next()) { + lastundopar = lastundopar->next(); + lastundopar->setInsetOwner(in); } } @@ -137,7 +133,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo) deletepar = before->next(); else deletepar = firstUndoParagraph(bv, undo.number_of_inset_id); - tmppar2 = tmppar3; + tmppar2 = undopar; while (deletepar && deletepar != behind) { deletelist.push_back(deletepar); tmppar = deletepar; @@ -154,15 +150,26 @@ bool textHandleUndo(BufferView * bv, Undo & undo) } } + // The order here is VERY IMPORTANT. We have to set the right + // next/prev pointer in the paragraphs so that a rebuild of + // the LyXText works!!! + + // thread the end of the undo onto the par in front if any + if (lastundopar) { + lastundopar->next(behind); + if (behind) + behind->previous(lastundopar); + } + // put the new stuff in the list if there is one - if (tmppar3) { + if (undopar) { + undopar->previous(before); if (before) - before->next(tmppar3); + before->next(undopar); else bv->text->ownerParagraph(firstUndoParagraph(bv, undo.number_of_inset_id)->id(), - tmppar3); + undopar); - tmppar3->previous(before); } else { // We enter here on DELETE undo operations where we have to // substitue the second paragraph with the first if the removed @@ -170,24 +177,30 @@ bool textHandleUndo(BufferView * bv, Undo & undo) if (!before && behind) { bv->text->ownerParagraph(firstUndoParagraph(bv, undo.number_of_inset_id)->id(), behind); - tmppar3 = behind; + undopar = behind; } } - if (tmppar4) { - tmppar4->next(behind); - if (behind) - behind->previous(tmppar4); - } // Set the cursor for redoing - if (before) { + if (before) { // if we have a par before the undopar Inset * it = before->inInset(); if (it) it->getLyXText(bv)->setCursorIntern(bv, before, 0); else bv->text->setCursorIntern(bv, before, 0); } +// we are not ready for this we cannot set the cursor for a paragraph +// which is not already in a row of LyXText!!! +#if 0 + else { // otherwise this is the first one and we start here + Inset * it = undopar->inInset(); + if (it) + it->getLyXText(bv)->setCursorIntern(bv, undopar, 0); + else + bv->text->setCursorIntern(bv, undopar, 0); + } +#endif Paragraph * endpar = 0; // calculate the endpar for redoing the paragraphs. @@ -196,8 +209,8 @@ bool textHandleUndo(BufferView * bv, Undo & undo) tmppar = bv->buffer()->getParFromID(undo.number_of_cursor_par); UpdatableInset* it = 0; - if (tmppar3) - it = static_cast(tmppar3->inInset()); + if (undopar) + it = static_cast(undopar->inInset()); if (it) { it->getLyXText(bv)->redoParagraphs(bv, it->getLyXText(bv)->cursor,