]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_gridinset.C
bug + spped fixes + small stuff
[lyx.git] / src / mathed / math_gridinset.C
index 1384d1e399316d4b4ec6f2d092a439cadb2ceb1c..9ed68656e3c867d535b3bd29bc56b96eb758a5a4 100644 (file)
@@ -15,6 +15,7 @@
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 #include "BufferView.h"
+#include "cursor.h"
 #include "dispatchresult.h"
 #include "debug.h"
 #include "funcrequest.h"
@@ -754,7 +755,7 @@ int MathGridInset::cellYOffset(idx_type idx) const
 }
 
 
-bool MathGridInset::idxUpDown(LCursor & cur, bool up, int targetx) const
+bool MathGridInset::idxUpDown(LCursor & cur, bool up) const
 {
        if (up) {
                if (cur.idx() < ncols())
@@ -765,7 +766,7 @@ bool MathGridInset::idxUpDown(LCursor & cur, bool up, int targetx) const
                        return false;
                cur.idx() += ncols();
        }
-       cur.pos() = cur.cell().x2pos(targetx - cur.cell().xo());
+       cur.pos() = cur.cell().x2pos(cur.x_target() - cur.cell().xo());
        return true;
 }
 
@@ -883,7 +884,7 @@ bool MathGridInset::idxDelete(idx_type & idx)
 
        // move cells if necessary
        for (idx_type i = index(row(idx), 0); i < idx; ++i)
-               std::swap(cell(i), cell(i + ncols()));
+               swap(cell(i), cell(i + ncols()));
 
        delRow(row(idx));
 
@@ -1043,9 +1044,9 @@ void MathGridInset::splitCell(LCursor & cur)
 
 
 DispatchResult
-MathGridInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
+MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
-       LCursor & cur = bv.fullCursor();
+       //lyxerr << "*** MathGridInset: request: " << cmd << endl;
        switch (cmd.action) {
 
                case LFUN_MOUSE_RELEASE:
@@ -1053,10 +1054,10 @@ MathGridInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
                        //      GridInsetMailer(*this).showDialog();
                        //      return DispatchResult(true, true);
                        //}
-                       return DispatchResult(false);
+                       return MathNestInset::priv_dispatch(cur, cmd);
 
                case LFUN_INSET_DIALOG_UPDATE:
-                       GridInsetMailer(*this).updateDialog(&bv);
+                       GridInsetMailer(*this).updateDialog(&cur.bv());
                        return DispatchResult(false);
 
                // insert file functions
@@ -1069,29 +1070,29 @@ MathGridInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
                        //}
                        if (nrows() > 1)
                                delRow(cur.row());
-                       if (cur.idx() >= nargs())
-                               cur.idx() = nargs() - 1;
+                       if (cur.idx() > cur.lastidx())
+                               cur.idx() = cur.lastidx();
                        if (cur.pos() > cur.lastpos())
                                cur.pos() = cur.lastpos();
                        return DispatchResult(true, FINISHED);
 
                case LFUN_CELL_SPLIT:
-                       //recordUndo(bv, Undo::ATOMIC);
+                       ////recordUndo(cur, Undo::ATOMIC);
                        splitCell(cur);
                        return DispatchResult(true, FINISHED);
 
                case LFUN_BREAKLINE: {
-                       //recordUndo(bv, Undo::INSERT);
+                       ////recordUndo(cur, Undo::INSERT);
                        row_type const r = cur.row();
                        addRow(r);
 
                        // split line
                        for (col_type c = col(cur.idx()) + 1; c < ncols(); ++c)
-                               std::swap(cell(index(r, c)), cell(index(r + 1, c)));
+                               swap(cell(index(r, c)), cell(index(r + 1, c)));
 
                        // split cell
                        splitCell(cur);
-                       std::swap(cell(cur.idx()), cell(cur.idx() + ncols() - 1));
+                       swap(cell(cur.idx()), cell(cur.idx() + ncols() - 1));
                        if (cur.idx() > 0)
                                --cur.idx();
                        cur.idx() = cur.lastpos();
@@ -1191,6 +1192,6 @@ cur.row());
                }
 
                default:
-                       return MathNestInset::priv_dispatch(bv, cmd);
+                       return MathNestInset::priv_dispatch(cur, cmd);
        }
 }