#include "math_nestinset.h"
#include "math_cursor.h"
#include "math_mathmlstream.h"
-#include "formulabase.h"
+#include "math_parser.h"
+#include "funcrequest.h"
#include "debug.h"
+#include "BufferView.h"
#include "frontends/Painter.h"
-using std::vector;
-
MathNestInset::MathNestInset(idx_type nargs)
: MathDimInset(), cells_(nargs), lock_(false)
x += 2;
}
+
void MathNestInset::substitute(MathMacro const & m)
{
for (idx_type i = 0; i < nargs(); ++i)
}
-bool MathNestInset::match(MathInset const * p) const
+bool MathNestInset::match(MathAtom const & at) const
{
- if (nargs() != p->nargs())
+ if (nargs() != at->nargs())
return false;
for (idx_type i = 0; i < nargs(); ++i)
- if (!cell(i).match(p->cell(i)))
+ if (!cell(i).match(at->cell(i)))
return false;
return true;
}
os << '\\' << name().c_str();
for (unsigned i = 0; i < nargs(); ++i)
os << '{' << cell(i) << '}';
- if (lock_ && !os.latex())
- os << "\\lyxlock ";
if (nargs() == 0)
- os << ' ';
+ os.pendingSpace(true);
+ if (lock_ && !os.latex()) {
+ os << "\\lyxlock";
+ os.pendingSpace(true);
+ }
}
}
-void MathNestInset::notifyCursorLeaves()
-{}
+void MathNestInset::notifyCursorLeaves(idx_type idx)
+{
+ cell(idx).notifyCursorLeaves();
+}
+
+
+MathInset::result_type MathNestInset::dispatch
+ (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
+{
+ BufferView * bv = cmd.view();
+
+ switch (cmd.action) {
+
+ case LFUN_PASTE: {
+ MathArray ar;
+ mathed_parse_cell(ar, cmd.argument);
+ cell(idx).insert(pos, ar);
+ pos += ar.size();
+ return DISPATCHED;
+ }
+
+ case LFUN_PASTESELECTION:
+ return
+ dispatch(
+ FuncRequest(bv, LFUN_PASTE, bv->getClipboard()), idx, pos);
+
+ case LFUN_MOUSE_PRESS:
+ if (cmd.button() == mouse_button::button2)
+ return dispatch(FuncRequest(bv, LFUN_PASTESELECTION), idx, pos);
+ return UNDISPATCHED;
+
+ default:
+ return MathInset::dispatch(cmd, idx, pos);
+ }
+ return UNDISPATCHED;
+}