]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
Allow using \binom without amsmath and add support for \brace and \brack
[lyx.git] / src / Cursor.cpp
index 397331f7a686c46fc21067ed47c965035a6b1fe4..b0997ecbba12047eef5dac3ce3ad5cd55d7c526b 100644 (file)
@@ -23,9 +23,9 @@
 #include "DispatchResult.h"
 #include "Encoding.h"
 #include "Font.h"
+#include "FuncCode.h"
 #include "FuncRequest.h"
 #include "Language.h"
-#include "lfuns.h"
 #include "LyXFunc.h" // only for setMessage()
 #include "LyXRC.h"
 #include "paragraph_funcs.h"
@@ -1554,7 +1554,7 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                if (pit() + 1 >= int(text()->paragraphs().size()) &&
                                row + 1 >= int(pm.rows().size()))
                        return false;
-       }       
+       }
 
        // with and without selection are handled differently
        if (!selection()) {
@@ -1587,7 +1587,10 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                                top().pos() = min(tm.x2pos(pit(), row - 1, xo), top().lastpos());
                        } else if (pit() > 0) {
                                --pit();
-                               ParagraphMetrics const & pmcur = bv_->parMetrics(text(), pit());
+                               TextMetrics & tm = bv_->textMetrics(text());
+                               if (!tm.contains(pit()))
+                                       tm.newParMetricsUp();
+                               ParagraphMetrics const & pmcur = tm.parMetrics(pit());
                                top().pos() = min(tm.x2pos(pit(), pmcur.rows().size() - 1, xo), top().lastpos());
                        }
                } else {
@@ -1595,6 +1598,9 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                                top().pos() = min(tm.x2pos(pit(), row + 1, xo), top().lastpos());
                        } else if (pit() + 1 < int(text()->paragraphs().size())) {
                                ++pit();
+                               TextMetrics & tm = bv_->textMetrics(text());
+                               if (!tm.contains(pit()))
+                                       tm.newParMetricsDown();
                                top().pos() = min(tm.x2pos(pit(), 0, xo), top().lastpos());
                        }
                }
@@ -1943,14 +1949,20 @@ void Cursor::recordUndoFullDocument()
 
 void Cursor::recordUndoSelection()
 {
-       bv_->buffer().undo().recordUndo(*this, ATOMIC_UNDO,
-               selBegin().pit(), selEnd().pit());
+       if (inMathed()) {
+               if (cap::multipleCellsSelected(*this))
+                       recordUndoInset();
+               else
+                       recordUndo();
+       } else
+               bv_->buffer().undo().recordUndo(*this, ATOMIC_UNDO,
+                       selBegin().pit(), selEnd().pit());
 }
 
 
 void Cursor::checkBufferStructure()
 {
-       if (paragraph().layout()->toclevel == Layout::NOT_IN_TOC)
+       if (paragraph().layout().toclevel == Layout::NOT_IN_TOC)
                return;
        Buffer const * master = buffer().masterBuffer();
        master->tocBackend().updateItem(ParConstIterator(*this));