]> git.lyx.org Git - lyx.git/commitdiff
preparations to regain ability of per-inset undo.
authorAndré Pönitz <poenitz@gmx.net>
Mon, 13 Oct 2003 13:27:45 +0000 (13:27 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 13 Oct 2003 13:27:45 +0000 (13:27 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7911 a592a061-630c-0410-9148-cb99ea01b6c8

src/undo.C
src/undo.h
src/undo_funcs.C

index 63a020e80f47bf11b11f3d05e8901cb0f2b04110..46854ecfef378ff45ea0bbdacf147e7a33486ff7 100644 (file)
 #include "paragraph.h"
 
 Undo::Undo(undo_kind kind_arg, int inset,
+          int plist_arg,
           int first, int last,
           int cursor, int cursor_pos_arg,
           ParagraphList const & par)
        :
                kind(kind_arg),
                inset_id(inset),
+               plist(plist_arg),
                first_par_offset(first),
                last_par_offset(last),
                cursor_par_offset(cursor),
index 415377cf3309cd05496354c98bad323ddc688b12..08cf5b98618bee85c1f849433df52d46620b5134 100644 (file)
@@ -45,6 +45,7 @@ public:
        };
        ///
        Undo(undo_kind kind, int inset_id,
+            int plist,
             int first, int last,
             int cursor, int cursor_pos,
             ParagraphList const & par_arg);
@@ -52,6 +53,9 @@ public:
        /// Which kind of operation are we recording for?
        undo_kind kind;
 
+       /// to what paragraph list do we belong?
+       int plist;
+
        /**
         * ID of hosting inset if the cursor is in one.
         * if -1, then the cursor is not in an inset.
index b1de438dafb143faed63d3af2a7761702e9b0df0..ccfcbd94d4dfb96fc49b7e9ce05275368fd28a58 100644 (file)
@@ -57,9 +57,16 @@ void recordUndo(BufferView * bv, Undo::undo_kind kind,
        LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
        int const inset_id = inset ? inset->id() : -1;
 
-       // We simply record the entire outer paragraphs
+       // Try to find the appropriate list by counting the,
        ParIterator null = buf->par_iterator_end();
 
+       int pcount = 0;
+       for (ParIterator it = buf->par_iterator_begin(); it != null; ++it, ++pcount)
+               if (&it.plist() == &plist)
+                       break;
+       //lyxerr << "This is plist #" << pcount << ' ' << &plist << endl;
+               
+       // We simply record the entire outer paragraphs
        // First, identify the outer paragraphs
        for (ParIterator it = buf->par_iterator_begin(); it != null; ++it) {
                if (it->id() == first->id())
@@ -93,11 +100,11 @@ void recordUndo(BufferView * bv, Undo::undo_kind kind,
 
        // Make and push the Undo entry
        stack.push(Undo(kind, inset_id,
+               pcount,
                first_offset, last_offset,
                cursor_offset, text->cursor.pos(),
                ParagraphList()));
 
-       lyxerr << "G" << endl;
        // Record the relevant paragraphs
        ParagraphList & undo_pars = stack.top().pars;
 
@@ -119,6 +126,13 @@ bool performUndoOrRedo(BufferView * bv, Undo const & undo)
        Buffer * buf = bv->buffer();
        ParagraphList & plist = buf->paragraphs();
 
+       ParIterator null = buf->par_iterator_end();
+       ParIterator plit = buf->par_iterator_begin();
+       int n = undo.plist;
+       for ( ; n && plit != null; ++plit, --n)
+               ;
+       //lyxerr << "undo: using plist #" << undo.plist << " " << &plit.plist() << endl;
+
        // Remove new stuff between first and last
        {
                ParagraphList::iterator first = plist.begin();
@@ -152,10 +166,10 @@ bool performUndoOrRedo(BufferView * bv, Undo const & undo)
                LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
                text->setCursorIntern(undo.cursor_par_offset, undo.cursor_pos);
 
-               lyxerr << "undo, inset: " << inset << endl;
+               //lyxerr << "undo, inset: " << inset << endl;
 
                if (inset) {
-                       lyxerr << "undo, inset owner: " << inset->owner() << endl;
+                       //lyxerr << "undo, inset owner: " << inset->owner() << endl;
 
                        // Magic needed to update inset internal state
                        FuncRequest cmd(bv, LFUN_INSET_EDIT, "left");