Fix "pullArg" behaviour when pressing <Backspace> at the beginning of an inset

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2307 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-07-23 13:52:48 +00:00
parent 37274eb840
commit 3024e24e80

View File

@ -211,13 +211,14 @@ void MathCursor::dump(char const * what) const
{ {
return; return;
lyxerr << "MC: " << what lyxerr << "MC: " << what << "\n";
<< " cursor.pos: " << cursor().pos_ for (unsigned i = 0; i < Cursor_.size(); ++i)
<< " cursor.idx: " << cursor().idx_ lyxerr << " i: " << i
<< " cursor.par: " << cursor().par_ << " pos: " << Cursor_[i].pos_
<< " sel: " << selection << " idx: " << Cursor_[i].idx_
<< " data: " << array() << " par: " << Cursor_[i].par_ << "\n";
<< "\n";
//lyxerr << " sel: " << selection << " data: " << array() << "\n";
} }
@ -287,11 +288,11 @@ bool MathCursor::Left(bool sel)
MathInset * p = prevInset(); MathInset * p = prevInset();
if (openable(p, sel, false)) { if (openable(p, sel, false)) {
array().prev(cursor().pos_); plainLeft();
push(p, false); push(p, false);
return true; return true;
} }
if (array().prev(cursor().pos_)) if (plainLeft())
return true; return true;
if (cursor().par_->idxLeft(cursor().idx_, cursor().pos_)) if (cursor().par_->idxLeft(cursor().idx_, cursor().pos_))
return true; return true;
@ -385,7 +386,7 @@ void MathCursor::SetPos(int x, int y)
if (openable(n, selection, true) && n->covers(x, y)) if (openable(n, selection, true) && n->covers(x, y))
push(n, true); push(n, true);
else if (openable(p, selection, true) && p->covers(x, y)) { else if (openable(p, selection, true) && p->covers(x, y)) {
array().prev(cursor().pos_); plainLeft();
push(p, false); push(p, false);
} else } else
break; break;
@ -497,14 +498,6 @@ void MathCursor::Delete()
Delete(); Delete();
} }
#ifdef WITH_WARNINGS
#warning pullArg disabled
#endif
//if (cursor().pos_ == 0 && Cursor_.size() >= 1) {
// lyxerr << "Delete: popping...\n";
// pop();
//}
dump("Delete 2"); dump("Delete 2");
} }
@ -558,7 +551,7 @@ bool MathCursor::Up(bool sel)
if (p) { if (p) {
int idx, pos; int idx, pos;
if (p->idxLastUp(idx, pos)) { if (p->idxLastUp(idx, pos)) {
array().prev(cursor().pos_); plainLeft();
push(p, false); push(p, false);
cursor().par_ = p; cursor().par_ = p;
cursor().idx_ = idx; cursor().idx_ = idx;
@ -613,7 +606,7 @@ bool MathCursor::Down(bool sel)
if (p) { if (p) {
int idx, pos; int idx, pos;
if (p->idxLastDown(idx, pos)) { if (p->idxLastDown(idx, pos)) {
array().prev(cursor().pos_); plainLeft();
push(p, false); push(p, false);
cursor().idx_ = idx; cursor().idx_ = idx;
cursor().pos_ = pos; cursor().pos_ = pos;
@ -661,7 +654,7 @@ in_word_set(s) << " \n";
if (!p) { if (!p) {
p = new MathScriptInset(true, false); p = new MathScriptInset(true, false);
insert(p); insert(p);
array().prev(cursor().pos_); plainLeft();
} }
push(p, true); push(p, true);
p->up(true); p->up(true);
@ -674,7 +667,7 @@ in_word_set(s) << " \n";
if (!p) { if (!p) {
p = new MathScriptInset(false, true); p = new MathScriptInset(false, true);
insert(p); insert(p);
array().prev(cursor().pos_); plainLeft();
} }
push(p, true); push(p, true);
p->down(true); p->down(true);
@ -772,7 +765,7 @@ in_word_set(s) << " \n";
SelCut(); SelCut();
insert(p); insert(p);
if (p->nargs()) { if (p->nargs()) {
array().prev(cursor().pos_); plainLeft();
push(p, true); push(p, true);
if (oldsel) if (oldsel)
SelPaste(); SelPaste();
@ -984,6 +977,7 @@ void MathCursor::handleDelim(int l, int r)
p->cell(0) = theSelection.glue(); p->cell(0) = theSelection.glue();
} }
insert(p); insert(p);
plainLeft();
push(p, true); push(p, true);
} }
@ -1071,12 +1065,12 @@ MathInset * MathCursor::enclosing(MathInsetTypes t, int & idx) const
void MathCursor::pullArg() void MathCursor::pullArg()
{ {
// pullArg // pullArg
dump("pullarg");
MathArray a = array(); MathArray a = array();
if (!Left()) if (pop()) {
return; array().erase(cursor().pos_);
normalize(); array().insert(cursor().pos_, a);
array().erase(cursor().pos_); }
array().insert(cursor().pos_, a);
} }