}
+void MathCursor::markInsert()
+{
+ //lyxerr << "inserting mark\n";
+ array().insert(pos(), MathAtom(new MathCharInset(0, lastcode_)));
+}
+
+
+void MathCursor::markErase()
+{
+ //lyxerr << "deleting mark\n";
+ array().erase(pos());
+}
+
+
void MathCursor::plainInsert(MathAtom const & t)
{
array().insert(pos(), t);
}
+void MathCursor::insert(char c)
+{
+ insert(c, lastcode_);
+}
+
+
void MathCursor::insert(MathAtom const & t)
{
macroModeClose();
par()->asGridInset()->delRow(hullRow());
}
- if (idx() > par()->nargs())
- idx() = par()->nargs();
+ if (idx() >= par()->nargs())
+ idx() = par()->nargs() - 1;
if (pos() > size())
pos() = size();
array().insert(pos(), a);
if (goright)
pos() += a.size();
+ } else {
+ formula()->mutateToText();
}
}
MathIterator it = ibegin(formula()->par().nucleus());
MathIterator et = iend(formula()->par().nucleus());
- for ( ; it != et; ++it) {
- // avoid invalid nesting hen selecting
- if (selection_ && !positionable(it.cursor(), Anchor_))
- continue;
- int xo = it.position().xpos();
- int yo = it.position().ypos();
- if (xlow - 2 <= xo && xo <= xhigh + 2 &&
- ylow - 2 <= yo && yo <= yhigh + 2)
- {
- double d = (x - xo) * (x - xo) + (y - yo) * (y - yo);
- if (d < best_dist) {
- best_dist = d;
- best_cursor = it.cursor();
+ while (1) {
+ // avoid invalid nesting when selecting
+ if (!selection_ || positionable(it.cursor(), Anchor_)) {
+ int xo = it.position().xpos();
+ int yo = it.position().ypos();
+ if (xlow - 2 <= xo && xo <= xhigh + 2 &&
+ ylow - 2 <= yo && yo <= yhigh + 2)
+ {
+ double d = (x - xo) * (x - xo) + (y - yo) * (y - yo);
+ if (d < best_dist) {
+ best_dist = d;
+ best_cursor = it.cursor();
+ }
}
}
+
+ if (it == et)
+ break;
+ ++it;
}
+
if (best_dist < 1e10)
Cursor_ = best_cursor;
return best_dist < 1e10;
m = std::max(1u, m);
n = std::max(1u, n);
v_align += 'c';
- niceInsert(MathAtom(new MathArrayInset(m, n, v_align[0], h_align)));
+ niceInsert(MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
return true;
}
return true;
}
+ // prevent entering of recursive macros
+ if (formula()->lyxCode() == Inset::MATHMACRO_CODE
+ && formula()->getInsetName() == s.substr(1))
+ {
+ lyxerr << "can't enter recursive macro\n";
+ return true;
+ }
+
niceInsert(createMathInset(s.substr(1)));
return true;
}
if (c == '\\')
insert(c, LM_TC_TEX);
+ else
+ insert(c, lastcode_);
return true;
}