Fix a leak; cosmetics

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2439 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-08-07 12:02:21 +00:00
parent fb2300f658
commit 089f4fca7d
4 changed files with 34 additions and 43 deletions

View File

@ -46,16 +46,6 @@ void MathArray::deep_copy(int pos1, int pos2)
}
bool MathArray::next(int & pos) const
{
if (pos >= size() - 1)
return false;
++pos;
return true;
}
int MathArray::last() const
{
return size() - 1;
@ -107,7 +97,7 @@ string MathArray::getString(int & pos) const
MathTextCodes const fcode = getCode(pos);
do {
s += getChar(pos);
next(pos);
++pos;
} while (pos < size() && !isInset(pos) && getCode(pos) == fcode);
return s;
@ -198,14 +188,14 @@ void MathArray::erase()
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);
}

View File

@ -76,8 +76,6 @@ public:
///
void erase();
///
bool next(int & pos) const;
///
int last() const;

View File

@ -210,6 +210,7 @@ bool MathCursor::openable(MathInset * p, bool sel, bool useupdown) const
{
if (!p)
return false;
if (!(p->isActive() || (useupdown && p->isScriptInset())))
return false;
@ -230,6 +231,12 @@ void MathCursor::plainLeft()
}
void MathCursor::plainRight()
{
++cursor().pos_;
}
bool MathCursor::left(bool sel)
{
dump("Left 1");
@ -263,12 +270,6 @@ bool MathCursor::left(bool sel)
}
void MathCursor::plainRight()
{
++cursor().pos_;
}
bool MathCursor::right(bool sel)
{
dump("Right 1");
@ -284,14 +285,18 @@ bool MathCursor::right(bool sel)
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;
}
@ -450,7 +455,7 @@ void MathCursor::erase()
}
// 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);
@ -721,15 +726,12 @@ void MathCursor::interpret(string const & s)
}
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());
}
@ -776,8 +778,8 @@ void MathCursor::selCut()
if (selection_) {
theSelection.grab(*this);
theSelection.erase(*this);
selClear();
}
selClear();
}
@ -1282,7 +1284,7 @@ MathCursorPos MathCursor::normalAnchor() const
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";

View File

@ -465,15 +465,16 @@ void MathMatrixInset::mutate(short newtype)
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);