using std::max;
using std::swap;
using std::isalnum;
+using std::vector;
+using std::ostringstream;
namespace {
c1 = p->col(i1.idx_);
c2 = p->col(i2.idx_);
if (c1 > c2)
- std::swap(c1, c2);
+ swap(c1, c2);
r1 = p->row(i1.idx_);
r2 = p->row(i2.idx_);
if (r1 > r2)
- std::swap(r1, r2);
+ swap(r1, r2);
}
void grab(MathCursor const & cursor)
}
+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);
par()->asGridInset()->delRow(hullRow());
}
- if (idx() > par()->nargs())
- idx() = par()->nargs();
+ if (idx() >= par()->nargs())
+ idx() = par()->nargs() - 1;
if (pos() > size())
pos() = size();
{
string s;
MathInset::difference_type i = macroNamePos();
- for ( ; i >= 0 && i < int(pos()); ++i)
+ for (; i >= 0 && i < int(pos()); ++i)
s += array().at(i)->getChar();
return s;
}
int y2 = c.yo() + c.descent();
pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
} else {
- std::vector<MathInset::idx_type> indices
+ vector<MathInset::idx_type> indices
= i1.par_->idxBetween(i1.idx_, i2.idx_);
for (unsigned i = 0; i < indices.size(); ++i) {
MathXArray & c = i1.xcell(indices[i]);
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)
+ for (; it != et; ++it)
if (it.par()->asBoxInset())
it.par()->asBoxInset()->rebreak();
}
MathIterator it = ibegin(formula()->par().nucleus());
MathIterator et = iend(formula()->par().nucleus());
while (1) {
- // 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();
+ // 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();
+ }
}
}
unsigned int n = 1;
istringstream is(s.substr(5).c_str());
is >> n;
- n = std::max(1u, n);
+ n = max(1u, n);
niceInsert(MathAtom(new MathCasesInset(n)));
return true;
}
string h_align;
istringstream is(s.substr(6).c_str());
is >> m >> n >> v_align >> h_align;
- m = std::max(1u, m);
- n = std::max(1u, n);
+ m = max(1u, m);
+ n = 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 if (c != ' ')
+ insert(c, lastcode_);
return true;
}
string MathCursor::info() const
{
- std::ostringstream os;
+ ostringstream os;
if (pos() > 0)
prevAtom()->infoize(os);
return os.str();