}
-bool MathArray::next(int & pos) const
-{
- if (pos >= size() - 1)
- return false;
-
- ++pos;
- return true;
-}
-
-
int MathArray::last() const
{
return size() - 1;
MathTextCodes const fcode = getCode(pos);
do {
s += getChar(pos);
- next(pos);
+ ++pos;
} while (pos < size() && !isInset(pos) && getCode(pos) == fcode);
return s;
void MathArray::erase(int pos)
{
if (pos < size())
- bf_.erase(bf_.begin() + pos);
+ erase(pos, pos + 1);
}
void MathArray::erase(int pos1, int pos2)
{
for (int pos = pos1; pos < pos2; ++pos)
- delete nextInset(pos);
+ delete bf_[pos];
bf_.erase(bf_.begin() + pos1, bf_.begin() + pos2);
}
{
if (!p)
return false;
+
if (!(p->isActive() || (useupdown && p->isScriptInset())))
return false;
}
+void MathCursor::plainRight()
+{
+ ++cursor().pos_;
+}
+
+
bool MathCursor::left(bool sel)
{
dump("Left 1");
}
-void MathCursor::plainRight()
-{
- ++cursor().pos_;
-}
-
-
bool MathCursor::right(bool sel)
{
dump("Right 1");
push(p, true);
return true;
}
- if (array().next(cursor().pos_))
+ if (cursor().pos_ != array().size()) {
+ plainRight();
return true;
- if (cursor().par_->idxRight(cursor().idx_, cursor().pos_))
+ }
+ if (cursor().par_->idxRight(cursor().idx_, cursor().pos_)) {
return true;
- if (!pop())
- return false;
- array().next(cursor().pos_);
- return true;
+ }
+ if (pop()) {
+ plainRight();
+ return true;
+ }
+ return false;
}
}
// delete empty cells if necessary
- if (cursor().pos_ == 0 && array().size() == 0) {
+ if (cursor().pos_ == 0 && array().empty()) {
bool popit;
bool removeit;
cursor().par_->idxDelete(cursor().idx_, popit, removeit);
}
if (p) {
- bool oldsel = selection_;
- if (oldsel)
- selCut();
+ selCut();
insert(p);
if (p->nargs()) {
plainLeft();
right(); // do not push for e.g. MathSymbolInset
- if (oldsel)
- selPaste();
+ selPaste();
}
p->metrics(p->size());
}
if (selection_) {
theSelection.grab(*this);
theSelection.erase(*this);
- selClear();
}
+ selClear();
}
MathCursorPos normal = Anchor_[Cursor_.size() - 1];
if (Cursor_.size() < Anchor_.size() && !(normal < cursor())) {
// anchor is behind cursor -> move anchor behind the inset
- normal.cell().next(normal.pos_);
+ ++normal.pos_;
}
//lyxerr << "normalizing: from " << Anchor_[Anchor_.size() - 1] << " to "
// << normal << "\n";
MathGridInset::addCol(1);
// split it "nicely" on the firest relop
- int pos1 = firstRelOp(cell(0));
+ int pos = firstRelOp(cell(0));
cell(1) = cell(0);
- cell(0).erase(pos1, cell(0).size());
- cell(1).erase(0, pos1);
- int pos2 = 0;
- cell(1).next(pos2);
- cell(2) = cell(1);
- cell(1).erase(pos2, cell(1).size());
- cell(2).erase(0, pos2);
+ cell(0).erase(pos, cell(0).size());
+ cell(1).erase(0, pos);
+
+ if (cell(1).size()) {
+ cell(2) = cell(1);
+ cell(1).erase(1, cell(1).size());
+ cell(2).erase(0);
+ }
halign("rcl");
setType(LM_OT_EQNARRAY);