#include "math_data.h"
#include "math_mathmlstream.h"
#include "math_streamstr.h"
+#include "BufferView.h"
+#include "cursor.h"
#include "dispatchresult.h"
#include "debug.h"
#include "funcrequest.h"
#include "LColor.h"
+
#include "frontends/Painter.h"
+
#include "support/std_sstream.h"
#include "insets/mailinset.h"
}
-bool MathGridInset::idxUpDown(BufferView & bv, bool up, int targetx) const
+bool MathGridInset::idxUpDown(LCursor & cur, bool up) const
{
- CursorSlice & cur = cursorTip(bv);
if (up) {
if (cur.idx() < ncols())
return false;
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;
}
-bool MathGridInset::idxLeft(BufferView & bv) const
+bool MathGridInset::idxLeft(LCursor & cur) const
{
// leave matrix if on the left hand edge
- CursorSlice & cur = cursorTip(bv);
if (cur.col() == 0)
return false;
--cur.idx();
}
-bool MathGridInset::idxRight(BufferView & bv) const
+bool MathGridInset::idxRight(LCursor & cur) const
{
// leave matrix if on the right hand edge
- CursorSlice & cur = cursorTip(bv);
if (cur.col() + 1 == ncols())
return false;
++cur.idx();
}
-bool MathGridInset::idxFirst(BufferView & bv) const
+bool MathGridInset::idxFirst(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
switch (v_align_) {
case 't':
cur.idx() = 0;
}
-bool MathGridInset::idxLast(BufferView & bv) const
+bool MathGridInset::idxLast(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
switch (v_align_) {
case 't':
cur.idx() = ncols() - 1;
}
-bool MathGridInset::idxHome(BufferView & bv) const
+bool MathGridInset::idxHome(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
if (cur.pos() > 0) {
cur.pos() = 0;
return true;
}
-bool MathGridInset::idxEnd(BufferView & bv) const
+bool MathGridInset::idxEnd(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
if (cur.pos() < cur.lastpos()) {
cur.pos() = cur.lastpos();
return true;
// 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));
}
-void MathGridInset::splitCell(BufferView & bv)
+void MathGridInset::splitCell(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
if (cur.idx() + 1 == nargs())
return;
MathArray ar = cur.cell();
DispatchResult
-MathGridInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
+MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
{
- CursorSlice & cur = cursorTip(bv);
+ //lyxerr << "*** MathGridInset: request: " << cmd << endl;
switch (cmd.action) {
case LFUN_MOUSE_RELEASE:
// 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
//}
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);
- splitCell(bv);
+ ////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(bv);
- std::swap(cell(cur.idx()), cell(cur.idx() + ncols() - 1));
+ splitCell(cur);
+ swap(cell(cur.idx()), cell(cur.idx() + ncols() - 1));
if (cur.idx() > 0)
--cur.idx();
cur.idx() = cur.lastpos();
}
default:
- return MathNestInset::priv_dispatch(bv, cmd);
+ return MathNestInset::priv_dispatch(cur, cmd);
}
}