]> git.lyx.org Git - lyx.git/blobdiff - src/undo_funcs.C
The "I want this in now" patch.
[lyx.git] / src / undo_funcs.C
index 3d3f659c2e8c29d60859c3fd702688c0eef94629..da7255979a16f0707ab8e07fa86fc92b3160b72c 100644 (file)
@@ -98,7 +98,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
                t->setCursorIntern(undoParagraphs(bv, num).begin(), 0);
        }
 
-       // Set the right(new) inset-owner of the paragraph if there is any. 
+       // Set the right(new) inset-owner of the paragraph if there is any.
        if (!undo.pars.empty()) {
                Inset * in = 0;
                if (before != end)
@@ -123,7 +123,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
                }
                // this surprisingly fills the undo! (Andre')
                size_t par = 0;
-               //while (deletepar && deletepar != *behind) {
+               //while (deletepar && deletepar != *behind)
                while (deletepar != *behind) {
                        deletelist.push_back(&*deletepar);
                        ++deletepar;
@@ -145,24 +145,29 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
 
        // Thread the end of the undo onto the par in front if any.
        if (!undo.pars.empty()) {
-               undo.pars.back()->next(&**behind);
-               if (behind != end)
-                       (&**behind)->previous(undo.pars.back());
+#warning FIXME
+               //undo.pars.back()->next(&**behind);
+               //if (behind != end)
+               //(&**behind)->previous(undo.pars.back());
        }
 
        // Put the new stuff in the list if there is one.
        Paragraph * undopar = undo.pars.empty() ? 0 : undo.pars.front();
        if (!undo.pars.empty()) {
-               undo.pars.front()->previous(&**before);
-               if (before != end)
-                       (&**before)->next(undopar);
-               else {
+#warning FIXME
+               //undo.pars.front()->previous(&**before);
+               if (before != end) {
+#warning FIXME
+                       //(&**before)->next(undopar);
+               } else {
                        int id = undoParagraphs(bv, undo.number_of_inset_id).front().id();
                        ParIterator op = bv->buffer()->getParFromID(id);
                        if (op != end && op->inInset()) {
-                               static_cast<InsetText*>(op->inInset())->paragraph(undopar);
+#warning FIXME reimplementaion needed here
+                               //static_cast<InsetText*>(op->inInset())->paragraph(undopar);
                        } else {
-                               bv->buffer()->paragraphs.set(undopar);
+#warning FIXME reimplementation needed here
+                               //bv->buffer()->paragraphs.set(undopar);
                        }
                }
        } else {
@@ -173,9 +178,11 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
                        int id = undoParagraphs(bv, undo.number_of_inset_id).front().id();
                        ParIterator op = bv->buffer()->getParFromID(id);
                        if (op != end && op->inInset()) {
-                               static_cast<InsetText*>(op->inInset())->paragraph(&**behind);
+#warning FIXME reimplementation needed here
+                               //static_cast<InsetText*>(op->inInset())->paragraph(&**behind);
                        } else {
-                               bv->buffer()->paragraphs.set(&**behind);
+#warning FIXME reimplementation needed here
+                               //bv->buffer()->paragraphs.set(&**behind);
                        }
                        undopar = &**behind;
                }
@@ -222,53 +229,37 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
        ParIterator tmppar =
                bv->buffer()->getParFromID(undo.number_of_cursor_par);
 
-       if (it) {
-               if (tmppar != end) {
-                       LyXText * t;
-                       Inset * it = tmppar->inInset();
-                       if (it) {
-                               FuncRequest cmd(bv, LFUN_INSET_EDIT, "left");
-                               it->localDispatch(cmd);
-                               t = it->getLyXText(bv);
-                       } else {
-                               t = bv->text;
-                       }
-                       t->setCursorIntern(*tmppar, undo.cursor_pos);
-                       // Clear any selection and set the selection
-                       // cursor for an evt. new selection.
-                       t->clearSelection();
-                       t->selection.cursor = t->cursor;
-                       t->updateCounters();
-                       bv->fitCursor();
+       if (tmppar != end) {
+               LyXText * t;
+               Inset * it = tmppar->inInset();
+               if (it) {
+                       FuncRequest cmd(bv, LFUN_INSET_EDIT, "left");
+                       it->localDispatch(cmd);
+                       t = it->getLyXText(bv);
+               } else {
+                       t = bv->text;
                }
+               t->setCursorIntern(*tmppar, undo.cursor_pos);
+               // Clear any selection and set the selection
+               // cursor for an evt. new selection.
+               t->clearSelection();
+               t->selection.cursor = t->cursor;
+               t->updateCounters();
+       }
+
+       if (it) {
+               bv->fitCursor();
                bv->updateInset(it);
                bv->text->setCursorIntern(bv->text->cursor.par(),
                                          bv->text->cursor.pos());
-       } else {
-               if (tmppar != end) {
-                       LyXText * t;
-                       Inset * it = tmppar->inInset();
-                       if (it) {
-                               FuncRequest cmd(bv, LFUN_INSET_EDIT, "left");
-                               it->localDispatch(cmd);
-                               t = it->getLyXText(bv);
-                       } else {
-                               t = bv->text;
-                       }
-                       t->setCursorIntern(*tmppar, undo.cursor_pos);
-                       // Clear any selection and set the selection
-                       // cursor for an evt. new selection.
-                       t->clearSelection();
-                       t->selection.cursor = t->cursor;
-                       t->updateCounters();
-               }
        }
 
        // And here it's safe enough to delete all removed paragraphs.
        vector<Paragraph *>::iterator pit = deletelist.begin();
        for(; pit != deletelist.end(); ++pit) {
-               (*pit)->previous(0);
-               (*pit)->next(0);
+#warning FIXME
+               //(*pit)->previous(0);
+               //(*pit)->next(0);
                delete (*pit);
        }
 
@@ -293,8 +284,9 @@ bool createUndo(BufferView * bv, Undo::undo_kind kind,
        int behind_number = -1;
        int inset_id = -1;
 
-       if (first->previous())
-               before_number = first->previous()->id();
+#warning FIXME
+       //if (first->previous())
+       //      before_number = first->previous()->id();
        if (behind)
                behind_number = behind->id();
        if (first->inInset())
@@ -325,40 +317,43 @@ bool createUndo(BufferView * bv, Undo::undo_kind kind,
 
        Paragraph const * end = 0;
 
-       if (behind)
-               end = behind->previous();
-       else {
+       if (behind) {
+#warning FIXME
+               //end = behind->previous();
+       }else {
                end = first;
-               while (end->next())
-                       end = end->next();
+#warning FIXME
+               //while (end->next())
+               //      end = end->next();
        }
 
-       if (first && end && (first != end->next()) &&
-           ((before_number != behind_number) ||
-                ((before_number < 0) && (behind_number < 0))))
-       {
-               undo_pars.push_back(new Paragraph(*first, true));
-               for (Paragraph * tmppar = first; tmppar != end && tmppar->next(); ) {
-                       tmppar = tmppar->next();
-                       undo_pars.push_back(new Paragraph(*tmppar, true));
-                       size_t const n = undo_pars.size();
-                       undo_pars[n - 2]->next(undo_pars[n - 1]);
-                       undo_pars[n - 1]->previous(undo_pars[n - 2]);
-               }
-               undo_pars.back()->next(0);
-       }
+#warning FIXME
+//     if (first && end && (first != end->next()) &&
+//         ((before_number != behind_number) ||
+//              ((before_number < 0) && (behind_number < 0))))
+//     {
+//             undo_pars.push_back(new Paragraph(*first, true));
+//             for (Paragraph * tmppar = first; tmppar != end && tmppar->next(); ) {
+//                     tmppar = tmppar->next();
+//                     undo_pars.push_back(new Paragraph(*tmppar, true));
+//                     size_t const n = undo_pars.size();
+//                     undo_pars[n - 2]->next(undo_pars[n - 1]);
+//                     undo_pars[n - 1]->previous(undo_pars[n - 2]);
+//             }
+//             undo_pars.back()->next(0);
+//     }
 
        // A memory optimization: Just store the layout
        // information when only edit.
        if (kind == Undo::EDIT) {
                for (size_t i = 0, n = undo_pars.size(); i < n; ++i)
                        undo_pars[i]->clearContents();
-       }               
+       }
 
        int cursor_par = undoCursor(bv).par()->id();
        int cursor_pos = undoCursor(bv).pos();
 
-       //lyxerr << "createUndo: inset_id: " << inset_id << "  before_number: " 
+       //lyxerr << "createUndo: inset_id: " << inset_id << "  before_number: "
        //      << before_number << "  behind_number: " << behind_number << "\n";
        u.reset(new Undo(kind, inset_id,
                before_number, behind_number,
@@ -372,9 +367,9 @@ bool createUndo(BufferView * bv, Undo::undo_kind kind,
 // Returns false if no undo possible.
 bool textUndoOrRedo(BufferView * bv,
        limited_stack<boost::shared_ptr<Undo> > & stack,
-       limited_stack<boost::shared_ptr<Undo> > & otherstack)
+                   limited_stack<boost::shared_ptr<Undo> > & /*otherstack*/)
 {
-       Buffer * b = bv->buffer();
+       //Buffer * b = bv->buffer();
 
        if (stack.empty()) {
                finishNoUndo(bv);