]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
remove duplicated (and probably not really correct) code
[lyx.git] / src / Text3.cpp
index c7fadab79dd560a495a4cfef349c5790a3444b8c..dc0025fd097ac5c042e200dcafd26ac15bbea591 100644 (file)
@@ -335,7 +335,7 @@ static void outline(OutlineOp mode, Cursor & cur)
 
        // Do we need to set insets' buffer_ members, because we copied
        // some stuff? We'll assume we do and reset it otherwise.
-       bool setBuffers = true;
+       bool set_buffers = true;
 
        switch (mode) {
                case OutlineUp: {
@@ -406,7 +406,7 @@ static void outline(OutlineOp mode, Cursor & cur)
                                        }
                                }
                        }
-                       setBuffers = false;
+                       set_buffers = false;
                        break;
                }
                case OutlineOut: {
@@ -426,11 +426,11 @@ static void outline(OutlineOp mode, Cursor & cur)
                                        }
                                }
                        }
-                       setBuffers = false;
+                       set_buffers = false;
                        break;
                }
        }
-       if (setBuffers)
+       if (set_buffers)
                // FIXME This only really needs doing for the newly introduced 
                // paragraphs. Something like:
                //      pit_type const numpars = distance(start, finish);
@@ -607,6 +607,19 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                && cur.boundary() == oldBoundary) {
                        cur.undispatched();
                        cmd = FuncRequest(LFUN_FINISHED_FORWARD);
+               
+                       // we will probably be moving out the inset, so we should execute
+                       // the depm-mechanism, but only when the cursor has a place to 
+                       // go outside this inset, i.e. in a slice above.
+                       if (cur.depth() > 1 && cur.pos() == cur.lastpos() 
+                                 && cur.pit() == cur.lastpit()) {
+                               // The cursor hasn't changed yet. To give the 
+                               // DEPM the possibility of doing something we must
+                               // provide it with two different cursors.
+                               Cursor dummy = cur;
+                               dummy.pos() = dummy.pit() = 0;
+                               cur.bv().checkDepm(dummy, cur);
+                       }
                }
                break;
 
@@ -620,6 +633,19 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        && cur.boundary() == oldBoundary) {
                        cur.undispatched();
                        cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
+
+                       // we will probably be moving out the inset, so we should execute
+                       // the depm-mechanism, but only when the cursor has a place to 
+                       // go outside this inset, i.e. in a slice above.
+                       if (cur.depth() > 1 && cur.pos() == 0 && cur.pit() == 0) {
+                               // The cursor hasn't changed yet. To give the 
+                               // DEPM the possibility of doing something we must
+                               // provide it with two different cursors.
+                               Cursor dummy = cur;
+                               dummy.pos() = cur.lastpos();
+                               dummy.pit() = cur.lastpit();
+                               cur.bv().checkDepm(dummy, cur);
+                       }
                }
                break;
 
@@ -1497,6 +1523,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                }
                if (!inset)
                        break;
+               cur.recordUndo();
                insertInset(cur, inset);
                cur.posForward();
                break;