From 7ffc9e9175699076f84580196d6b6be2ed3fa291 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 3 Feb 2004 14:29:00 +0000 Subject: [PATCH] fix super/subscript crash git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8393 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/cursor.C | 19 ++++++++++--------- src/lyxfunc.C | 14 +++++--------- src/mathed/math_data.C | 4 ++-- src/mathed/math_nestinset.C | 7 ++----- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/cursor.C b/src/cursor.C index 854886481b..4fea08cdf8 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -303,7 +303,8 @@ void LCursor::getPos(int & x, int & y) const // inset.yo_, so getCursor() returns an old value. // Ugly as you like. } - lyxerr << "#### LCursor::getPos: x: " << x << " y: " << y << endl; + //lyxerr << "#### LCursor::getPos: " << *this + // << " x: " << x << " y: " << y << endl; } @@ -1313,7 +1314,7 @@ void LCursor::normalize() << idx() << ' ' << nargs() << " in: " << inset() << endl; } - idx() = min(idx(), nargs() - 1); + idx() = min(idx(), lastidx()); if (pos() > lastpos()) { lyxerr << "this should not really happen - 2: " @@ -1537,22 +1538,22 @@ bool LCursor::script(bool up) idx() = up; pos() = 0; } else if (pos() != 0 && prevAtom()->asScriptInset()) { - prevAtom().nucleus()->asScriptInset()->ensure(up); - posLeft(); - push(inset()); + --pos(); + nextAtom().nucleus()->asScriptInset()->ensure(up); + push(nextInset()); idx() = up; pos() = lastpos(); } else if (pos() != 0) { --pos(); cell()[pos()] = MathAtom(new MathScriptInset(nextAtom(), up)); - push(inset()); + push(nextInset()); idx() = up; pos() = 0; } else { plainInsert(MathAtom(new MathScriptInset(up))); - posLeft(); + --pos(); nextAtom().nucleus()->asScriptInset()->ensure(up); - push(inset()); + push(nextInset()); idx() = up; pos() = 0; } @@ -1563,7 +1564,7 @@ bool LCursor::script(bool up) bool LCursor::interpret(char c) { - lyxerr << "interpret 2: '" << c << "'" << endl; + //lyxerr << "interpret 2: '" << c << "'" << endl; clearTargetX(); if (inMacroArgMode()) { posLeft(); diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 0b55b74c00..eee8bb805e 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -162,13 +162,7 @@ void LyXFunc::handleKeyFunc(kb_action action) void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state) { - string argument; - - if (lyxerr.debugging(Debug::KEY)) { - lyxerr << "KeySym is " - << keysym->getSymbolName() - << endl; - } + lyxerr[Debug::KEY] << "KeySym is " << keysym->getSymbolName() << endl; // Do nothing if we have nothing (JMarc) if (!keysym->isOK()) { @@ -254,9 +248,11 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state) if (encoded_last_key != 0) { string arg; arg += encoded_last_key; + lyxerr << "SelfInsert arg[`" + << arg << "']" << endl; dispatch(FuncRequest(LFUN_SELFINSERT, arg)); - lyxerr[Debug::KEY] << "SelfInsert arg[`" - << argument << "']" << endl; + lyxerr[Debug::KEY] + << "SelfInsert arg[`" << arg << "']" << endl; } } else { dispatch(func); diff --git a/src/mathed/math_data.C b/src/mathed/math_data.C index d8a1f31902..7617621047 100644 --- a/src/mathed/math_data.C +++ b/src/mathed/math_data.C @@ -314,8 +314,8 @@ int MathArray::pos2x(size_type pos, int glue) const const_iterator it = begin() + i; if ((*it)->getChar() == ' ') x += glue; - lyxerr << "char: " << (*it)->getChar() - << "width: " << (*it)->width() << std::endl; + //lyxerr << "char: " << (*it)->getChar() + // << "width: " << (*it)->width() << std::endl; x += (*it)->width(); } return x; diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index d99f9fa30e..8e1ba41b5f 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -79,9 +79,6 @@ void MathNestInset::getCursorPos(CursorSlice const & cur, // move cursor visually into empty cells ("blue rectangles"); if (cur.cell().empty()) x += 2; - lyxerr << "MathNestInset::getCursorPos: cur: " << cur - << " x: " << x << " y: " << y << endl; - BOOST_ASSERT(x < 100000); } @@ -103,7 +100,7 @@ void MathNestInset::metrics(MetricsInfo const & mi) const bool MathNestInset::idxNext(LCursor & cur) const { BOOST_ASSERT(cur.inset() == this); - if (cur.idx() + 1 >= nargs()) + if (cur.idx() == cur.lastidx()) return false; ++cur.idx(); cur.pos() = 0; @@ -150,7 +147,7 @@ bool MathNestInset::idxLast(LCursor & cur) const BOOST_ASSERT(cur.inset() == this); if (nargs() == 0) return false; - cur.idx() = nargs() - 1; + cur.idx() = cur.lastidx(); cur.pos() = cur.lastpos(); return true; } -- 2.39.5