]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
Fix functions that used functions but did not defined it
[lyx.git] / src / Cursor.cpp
index 8cd445bcb7b48d4f5af6ea6ace2ea7c308335baa..cab25022d7176cafc76db12683d5432597653ed4 100644 (file)
@@ -903,7 +903,8 @@ void Cursor::pop()
 void Cursor::push(Inset & inset)
 {
        push_back(CursorSlice(inset));
-       inset.setBuffer(*buffer());
+       // See bug #13050
+       // inset.setBuffer(*buffer());
 }
 
 
@@ -1492,7 +1493,7 @@ void Cursor::insert(char_type c)
        LASSERT(!empty(), return);
        if (inMathed()) {
                cap::selClearOrDel(*this);
-               insert(new InsetMathChar(c));
+               insert(new InsetMathChar(buffer(), c));
        } else {
                text()->insertChar(*this, c);
        }
@@ -1576,7 +1577,7 @@ void Cursor::niceInsert(MathAtom const & t)
                docstring const name = t->asMacro()->name();
                MacroData const * data = buffer()->getMacro(name);
                if (data && data->numargs() - data->optionals() > 0) {
-                       plainInsert(MathAtom(new InsetMathBrace(ar)));
+                       plainInsert(MathAtom(new InsetMathBrace(buffer(), ar)));
                        posBackward();
                }
        }
@@ -1836,7 +1837,7 @@ bool Cursor::macroModeClose(bool cancel)
        // finally put the macro argument behind, if needed
        if (macroArg) {
                if (selection.size() > 1 || selection[0]->asScriptInset())
-                       plainInsert(MathAtom(new InsetMathBrace(selection)));
+                       plainInsert(MathAtom(new InsetMathBrace(buffer(), selection)));
                else
                        insert(selection);
        }
@@ -1882,8 +1883,6 @@ void Cursor::pullArg()
                plainErase();
                cell().insert(pos(), ar);
                resetAnchor();
-       } else {
-               //formula()->mutateToText();
        }
 }
 
@@ -2007,6 +2006,8 @@ bool Cursor::upDownInMath(bool up)
                // try to find best position within this inset
                if (!selection())
                        setCursor(bruteFind(*this, xo, yo));
+               // FIXME : this is actually only needed for InsetMathMacro (bug #12952).
+               screenUpdateFlags(Update::SinglePar);
                return true;
        }
 
@@ -2143,7 +2144,7 @@ bool Cursor::mathBackward(bool word)
 }
 
 
-bool Cursor::upDownInText(bool up, bool & updateNeeded)
+bool Cursor::upDownInText(bool up)
 {
        LASSERT(text(), return false);
 
@@ -2153,6 +2154,9 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
        getPos(xo, yo);
        xo = beforeDispatchPosX_;
 
+       // Is a full repaint necessary?
+       bool updateNeeded = false;
+
        // update the targetX - this is here before the "return false"
        // to set a new target which can be used by InsetTexts above
        // if we cannot move up/down inside this inset anymore
@@ -2221,12 +2225,13 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                        dummy.pos() = dummy.pos() == 0 ? dummy.lastpos() : 0;
                        dummy.pit() = dummy.pit() == 0 ? dummy.lastpit() : 0;
 
-                       updateNeeded |= bv().checkDepm(dummy, *this);
-                       updateTextTargetOffset();
-                       if (updateNeeded)
+                       if (bv().checkDepm(dummy, *this)) {
+                               updateNeeded = true;
                                forceBufferUpdate();
+                       }
+                       updateTextTargetOffset();
                }
-               return false;
+               return updateNeeded;
        }
 
        // with and without selection are handled differently
@@ -2252,6 +2257,7 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                        ++dummy.pos();
                if (bv().checkDepm(dummy, old)) {
                        updateNeeded = true;
+                       forceBufferUpdate();
                        // Make sure that cur gets back whatever happened to dummy (Lgb)
                        operator=(dummy);
                }
@@ -2292,13 +2298,14 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                // When selection==false, this is done by TextMetrics::editXY
                setCurrentFont();
 
-               updateNeeded |= bv().checkDepm(*this, old);
+               if (bv().checkDepm(*this, old)) {
+                       updateNeeded = true;
+                       forceBufferUpdate();
+               }
        }
 
-       if (updateNeeded)
-               forceBufferUpdate();
        updateTextTargetOffset();
-       return true;
+       return updateNeeded;
 }